Recovering MBR after reinstalling Windows over biOS Ubuntu/Windows
This applies to the situation that when Windows and Ubuntu coexist on a computer and we reinstall Windows for some reasons, the Grub loader is lost. However, Ubuntu is still there. Do the following to recover.
- Restart with Ubuntu LiveCD.
sudo grub- Use
find /boot/grub/stage1to find where the Grub is installed. For example(hd0,6). root (hd0,6)setup (hd0)quit- Restart the computer, and it’s done!
Update: with the introduction of Grub 2, the above method is not working. See here for a solution, adapted for my case below.
- Use
gpartedto figure out where the system has been installed. For my case,/is at/dev/sda11, and/homeis at/dev/sda9. - Mount the root directory.
mount /dev/sda11 /mnt - Install the Grub 2 loader.
grub-install --root-directory=/mnt/ /dev/sda - Restart the system and the Grub 2 loader is shown.
- Use the following to boot the system.
grub> find /boot/grub/core.img grub> root (hdx,y) (previous command will output the x,y) grub> kernel /boot/grub/core.img grub> boot - After the system is booted, install the bootloader.
sudo grub-install /dev/sda