Canada  united states of america usa  linkedinfacebook   Call Us Today: 866.646.6461

Restore grub2 in Linux (Ubuntu)

If for some reason your grub has gotten corrupted, here are the steps to restore it.

Boot into a rescue CD (either Ubuntu or System Rescue CD, which you can download freely).

Mount the drive, where sdXY is the partition (eg: /dev/sda1)

sudo mount /dev/sdXY /mnt

Map all of system partitions (/dev, sys and proc):

sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys

Then "chroot" to the new directory:

sudo chroot /mnt

Note: if you are using System Rescue CD, you may get this error:
chroot: failed to run command `/bin/zsh` : No such file or directory

In that case you have to specify the shell:

chroot /mnt /bin/bash

Once chrooted, run the following to install grub (where sdX is your drive where grub will be installed. You have to use the drive, not a partition. ie: /dev/sda, not /dev/sda1)

grub-install /dev/sdX

Finally, unmount everything:

sudo umount /mnt/sys
sudo umount /mnt/proc
sudo umount /mnt/dev
sudo umount /mnt

and reboot.

 ALT is a specialized IT consulting and IT support company. If you need Linux-related support, feel free to contact us and one of our consultants will be happy to help.

Last updated Jan 2, 2019