Grub Repair in Dual Boot (Windows/Linux) Systems | Nagarams Blog

Tuesday, 15 July 2014

Grub Repair in Dual Boot (Windows/Linux) Systems

Rate this Post:



What will happen, when you are using the Dual boot in your PC as windows and Linux are side by side on single HDD and you have formatted your Windows OS and installed once again? 
Yes…you are right. If you format your PC you will surely face the problem. That is you will lose your Linux boot option (GRUB) in the boot menu.
So, you cannot load or choose the Linux, even the entire Linux partition is existed on the same HDD.
The reason for this is, the MBR (Main Boot Record) in dual boot PC which stores the GRUB will be erased and stored with windows boot (DOS boot) during installation of windows. Hence, it is showing the windows while booting. Now you have to recover the GRUB (which shows Linux option too) after re-installation of Windows by installing it on MBR of your HDD.
Here you can go through the steps to resolve the problem and to restore the GRUB at MBR, so that you can get the GRUB back and can choose the OS that you wish (Windows/Linux) at boot.
Note: In my case I had the problem with XP/Ubuntu, so I am using the Ubuntu live cd.
  • Get the Ubuntu Live cd / Bootable USB with Ubuntu live. 
  •  Boot your PC with Ubuntu live CD / USB and it will lead you to the Ubuntu live desktop. 
  •  Now open the Terminal ( press Alt+Ctrl+T or Applications > Accessories > Terminal) )
  • In the terminal type the following commands
o    To check the Linux installed partition type the following command
sudo fdisk  -l
the result is like below
after finding the appropriate partition on which LINUX was installed (like sda2 or sda3 or sda4 or sdb3 etc.),  remember that. You can also use the Gparted GUI application to find the Linux partition. GParted – available through System > Administration > GParted on the Ubuntu Live CD.
o    Now type the following

sudo mount /dev/sda2 /mnt      
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
Note: in my case my Linux OS was installed on sda2 so change the sda2 in the above command according to your's.                           
o    Now chroot the /mnt  directory by typing the following command

                         sudo chroot /mnt

o    After chroot the /mnt folder install the GRUB by typing the following commands (type below commands as it is)

grub-install /dev/sda
grub-install  --recheck /dev/sda 

                         if it ask you for   force option then give 

                                    grub-install --recheck  sda --force

o    If everything went right without any errors , then update the GRUB by typing 

                                    update-grub

o    After GRUB update exit from the chroot by typing the command
exit
o    Now unmount all the directories those are previously mounted
sudo umount /mnt/dev
                                           sudo umount /mnt/proc
sudo umount /mnt
Now reboot the PC from HDD (Remove CD/USB). If you find the both Windows option and Linux then no problem, otherwise lo-gin to the Linux and type the following command in terminal.
                                    sudo update-grub
Now it will adds the windows boot menu option.

That’s it, from the next boot onwards you can choose your choice of OS.

Thank You

Please Leave a Comment

1 comment :

Unknown said...

very good tips. thank you

Post a Comment