Tutorial: repairing or reinstalling GRUB (beginner level)
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:
- Enter live session (in this case, using crunkbong)
- Enter a chroot environment for your system with broken GRUB
- Install grub and restart
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
.
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.
Crunkbong offers a script to ease the pain: chroot-mount. This will open a rudimentary chroot session. Run chroot-mount -h
for more information.
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.
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.
If this tutorial leaves anything out, feel free to let me know.