You are on page 1of 5

You can re-install grub in the Master Boot Record using the LiveCD for you distribution version,

It goes like this:

Boot from LiveCD please try to use a LiveCD that has the same version of Grub2 as the
installed version

Mount the root of the installed Ubuntu at /mnt

Change root

Update grub

Install grub

Reboot
The above steps are from near the bottom of the Ubuntu Community Documentation of Grub2
After booting from the liveCD ( select "Try Ubuntu" on the opening screen)
Then start up a terminal (dash, type-in terminal, )

It may be easier to open this web page while running LiveCD. Firefox should allow you to
do this.
Type in the terminal sudo fdisk -l and enter your password if asked. that's a lower case L Find
the installed Ubuntu partitions, (from mine with other disks snipped here)
me@mycomputer:~$sudo fdisk -l

Disk /dev/sde: 300.1 GB, 300089646592 bytes


255 heads, 63 sectors/track, 36483 cylinders, total 586112591 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3f5ebeb

Device Boot Start End Blocks Id System


/dev/sde2 138464296 586110975 223823340 5 Extended
/dev/sde3 * 2048 138463231 69230592 83 Linux
/dev/sde5 138464298 313460279 87497991 7 HPFS/NTFS/exFAT
/dev/sde6 313460736 317650943 2095104 82 Linux swap / Solaris
/dev/sde7 317652992 581922815 132134912 83 Linux
/dev/sde8 581924864 586110975 2093056 82 Linux swap / Solaris

Partition table entries are not in disk order

Find your Linux installation (Id=83, System=Linux0 then type in sudo mount /dev/sde3 /mnt
but use your partition instead of /dev/sde3(my root partition is sde3, sde7 is my home partition)

This is assuming that you do not have a separate /boot partition. If you do, you will need to also
mount it by typing sudo mount /dev/sd /mnt/boot, where sd is the partition where you installed
the separate boot directory.
sudo ls /mnt just checking to see if I got it right
me@mycomputer:~$ sudo mount /dev/sde3 /mnt
me@mycomputer:~$ sudo ls /mnt
bin cdrom etc initrd.img lib media opt root sbin srv
tmp var vmlinuz.old
boot dev home initrd.img.old lost+found mnt proc run selinux sys
usr vmlinuz

You should test to see if the boot directory is properly installed. Type in sudo ls /mnt/boot and if it
is empty, the boot directory is not installed. It should look something like this:
me@mycomputer:~$ sudo ls /boot
abi-2.6.35-30-generic initrd.img-2.6.35-30-generic System.map-2.6.35-31-
generic
abi-2.6.35-31-generic initrd.img-2.6.35-31-generic vmcoreinfo-2.6.35-30-
generic
config-2.6.35-30-generic memtest86+.bin vmcoreinfo-2.6.35-31-
generic
config-2.6.35-31-generic memtest86+_multiboot.bin vmlinuz-2.6.35-30-
generic
grub System.map-2.6.35-30-generic vmlinuz-2.6.35-31-
generic

Type in for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i; done do as one line
Then type in sudo chroot /mnt change the root
Now type in sudo update-grub now update grub
me@mycomputer:~$ sudo for i in /dev /dev/pts /proc /sys; do sudo mount -B $i
/mnt$i; done
me@mycomputer:~$ sudo chroot /mnt
me@mycomputer:~$ sudo update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.0.0-13-generic
Found initrd image: /boot/initrd.img-3.0.0-13-generic
Found linux image: /boot/vmlinuz-3.0.0-12-generic
Found initrd image: /boot/initrd.img-3.0.0-12-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP Professional on /dev/sdc1
done

Now to re-install grub in the MBR. You will need to know which disk your system boots from, and
find it in the fdisk -l listing you have already done. Then type in sudo grub-install /dev/sd
replacing sd with the disk you will boot from.
me@mycomputer:~$ sudo grub-install /dev/sd

Then type in Crtl-D to exit chroot.

Then type in sudo for i in /sys /proc /dev/pts /dev; do sudo umount
/mnt$i; done - as one line
me@mycomputer:~$ sudo for i in /sys /proc /dev/pts /dev; do sudo umount /mnt$i;
done

If you mounted a separate /boot partition, type in sudo umount /mnt/boot


me@mycomputer:~$ sudo umount /mnt/boot
Then type in sudo umount /mnt
me@mycomputer:~$ ssudo umount /mnt

Then type in sudo reboot to restart he system (remember to remove the LiveCD).
me@mycomputer:~$ sudo reboot

Hopefully, grub will be installed.


Good Luck.

To recover grub:
1. Open the live version.
2. Open the terminal and run sudo fdisk -l to see where Linux is installed.
3. Run sudo mount /dev/sdaX /mnt where x is the number you have found Linux
word in
4. Run sudo grub-install --root-directory=/mnt /dev/sda to install grub.
5. Run sudo update-grub to update grub and if this command didn't work run it after
rebooting.
6. Reboot.

This page documents how to restore or recover the boot-loader (GRUB) after installing Windows.
Some reasons to repair your boot-loader might include installing Microsoft Windows after you have
installed Ubuntu, adding or removing a hard drive, or changing hard drive settings.
Note: this tutorial does not apply if you had installed Ubuntu inside Windows (via the Wubi
installer). In this case, please read this page.

Using the Ubuntu CD (Recommended)


The graphical way
Insert your Ubuntu CD, reboot your computer and set it to boot from CD in the BIOS and
boot into a live session. You can also use a LiveUSB if you have created one in the past.
Install and run Boot-Repair

Click "Recommended Repair".


Now reboot your system. The usual GRUB boot menu should appear. If it does not, hold
Left Shift while booting. You will be able to choose between Ubuntu and Windows.
The terminal way
* Open a terminal. As of Ubuntu 11.10 and 11.04, this can be done by opening the Unity Dash (you
can click the Ubuntu logo in the top panel or use the Windows key on your keyboard) and typing in
"Terminal", and clicking what comes up. On earlier versions, you can achieve this by going to
Applications -> Accessories -> Terminal. Alternately use the Keyboard Shortcut: CTRL + ALT +
T.
For full details on using terminal to fix grub on hard drive from Live Installer DVD or Flash:
https://help.ubuntu.com/community/Grub2/Installing#via_the_LiveCD_terminal

You are then presented with a standard bash prompt, type - this only works to reinstall to
MBR of a working system:
sudo grub-install /dev/XXX

where XXX is the device of your Ubuntu install. (eg: grub-install /dev/sdb). Hint: You can also use
/dev/disk/by-label/ if the partition you installed on has a label. You can determine the /dev node for
such a device by running:
ls -l /dev/disk/by-label/

This will give the output of something like:


lrwxrwxrwx 1 root root 10 Oct 16 10:27 data -> ../../sdb2
lrwxrwxrwx 1 root root 10 Oct 16 10:27 data2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Oct 16 10:27 fat -> ../../sda6
lrwxrwxrwx 1 root root 10 Oct 16 10:27 home -> ../../sda7
lrwxrwxrwx 1 root root 10 Oct 16 10:27 root -> ../../sda1
lrwxrwxrwx 1 root root 10 Oct 16 10:27 swap -> ../../sda5
lrwxrwxrwx 1 root root 10 Oct 16 10:27 windows -> ../../sdb1

You can also use fdisk if you do not see the /dev/disk/by-label:
$ sudo fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes


255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001bc54

Device Boot Start End Blocks Id System


/dev/sda1 * 1 18725 150403072 83 Linux
/dev/sda2 18725 19458 5884929 5 Extended
/dev/sda5 18725 19458 5884928 82 Linux swap / Solaris

From here, find only the drive name, ignore the partition number, that is, for partitions labeled
"root", "data2", "fat", "home" and "swap" it's all still just sda. This is due to the fact that GRUB is
installed in the MBR of the drive, and not on a partition.
Trouble? If other things are messed up, e.g. if you have deleted the partition from where Grub was
previously installed, grub-install may return an error message such as "cannot find a device for /...
(is /dev mounted?)". You may have to do grub-install a bit differently. Refer to the handy guide on
fixing a broken system
Now reboot your system. The usual GRUB boot menu should appear. If it does not, hold Left Shift
while booting. You will be able to choose between Ubuntu and Windows.

Using the Ubuntu Alternate CD


Boot your system from the Ubuntu Alternate CD.
When the Ubuntu splash screen comes up with the boot: prompt, type in rescue and press
enter.

Choose your language, location (country) and then keyboard layout as if you were doing a
fresh install.
Enter a host name, or leave it with the default (Ubuntu).
At this stage you are presented with a screen where you can select which partition is your
root partition (there is a list of the partitions on your hard drive, so you are required to know
which partition number Ubuntu is on). This will be dev/discs/discY/partX, where
the X is a partition number and Y is the number of the drive.

Now proceed as described in "The terminal way" above.

You might also like