Reply to comment

Boot from Grub Prompt - Boot from Grub Rescue Prompt

So, you're stuck at a grub> prompt without a liveCD with which to rescue your system...

There are several ways to fix a messed-up boot-loader. As far as I'm concerned, one of the best methods is to boot a kernel manually, then make the repairs from within a working desktop.

You'll need three key pieces of information: The number of the hard-drive you're wishing to boot from, (usually (hd0)), the partition on which Ubuntu is installed, and the name/number of the kernel to boot. Grub2 makes finding the information easy. Please, read through this How-To first, then follow the steps in the instructions.

There's something you need to know here. In grub-speak, hard-drives are listed as "hd"s, and they're numbered, whereas in linux-speak, they're listed as "sd"s, and are represented by letters.
For example "hd0, hd1, hd2, (hd0,1), (hd0,2),", is how grub lists hard-drives and partitions, and sda, sdb, sdc, (sda,1), (sda,2), etc, is how Linux lists them. The first number or letter designates the hard-drive, the second number, the one after the comma, the partition.

To find bootable hard-drives and partitions from the grub prompt, type the ls command and press enter.

Grub2 will spit out something along the lines of (hd0) (hd0,2) (hd0,1), depending on how your hard-drive is partitioned, and how many partitions are present.

To find which kernels and initrd.img files are available, type: ls -l /boot.
The commandls -l / will produce a list of the file system.

Grub2 will spit out a complete listing of available kernels and intird.img files.

Write down or memorise the number of the kernel and the initrd.img file you want to load, or, even easier, use TAB-completion as shown at the bottom of the post, and enter these commands:

root (hdX,Y) --replace the X and Y with the drive and partition number you located with the ls command.

If no errors are returned, enter:

linux /boot/vmlinuz-x.x.x-x-xxxxxx root=/dev/sdXY ro --again, replacing the x.x...x with the kernel number, and the XY with with the correct drive letter and partition number.

You've supplied enough information at this point to boot the machine with boot, though it is customary to also supply the intird.img with:

initrd /boot/initrd.img-x.x.x-x-xxxxx then boot

If you specified the correct drive number, partition and kernel, Ubuntu will boot. If at any point a file-not-found error was returned, you've chosen the wrong drive, partition, or possibly made a spelling error when specifying the kernel or initrd.img and need to make an adjustment.

As in BASH, Grub2 keeps a history, meaning that the up and down arrows can be used to recall previous commands, and tab-completion is available to help with spelling.

For example, if you enter: linux /boot/vml then press TAB, the most recent kernel will be specified. That applies to the initrd.img as well, of course.

There, that's not so complicated, is it? It might seem to be at first - just keep in mind that only three or four commands are required.

To recap:
root (hd0,X)
linux /boot/vml use TAB completion here root=/dev/sdaX ro
initrd /boot/initrd.img- use TAB completion here
boot

Presuming you've managed to get your system to boot, you still need to repair grub once you get to the desktop. A great tool for that task is Boot Repair. Sometimes simply running sudo update-grub in a terminal is sufficient, though I strongly recommend Boot Repair.

If these instructions didn't cut it for you, or if you've got an Ubuntu liveCD and would prefer to use a graphical repair tool, check out my Boot Repair Tutorial

Please note that the instructions apply only to a normal grub prompt - to get back into a system from the grub-rescue prompt, a couple extra steps are required. Namely:

set
ls
set prefix=(hd0,X)/boot/grub - change the X to the partition where grub is located (usaually /boot/grub in Ubuntu)
set root=(hd0,1)
insmod normal

If you managed to get normal grub prompt, proceed with the remainder of the instructions, if not, you might have to change the prefix. IE: set prefix=(hd0,X)/grub.
Keep in mind that a grub-rescue prompt usually means that grub wasn't installed properly, meaning you'll have to re-install (grub) using a liveCD.

Resources:

Ubuntu Community Documentation - Grub2
gnu.org/software/grub/manual/grub2
archlinux.org/GRUB2

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Images can be added to this post.

More information about formatting options

Image CAPTCHA
Enter the characters shown in the image.