Situation : Whenever there is inconsistency in the GRUB file, empty grub configuration or of the grub file got removed accidentally, follow the below steps to fix the grub issue.
Solution:
STEP 1 : List the partitions by using “ ls “ command
grub > ls
(proc) (hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (fd0)
STEP 2: Findout the root partitions by using command ls < partition name >. Run ls command to all above listed available partitions.
STEP 3: Set the root partition. In our case its present in (hd0,msdos1)
grub> set root=(hd0,msdos1)
grub>
STEP 4: Type Linux and specify the kernel or Press tab for listing the available kernel. Once choosing it, we have to specify the root volume (In our example its /dev/sda1).
grub> linux /vmlinuz-3.10.0-229.el7.x86_64 ro root=/dev/sda1
STEP 5: Specify the initramfs image press tab for listing it. Choose the initramfs image with the same kernel version.
grub> initrd /initramfs-3.10.0-229.el7.x86_64.img
Execute 'boot' command to boot the server with above configuration.
Once the server is up, use grub2-mkconfig command to rebuild the grub.conf file.
[root@nsk /]grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
...
.
done
Finally verify the grub file under /boot/grub2/
[root@nsk /]# cd /boot/grub2/
[root@nsk grub2]# ls
device.map fonts grub.cfg grubenv i386-pc locale
Reboot the server and verify one more time.
No comments:
Post a Comment