The Grub Rescue Mode Megathread
(The Grub Rescue Hijack Thread)
What's with the Subtitle?
Adding "Me Too" Posts just aren't proper etiquette. And who can think of an original title on this subject. So feel free to discuss your problem here, but read the rules first! Oh, and it's not "Grub 2" because Grub legacy doesn't have a 'grub rescue' prompt; if you see 'grub rescue>', you are using Grub 2.
Should I Be Here?
If you end up at a Grub rescue prompt while trying to boot to a normal installation, this thread may help. A 'grub rescue>' prompt means that Grub 2 has read the MBR but can't find the grub folder, specific files, and/or a usable grub.cfg file. If you see a 'grub' prompt, you have more capabilities such as TAB Complete and scrollback, but you can try the same procedures to restore Grub 2.
If you are using Wubi (Ubuntu within Windows), there is a specific section for Wubi users marked "Wubi Only". However, I would recommend you proceed to forum member Rubi 1200's guide for dealing with Wubi related problems: Wubi Megathread. Wubi boot problem descriptions and the rememedies are well-documented on that site.
What Should I Try First?
If possible, obtain and boot an Ubuntu installation CD (LiveCD) or bootable USB. You can obtain the Live CD iso file from http://www.ubuntu.com/desktop/get-ubuntu/download. Preferably use a CD of the same version you are trying to recover; if you don't have the same version, use a more recent release to get a later version of Grub 2.
From the LiveCD Desktop, there are several things that you can do that will either fix Grub 2 problems or give you information that can help.
- Use Nautilus, GParted or Disk Utility to determine your Ubuntu partition. Disk checks can be accomplished with Disk Utility or Gparted, both accessed via the System, Administration menu.
- Mount your Ubuntu installation and attempt to edit your real installation's boot files.
- Run the boot info script by forum member meierfra.
- Access the forums and Internet for help.
If you can get to the LiveCD, many Grub 2 problems can be solved by 1) reinstalling the bootloader or 2) purging/reinstalling Grub2. Purging and reinstalling has the advantage of repairing corrupted files and installing files manually deleted by the user. Nevertheless, the reinstall option should be attempted first.
I'm Still Stuck at the 'grub rescue>' Prompt
- If you are reading this, it should mean:
- You haven't been able to fix things from the LiveCD.
- You can't boot to the Desktop (no CD, no CD-ROM, no bootable USB, no Internet)
- You couldn't get the HOWTO referenced in the previous section to work.
- You didn't read the previous stuff nor view the HOWTO linked above because you are the impatient type.
- OK, fine. Hijack this thread! Let us hear your pleas! But first, read:
Rules for Posting !
- Your first post if you need help must include the RESULTS.txt contents from meierfra's boot info script
- Go to http://bootinfoscript.sourceforge.net/
- Follow the instructions on the site on how to download and execute the script.
- Start a new post. Press the # icon in the post's menu bar. This will generate [code] [/code] tags. You may also manually type them. Paste the contents of RESULTS.txt between the 'code' tags.
- Explain why the procedures below didn't work. Include error messages if possible.
- Note to helpers: Since there may well be multiple users with problems, be sure you identify to whom your post is directed via brief quotes or "@ forum-username".
- Since multiple users will be seeeking help, be specific - No "It didn't work" posts. Be specific on what did or did not work!
'grub rescue>' Boot Procedures (About Time!)
The short version - the commands you must run. Substitute the correct values for X,Y. If these commands fail or you want explanations, refer to the next entry - "Commands you may need to run"
Code:
set prefix=(hdX,Y)/boot/grub # Example: (hd0,1) , (hd1,5)
set root=(hdX,Y)
insmod linux
linux /vmlinuz root=/dev/sdXY ro # Example: root=/dev/sda1 , /dev/sdb5
initrd /initrd.img
boot
Commands you may need to run if the previous command set failed:
Text in bold black are commands to be entered at the 'grub rescue>' prompt. If there is an X,Y component, substitute the correct value for your Ubuntu partition. Example: (hdX,Y) >> (hd0,5); sdXY >> sda5
- Locate the Ubuntu Partition.
- ls - This will display the known drives/partitions.
- Drives are designated (hd0), (hd1), etc. Partitions are designated (hd0,1), (hd0,2), (hd1,1), etc
- The Ubuntu partition will be one of the (hdX,Y) formatted returns.
- If all you get is (hd0) you most likely have a partition table or disk error. Seek assistance elsewhere! (fsck, e2fsck, TestDisk, etc.)
- Locate the grub folder.
- ls (hd0,1)/boot/grub - Try each partition (hd0,1), etc. until you find your grub folder
- If you don't find the /boot/grub folder, start with a wider search and narrow the search once you find the Ubuntu folders:
- ls (hdX,Y)/ # Look for the Ubuntu folders, such as lost+found, /bin/, /boot, /home,
- ls (hdX,Y)/boot # Look for the grub folder.
- The grub folder will contain dozens of *.mod files, as well as grub.cfg
- Set prefix and root.
- set prefix=(hdX,Y)/boot/grub
- Example: set prefix=(hd0,5)/boot/grub
- set root=(hdX,Y)
- Example: set root=(hd0,5)
- Confirm the prefix and root settings.
- Load Modules.
- No modules can be loaded until the prefix is set correctly.
- An incorrect path or missing file will result in an "unknown command" or "file not found" error. Use the set and ls /boot/grub or ls /boot commands to verify the path and look for the specific file(s).
- If you receive an error, return to Step 3.
- insmod linux - if you get an 'unknown command' when entering the 'linux' command later, repeat using: insmod /boot/grub/linux.mod
- Additional modules such as normal.mod and help.mod may be loaded. Not all modules are available in rescue mode.
- Load the Kernel & Initrd image.
- linux /vmlinuz root=/dev/sdXY ro
- Substitute the correct values for X,Y - Example: sda5
- initrd /initrd.img
- To load a specific kernel, especially an older kernel:
- linux /boot/vmlinuz-<kernel version> root=/dev/sdXY ro
- initrd /boot/initrd.img-<kernel version>
- Example: linux /boot/vmlinuz-2.6.35-22-generic root=/dev/sda5 ro
- Example: initrd /boot/initrd-2.6.35-22-generic
- Boot.
Wubi Only.
Forum member Rubi1200 has created an excellent site for dealing with Wubi related problems. You can continue with the instructions below but I would recommend you go to his forum guide, which deals specifically with Wubi:
Wubi Megathread
The procedures below show the procedures from a normal Wubi Grub 2 prompt. In my testing, the modules were already loaded so a bad Wubi installation may react differently. However, by seeing what is normal for Wubi you may be able to also return it to a bootable state.
Attention Wubi 9.10 Users. You may need to copy a new version of the file "wubildr". Here is the link to forum member meierfra's guide on how to do that:
Boot Problems:Wubi 9.10
Booting from the Wubi Grub prompt requires different commands as the file locations are not the same as for a normal Ubuntu installation.
- The Wubi files are not on an Ubuntu partition. They are contained in a Windows partition within a Windows file: /ubuntu/disks/root.disk
- If you want to inspect your Wubi files from the Live CD (and possibly repair them or retrieve data):
- Determine the Windows partition (/dev/sdXY) Example: /dev/sda1
- Make the mount points and mount Windows: sudo mkdir /mnt/windows && sudo mount /dev/sdXY /mnt/windows
- Make the Wubi mount point and mount the Wubi file: sudo mkdir /mnt/wubi && sudo mount /mnt/windows/ubuntu/disks/root.disk /mnt/wubi
- At the grub prompt, the modules are not contained in the /boot/grub folder, but in the Wubi folder: (loop0)/usr/lib/grub/i386-pc/
- Review the procedures and explanations in the previous sections and refer to those sections for additional guidance.
- If you encounted an error, review the similar step above for possible solutions.
- With a 'grub>' prompt, TAB COMPLETION may be available.
- Run the commands only from this section. Do not run the commands in previous sections.
The short version - the commands you must run. Substitute the correct values for X,Y. If these commands fail or you want explanations, refer to the next entry - "Commands you may need to run"
Code:
set root=(hdX,Y) # Example: (hd0,1) , (hd1,5)
loopback (loop0) /ubuntu/disks/root.disk
set root=(loop0)[/B]
linux /vmlinuz root=/dev/sdXY loop=/ubuntu/disks/root.disk ro # Example: root=/dev/sda1 , /dev/sdb5
initrd /initrd.img
boot
Commands you may need to run if the previous command set failed:
- Locate the Ubuntu Partition.
- ls - This will display the known drives/partitions.
- You should see (memdisk), (loop0), and your Windows partition (hdX,Y) or (hdX,msdosY)
- If there is no (loop0):
- set root=(hdX,Y) # X,Y is your Windows partition. Example: sda1: X=0, Y=1; sdb5: X=1, Y=5
- loopback (loop0) /ubuntu/disks/root.disk
- Locate grub.cfg.
- ls (loop0)/boot/grub - Only the grub.cfg & grubenv files may be present.
- No *.mod files will be present.
- Set prefix and root.
- set prefix=(memdisk)/boot/grub
- set root=(loop0)
- Confirm the prefix and root settings:
- Load Modules.
- Some modules may already be loaded.
- No modules can be loaded until the prefix is set correctly.
- Available modules: ls (loop0)/usr/lib/grub/i386-pc/
- An incorrect path or missing file will result in an "unknown command" or "file not found" error.
- You can check the currently loaded modules with: lsmod
- If the output scrolls off the screen: set pager=1
- insmod (loop0)/usr/lib/grub/i386-pc/linux.mod
- To load additional modules:
- insmod (loop0)/usr/lib/grub/i386-pc/<module.mod>
- Load the Kernel & Initrd image.
- linux /vmlinuz root=/dev/sdXY loop=/ubuntu/disks/root.disk ro
- * Substitute the correct values for X,Y - Example: sda5
- initrd /initrd.img
- To load a specific kernel, especially an older kernel:
- linux /boot/vmlinuz-<kernel version> /dev/sdXY ro # TAB to complete the kernel version but don't forget the additional entries.
- initrd /boot/initrd.img-<kernel version> # TAB to complete the kernel version.
* Example: linux /boot/vmlinuz-2.6.35-22-generic root=/dev/sda5 ro
* Example: initrd /boot/initrd-2.6.35-22-generic
- initrd /initrd.img
- Boot.
Selected Links.
Grub 2 Community Doc - Rescue Mode
HOWTO: Purge & Reinstall Grub 2 from the Live CD
Meierfra's Boot Info Script
Bookmarks