How to restore the Ubuntu/XP/Vista/7 bootloader (Updated for Ubuntu 11.10)
This How-to is for windows dual booters who reinstall an operating system only to find that it has taken away access to their other operating system.
All three parts of this tutorial require that you boot from a cd. If you don't know how to do this, check here.
If you have made a mistake and want to revert the changes, simply follow the instructions for reinstalling the previous bootloader. For example, if you have installed vista over ubuntu, try to get the ubuntu bootloader back, but want to get the vista bootloader back, simply follow my instructions for installing the vista bootloader.
How to restore the Ubuntu grub bootloader (9.10 and beyond)
First you need to find out what your drives are called. You can do this by going to a terminal and typing:
sudo fdisk -l
So, still in the terminal, type:
sudo mkdir /media/sda5 sudo mount /dev/sda5 /media/sda5
sudo grub-install --root-directory=/media/sda5 /dev/sda
How to restore the Ubuntu grub bootloader (9.04 and older)
First of all, all credit for this part of the tutorial goes to catlet. I am simply rewriting his tutorial to have all three bootloaders in this tutorial.
So, lets begin. To restore the grub, you must boot off the ubuntu live cd. Any ubuntu live cd will do.
Once there, open a terminal (Applications>Accessories>Terminal) and type this:
Now you need to tell Grub where it is installed. Using the output of the last command, change this one and run it:
Ok, so thats the configuration over and done with. Now we just need to run one command to install the Grub to your hard drive:
Now to quit and check if it has worked:
Make sure you have taken the live cd out of your disc tray. All going well, you should start back up and see the grub once again.
How to restore the Windows XP bootloader
For this you will need your Windows XP installation CD. Boot into it now.
You will get to a part where it asks if you want to repair or recover. To do so, press "r".
If prompted, enter your Windows XP administrator password. This will leave you at at a command line, so type in the following two commands:
How to restore the Windows Vista or 7 bootloader
To restore the Windows Vista/7 bootloader, you must first boot off your Windows Vista/7 installation DVD.
If you have one of the many OEM computers that didnt come with a Vista/7 installation disk, you can get the same effect with a Vista recovery disk, which you can download for Vista or Win 7.
When you get to the Regional settings, select your Location/Keyboard setting then click next. On the next page you must click on "Repair your computer."
On the next page, if it finds your Windows Vista/7 installation, make sure it is UNSELECTED before clicking next.
Then click on "Command prompt". From there, type in the folowing:
Take out your Vista/7 DVD and hopefully, you will be left with your Windows Vista/7 Bootloader.
(with my additions and corrections --cebaehren)
If you cannot boot from GRUB 2 and need to reinstall it, here is the simple method. For more details or for advanced options, refer to the Ubuntu community documentation here:
Grub2 – Reinstalling GRUB 2:
- Boot the 9.10 Karmic LiveCD to the Desktop.
- Open a terminal – Applications, Accessories, Terminal.
If you have an fakeraid try first
sudo modprobe -q dm-mod
sudo modprobe -q dm-mirror
sudo /sbin/dmraid -ay
Note that in an diskmapperRAID (not multiplediskRAID!) the RAID device (two or more hard disks in array) is found as a nvidia device with long stupid name (nvidia_edabbdgc, with first partition as nvidia_edabbdgc1 and counting
Use /dev/dm-0 for the array of disks and dm-1 for the first partition and so counting for the following parttitions
that is fdisk /dev/dm-0 or /dev/dm-
- Determine your normal system partition – `sudo fdisk -l` (That is a lowercase L)
- If you aren’t sure, run `df -Th`. Look for the correct disk size and ext3 or ext4 format.
- Mount your normal system partition:
sudo mount /dev/sdXY /mnt
- Example: sudo mount /dev/sda1 /mnt
- Note: The partition to mount is normally the partition on which
Ubuntu was installed: sda1, sdb5, etc.
If you have a separate /boot partition, use the device on which the /boot partition is located. Grub 2 works best when installed in the MBR of the drive to which BIOS boots. Also remember that you mount the partition (including the number) in this step, but you do not include the partition number when you run the “sudo grub-install” command later.
- cebaehren note: the kernel or Linux command consider the X as a letter of alphabet for the (considered as) scsi device (sda, sdb, sdc). The partitions starting with 1 (sda1, ... sdb3, sde5, etc)
- Note: GRUB 2 counts the first drive (not this case in X) as “0″, but the first partition (Y) as “1″
- Only if you have a separate boot partition:
sudo mount /dev/sdXY /mnt/boot
- Reinstall GRUB 2:
sudo grub-install --root-directory=/mnt /dev/sdX
- Example: sudo grub-install –root-directory=/mnt /dev/sda
- Note: Substitute the device on which Ubuntu was installed – sda, sdb, etc. Do not specify a partition number.
- Unmount the partition:
sudo umount /mnt