Fix This! – Grub 2 Boot Recovery


What do you do when you can’t boot?  No, you don’t call The Ghostbusters.  Grub recovery is one of the most sought after questions from many Linux users, even above the beginner level.  It can be confusing, being left with a ‘Grub> ‘ prompt upon bootup.  I want to go through some good techniques to get yourself back on track.


The Easy Way

I have found Rescue cd’s such as SystemRescueCD to be highly valuable for disk recovery, among other things..  For Grub related issues, there is Rescatux.  Rescatux also has a companion, Super Grub2 Disk.  The later is based on Grub2, but either should work fine for Grub2, which is the current Grub implementation on newer distributions.  Burn either image to a CD/DVD, restart you pc, and boot into the CD.  The presentation is straightforward, but if you have any issues, consult the main site.

Live CDs

Another way is through Live CDs.   One of the easiest to use LIve CDs out there is Ubuntu (you can use any live CD if you wish).  This example assumes your disk is identified as ‘/dev/sda’.  The following set of commands should get you up and running again in no time.

First let’s find out what drive contains the root partition (typically /dev/sda1)

 mount /dev/sda1

You will see a list similar to this:

$ sudo fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00008ec7

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1013 8136891 8e Linux LVM
/dev/sda2 1014 1044 249007+ 5 Extended
/dev/sda5 1014 1044 248976 83 Linux

Now, we need to mount the drive, typically /dev/sda1, and install grub into the root directory:

mount /dev/sda1 /mnt/ grub-install --root-directory=/mnt /dev/sda

If you havea  /boot partition (typical for EFI systems), you will need to mount both /boot and root .  Let’s assume /dev/sda1 is the /boot partition, and /dev/sda2 is the root partition.

sudo mount /dev/sda2 /mnt sudo mount /dev/sda1 /mnt/boot

Now, remount the rest of your devices using the –bind option:

sudo mount --bind /dev /mnt/dev

Once this is done, you have mounted the essentials for your system.  Change from the root filesystem of the Live CD to your installation with ‘chroot’ :

sudo chroot /mnt

Reconfigure the Grub package:

dpkg-reconfigure grub-pc

Make sure you tell Grub which particular device to use.  Once you have done that, unmount the drives and reboot.  The third line is optional if you have a seperate boot partition:

sudo umount /mnt/dev sudo umount /mnt sudo umount /boot reboot

The above two methods are just the tip of the iceberg, but work for most.  While some will tell you to use syslinux, don’t listen to those blokes, Grub2 is far more powerful, but in the end,  the choice is up to you.  See reference sources below if you wish to learn more.

Covering your arse with grub-mkrescue

You can also save yourself a LOT of trouble by making a grub rescue disk.  This way, if you get in a bind, you can always use this disc to get yourself back up and running in no time flat. 

Making the image:

grub-mkrescue --output=.iso /boot/grub

Now, burn the image to a CD with your program of choice, such as Brasero (GUI), dd (CLI), or whichever you wish to use.  After booting this CD, check the configuration of grub with:

configfile /grub.cfg

This should output your grub menu.  If all looks good, keep the CD handy for emergencies.  Be sure to make a new rescue CD if you change disks or move around partitions on your system(s).  You can copy that grub menu or compare it to what you had before.  Questions or comments?



GRUB 2 official site
GRUB 2 Manual
GRUB 2 Ubuntu Wiki documentation
GRUB 2 Command List

A wealth of information on Grub2
Grub Error Messages
Arch Linux Grub Page
Source Material For this Article


About professorkaos64

Posted on 20130821, in Fix This!, How-To and tagged , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s