Originally posted to AskUbuntu.com ...

AskUbuntu has adopted a policy of closing questions about EOL (End Of Life) versions. There's a vocal contingent to remove them as well. To prevent possible loss of this popular question (342335 views to date), am placing a revised version here. --- docsalvager

The "classic" system...

  • Puppy Linux 5.2.8 (Lucid) based on Ubuntu 10.04 (Lucid Lynx)
  • GRUB 2 boot loader

GRUB 2 puts a number of *.mod files (kernel modules) in /boot/grub. Deleting these files (thinking they were misplaced sound files) resulted in failure on reboot and the prompt grub rescue>.

How to recover in this situation?

closed as off-topic by psusi, jasonwryan, Networker, Anthon, John WH Smith Dec 28 '14 at 18:04

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – psusi, Anthon, John WH Smith
  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – jasonwryan, Networker

  • 1
    Seems like a dumb question.. obviously you either restore the deleted files from backup, or reinstall grub ( and there are plenty of questions about how to do that already ) – psusi Dec 28 '14 at 2:08
  • Absolute past viewing statistics are about as relevant as those of yesterday's newspaper. – Anthon Dec 28 '14 at 8:03
  • Newspapers from the past have solved countless crimes and been responsible for a great deal of problem-solving that made the world a better place. – DocSalvager Dec 30 '14 at 0:42
  • It would seem to me that booting into rescue mode off the DVD and reinstalling grub from there would probably be ideal. It's probably a lot more straightforward for most people since the mentioned data loss should be restricted to the files in the package. – Bratchley Dec 30 '14 at 2:24
  • Not to say that I don't think fishing the specific files out of the initrd isn't clever. I Just think it's likely to confuse people as it is to help. Booting into rescue/recovery mode is a more common procedure. – Bratchley Dec 30 '14 at 2:25

This answer is for others out there that DocSalvager's answer doesn't work for.

  1. I followed DocSalvager's use of ls to find the correct hard drive partition. In my case it was (hd0,msdos5).
  2. Then I executed the following commands to get back to the normal grub boot loader screen.

    grub rescue>  set boot=(hd0,msdos5)
    grub rescue>  set prefix=(hd0,msdos5)/boot/grub
    grub rescue>  insmod normal  
    grub rescue>  normal  
    
  3. After booting into Ubuntu I repaired the grub boot loader with the following commands from the terminal.

    sudo grub-install /dev/sda 
    

Please reference this source for a visual walk through of this process.

  • 6
    I'm glad you guys posted before this was closed – smac89 Oct 14 '15 at 4:47
  • 1
    Worked for me. Thanks! – Anmol Singh Jaggi Jun 15 '16 at 8:56
  • 2
    Perfect - exactly the help I needed to boot! I also ran sudo update-grub before grub-install, because my partition layout had changed. – mwfearnley Aug 14 '16 at 14:44
  • How long does the insmod normal command take? After pressing Enter my ubuntu hangs. Admittedly it's 'running' as a VM in Oracle VirtualBox though. – snark Nov 9 '17 at 13:13
  • 1
    Update: It came back eventually with error: failure reading sector 0x8019a4 from 'hd0' so I guess it's pretty terminal! – snark Nov 9 '17 at 13:24
up vote 29 down vote accepted

Recovering from a grub rescue crash ...

  • 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 vmlinuz and 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 grub 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!

See also ...

  • I cannot find any boot folder at the root level in the BusyBox – souparno majumder Sep 20 '16 at 9:51
  • 1
    The vmlinuz,... boot images you are looking for could be in the top-level root filesystem so try using just a slash. That will also show top-level directories. If the boot images are not in the top-level root, you can start trying the most promising of the directories till you find them. For example: ls (hd0,1)/, ls (hd0,2)/, ls (hd0,2)/initramfs/, etc.. – DocSalvager Sep 21 '16 at 5:48
  • In my case, after running ls (hd0,7)/boot, it shows attempt to read or write outside of disk 'hd0'. – d a i s y Nov 17 '16 at 5:19
  • There are less than 7 partitions on drive hd0. It may also be that there is some unallocated space on the drive that is not part of any partition. – DocSalvager Nov 17 '16 at 6:04
  • 1
    I had to set the prefix to /boot/grub before being allowed to run insmod linux! – Emil Feb 6 '17 at 15:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.