Fixing Grub

Often there is need to repair the GRUB ( GRand Unified Boot ) loader after various operations in linux installations, particularly after installing windows for dual boot or re sizing the root partition of linux. For fixing grub, you need to have a bootable live cd or usb installation of your linux distro or (preferably) gparted.

Then, to repair the GRUB follow these steps

1) Boot from the live media.

2) Determine the partition that contains your file system ( linux installation files ). Most probably this will be an ext partition like ext-3, ext-4 etc.

3) Create a directory to act as a mount point by typing


4) Mount the root partition in this directory

# mount /dev/sda5 /tmp/mydir

5) Begin preparations to change root environment

# mount --bind /dev /tmp/mydir/dev
# mount --bind /proc /tmp/mydir/proc
# mount --bind /sys /tmp/mydir/sys

6) Now, change the root environment

# chroot /tmp/mydir

7) Now we need to install GRUB on the boot device. Please note that in this step we will use device nameĀ and not the partition name e.d we will use like /dev/sda not /dev/sda1. To install GRUB in debian based distros, type

# grub-install /dev/sda

For Cent OS, fedora and other rpm based distros type

# grub-2 install /dev/sda

8) Reboot.

This should fix your problem.