Skip to content

Tutorial: repairing or reinstalling GRUB (beginner level)

souperdoupe edited this page May 4, 2018 · 1 revision

The following tutorial explains how to restore GRUB through a live install. (This is one of those annoying cases that led to me creating crunkbong in the first place.) These procedures can be replicated on any Linux live environment.

Usually, this procedure is necessary if you have an existing Linux install, and install another operating system alongside it, thinking it will dual-boot. Instead, you reboot, and discover that GRUB has been wiped-out completely. Windows usually replaces the bootloader. Others will leave it blank, and you will boot to a grub recovery console. Neither of these are helpful. Fear not: it's simple to repair.

The procedure can be summarized as follows:

  1. Enter live session (in this case, using crunkbong)
  2. Enter a chroot environment for your system with broken GRUB
  3. Install grub and restart

Enter the live install

Create a live USB drive using whatever method you have. The "crunkbong way" uses dd:

dd if=/path/to/crunkbong.iso of=/dev/sdx

Where sdx is your USB device (example: sdb). You can find it with fdisk -l.

Notes for beginners

When you reboot, you should be able to enter your live USB. Many computers are assigned a button (like F9-12) that will generate a menu of bootable media. You may have to configure BIOS to boot from removable/flash storage. Please perform this research on your own.

Open a chroot session

chroot-mount

Crunkbong offers a script to ease the pain: chroot-mount. This will open a rudimentary chroot session. Run chroot-mount -h for more information.

manual chroot

You will need to mount the environment that you wish to repair, device sdyz (example: sda1).

mount -o rw /dev/sdyz /mnt

Establish a procfs:

mount -t proc proc /proc

And bind-mount some other partitions:

mount -o bind /dev /mnt/dev mount -o bind /sys /mnt/sys

And enter the chroot:

chroot /mnt /bin/sh Where /bin/sh is your preferred shell.

Repair GRUB

In your new chroot session, run the following command:

grub-install /dev/sdy

Where sdy is the device which contains your filesystem (eg, /dev/sda)

It should also run update-grub. If for some reason it doesn't, then run it.

In most cases, this will repair grub. You can exit the chroot, unmount your devices, and reboot to your system.

Debugging

If this tutorial leaves anything out, feel free to let me know.