The Quick Answer:
[Update: you may want to take a look at this first]
For version 1.99 (Ubuntu 11.04):
At a terminal in a LiveCD Desktop.
sudo grub-install --boot-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444/boot /dev/sda
Warning! This will not be the correct information for your PC!
You will need to replace ’0d104aff-ec8c-44c8-b811-92b993823444′ and possibly ‘/dev/sda’ see below for details:
________________________________________
Overwriting the Master Boot Record
Note: The existing MBR will be lost. In order to dual-boot your computer, we will be creating a new Master Boot Record to include all operating systems, including Ubuntu Linux and Microsoft Windows.
1. Download the latest version of Ubuntu Desktop edition from http://www.ubuntu.com/GetUbuntu/download and burn your Ubuntu CD.
2. Reboot your computer and boot into a live session.
________________________________________
Find your Ubuntu boot partition
You need to mount the partition with the ‘/boot’ folder in it.
1. Mount your Ubuntu partition from the Places menu.
Open “Home” and click an unmounted partition from the bar to the left.
2. As an example: I clicked on a 16G partition to mount it, then I went into the boot/grub directory to check for grub.cfg
________________________________________
Note the partition details.
Run this command:
mount | tail -1
You should see output similar to this:
/dev/sda2 on /media/0d104aff-ec8c-44c8-b811-92b993823444 type ext4 (rw,nosuid,nodev,uhelper=devkit)
Note the designation for the disk /dev/sda which you will be using later, and the directory in /media.
Hint: Use Tab Completion in Terminal to complete the path.
This automatically finishes file names, directory locations, and other long or hard to type file names.
________________________________________
Verify that your partition is the Ubuntu boot partition.
Run this command:
ls /media/0d104aff-ec8c-44c8-b811-92b993823444/boot
or
ls /media/0d104aff-ec8c-44c8-b811-92b993823444
But substitute the example’s UUID, 0d104aff-ec8c-44c8-b811-92b993823444, with your volume’s UUID which you found earlier.
In either case, the output should be something like this:
abi-2.6.38-8-generic memtest86+_multiboot.bin
config-2.6.38-8-generic System.map-2.6.38-8-generic
grub vmcoreinfo-2.6.38-8-generic
initrd.img-2.6.38-8-generic vmlinuz-2.6.38-8-generic
memtest86+.bin
If what you have is not similar, unmount it and try another partition.
________________________________________
Reinstall GRUB
Now that everything is mounted, we just need to reinstall GRUB by specifying the correct directory and the correct drive name:
For version 1.99 (Ubuntu 11.04):
sudo grub-install --boot-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444/boot /dev/sda
If you get BIOS warnings try:
sudo grub-install --boot-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444/boot /dev/sda --recheck
Warning:
Substitute /dev/sda with the location you want to install GRUB on.
Substitute the example’s UUID, 0d104aff-ec8c-44c8-b811-92b993823444, with your volume’s UUID which you found earlier
If all went well, you should see something like this:
“Installation finished. No error reported”
________________________________________
Reboot and Test
Reboot, making sure to boot to your hard drive and not to the live CD.
Grub should be installed and both Ubuntu and Windows should have been automatically detected and listed in the menu.
The Master Boot Record will execute Grub as the initial boot-loader.
The Windows boot-loader is contained within the Windows partition and will then be chain-loaded by the Grub boot-loader.
If your GRUB Boot Menu is out of date, run this command:
sudo update-grub
________________________________________
Notes:
Prior to version 1.99:
sudo grub-install --root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444 /dev/sda
If you get BIOS warnings try:
sudo grub-install --root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444 /dev/sda --recheck
Warning:
Substitute /dev/sda with the location you want to install GRUB on.
Substitute the example’s UUID, 0d104aff-ec8c-44c8-b811-92b993823444, with your volume’s UUID which you found earlier
________________________________________
Based on RecoveringUbuntuAfterInstallingWindows.
Filed under: Feature Tagged: 11.04, boot, boot-loader, commands, grub, grub2, live CD, master boot record, mbr, mount, natty, partition, update-grub, windows Image may be NSFW.
Clik here to view.
Clik here to view.
