grub rescue - How to recover the System

BulkMail Verifier
Submitted by leopathu on Sun, 05/08/2022 - 13:01
grub

Commonly most of the people facing the grub rescue crash, mostly it will happen when we use dual boot option to use two different Operating System. The main cause of the problem we had deleted the linux partition in the system.

  • grub rescue> does not support cd, cp or any other filesystem commands except its own variation of ls which is really a kind of find command.

So first, had to find the partition with the /boot directory containing the vmlinuz and other boot image files...

  • grub rescue>  ls   (hd0,4) (hd0,3) (hd0,2) (hd0,1)  
  • grub rescue>  ls (hd0,4)/boot ... some kind of 'not found' message
  • grub rescue>  ls (hd0,3)/boot ... some kind of 'not found' message
  • grub rescue>  ls (hd0,2)/boot ... grub ... initrd.img-2.6.32-33-generic ... vmlinuz-2.6.32-33-generic
    • ls without arguments returns the four partitions on this system.
    • ls (hd0,4)/boot does not find a /boot directory on partition (hd0,4).
    • ls (hd0,3)/boot does not find a /boot directory on partition (hd0,3).
    • ls (hd0,2)/boot finds a /boot directory on partition (hd0,2) and it contains a vmlinuzand other boot image files we want.

To manually boot from the grub rescue> prompt ...

  • grub rescue>  set root=(hd0,2)/boot  
  • grub rescue>  insmod linux  
  • grub rescue>  linux (hd0,2)/boot/vmlinuz-2.6.32-33-generic  
  • grub rescue>  initrd (hd0,2)/boot/initrd.img-2.6.32-33-generic  
  • grub rescue>  boot  
    • Set root to use the /boot directory on partition (hd0,2).
    • Load kernel module linux.
    • Set that module to use the kernel image vmlinuz-2.6.32-33-generic.
    • Set initrd(init RAM disk) to use the image initrd.img-2.6.32-33-generic.
    • Boot Linux.

This boots to a BusyBox commandline prompt which has all the basic filesystem commands (and then some!).

Then could move the *.mod files back to the /boot/grub directory ...

  • busybox>  cd /boot   busybox>  mv mod/* grub busybox>  reboot

Successful Reboot!

 

 

Tags