How to repair the Grub in Linux

Try Fast Read
1
0



Many of us dual boot windows and linux. We all know we are always in need to reinstall windows and it overwrites the Linux MBR on the device. Now you can’t boot into linux as it doesn’t show up in windo a booting device (cd or usb) of Your Linux installation.
Then Boot from it and Run Live system
Now fire up terminal and get ready to hit these commands

First create a directory root directory
mkdir /mnt/root

mount /dev/xxx? /mnt/root
where xxx is your linux partition
you can view it by the following command
fdisk -l
You can check out the following config
Device Boot Start End Blocks Id System
/dev/sd1 2048 206847 102400 7 Linux
then xxx=sda1
Then you have to mount the proc subsystem and udev inside /mnt/root also:
sudo mount -t proc none /mnt/root/proc
sudo mount -o bind /dev /mnt/root/dev
Run chroot to change apparent root directory for the current running process and its children.
chroot /mnt/root /bin/bash
Now you are under the linux in your system, Then Simply run the grub-install command and reboot to get your grub back 🙂 again xxx is your linux partition sda1 in the example
for grub(ubuntu)
grub-install /dev/xxx
or
grub-install /dev/sda –root-directory=/mnt
for grub2(fedora)
grub2-install /dev/sda

(use –force, if some error comes up)
you can now run mkconfig command to update ur grub
for grub(ubuntu)
grub-imkconfig
for grub2(fedora)
grub2-mkconfig

Hope this helps

Post navigation