Restore Grub Bootloader

From Knowledge76

Jump to: navigation, search


Contents

Overview

GRUB is the default Bootloader program in Ubuntu. It takes care of getting the operating system started up. It is also responsible for allowing the user to select between multiple operating systems at boot. Sometimes, GRUB can begin acting funny, and it may not let you boot into Ubuntu to fix the problem.

Important Note About GRUB Updates!

If you need to configure grub-pc (for example, after an update), installing grub to all devices will break GRUB. You will need to install to /dev/sda (not /dev/sda1) **only**. Installing everywhere **will** break the bootloader.


Reinstall GRUB Bootloader and MBR (Master Boot Record) for Ubuntu 9.10 and Later

Insert an Ubuntu Install CD. You can find instructions for burning them Here. Then boot to it. Open a terminal (Applications > Accessories > Terminal) and run the following commands:

sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
sudo chroot /mnt
grub-install --force /dev/sda

After this, reboot your computer, removing the disk when prompted, and Ubuntu should boot.


Common Errors

Often, the fourth command (sudo cp /etc/resolv.conf /mnt/etc/resolv.conf) will return an error, stating that the file does not exist. This is not an issue, and you can proceed. Alternatively, connecting to the internet from the LiveCD should create this file.

If the chroot command returns with the error "chroot: cannot run command `/bin/bash': Exec format error", this probably indicates that the Ubuntu Install CD is not compatible with that of the installed system.

For example, the error is most frequently seen when trying to chroot to a 64-bit system (eg. amd64) from a 32-bit Install CD (eg. x86).

The solution is to use an Install CD which is using the same architecture as the installed system (i.e. 32-bit Install CD for 32-bit targets / 64-bit Install CD for 64-bit targets).

Personal tools