This post will be helpful to people with dual booted laptops with Ubuntu and Windows. If by any chance your Windows crashes or has some serious problem with it, then you have no option other than formatting Windows ,but the problem occurs when you have dual booted PC with Ubuntu and Windows and you format your Windows and re-install it. Or there may be another possibility : You have Ubuntu installed and then you install Windows.
Ubuntu uses GRUB (GRand Unified Boot-loader) which can be used by both Ubuntu and Windows for booting. But Windows uses NTLDR (NT Loader) which does not support any other operating system. So for dual booted PCs, we require GRUB as its boot-loader. When you re-install Windows or install Windows over Ubuntu, GRUB is replaced by NTLDR so you can’t see Ubuntu in your grub menu, hence you need to re-install Ubuntu’s boot-loader i.e. GRUB. Following is step-wise CHROOT method to re-install GRUB 2 for Ubuntu 9.10 onwards :
This method of installation uses the chroot command to gain access to the broken system’s files. Once the chroot command is issued, the LiveCD treats the broken system’s / as its own. Commands run in a chroot environment will affect the broken systems filesystems and not those of the LiveCD.
1. Boot to the LiveCD Desktop (Ubuntu 9.10 or later).
Open a terminal – Applications, Accessories, Terminal.
3. Determine your normal system partition – (the switch is a lowercase “L”)
sudo fdisk -l
* If you aren’t sure, run
df -Th. Look for the correct disk size and ext3 or ext4 format.
4. Mount your normal system partition:
* Substitute the correct partition: sda1, sdb5, etc.
sudo mount /dev/sdXX /mnt # Example: sudo mount /dev/sda1 /mnt
Only if you have a separate boot partition:
* sdYY is the /boot partition designation (for example sdb3)
sudo mount /dev/sdYY /mnt/boot
6. Mount the critical virtual filesystems:
sudo mount –bind /dev /mnt/dev
sudo mount –bind /proc /mnt/proc
sudo mount –bind /sys /mnt/sys
7. To ensure that only the grub utilities from the LiveCD get executed, mount /usr
sudo mount –bind /usr/ /mnt/usr
8. Chroot into your normal system device:
sudo chroot /mnt
9. If there is no /boot/grub/grub.cfg or it’s not correct, create one using
10. Reinstall GRUB 2:
Substitute the correct device – sda, sdb, etc. Do not specify a partition number.
Verify the install (use the correct device, for example sda. Do not specify a partition): sudo grub-install –recheck /dev/sdX
Exit chroot: CTRL-D on keyboard
13. Unmount virtual filesystems:
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
* If you mounted a separate /boot partition:
sudo umount /mnt/boot
14. Unmount the LiveCD’s /usr directory:
sudo umount /mnt/usr
15. Unmount last device:
sudo umount /mnt