GRUB2 Rescue

by
Share this Article: Facebook0Google+0Twitter9LinkedIn0Reddit0StumbleUpon0

We all have been to a place in our lives where our machine fails to boot with the infamous “GRUB Rescue” command-prompt. This short document explains how to re-install GRUB2 and generate grub.cfg (menu entries).

Requirements:

  1. Machine on which the boot-loader is to be installed
  2. Linux Live USB/CD/DVD. Any disk capable of a chroot environment will do

Process:

  1. Open up a terminal if you’re using a live session
  2. Execute lsblk and check what node corresponds to the root partition of your distribution (I’ll be using /dev/sda1 as an example)
  3. sudo bash (get a root bash for all the succeeding commands)
  4. mount /dev/sda1 /mnt (mount root partition on /mnt)
  5. mount -t proc none /mnt/proc (mount proc)
  6. mount –rbind /dev /mnt/dev (mount dev)
  7. mount –rbind /sys /mnt/sys (mount sys)
  8. chroot /mnt /bin/bash (changing root to /mnt and bash is shell).
  9. Make sure GRUB2 is already installed. If not, install it from the package manager. The package may have different names, depending on your distribution. In Arch Linux, it is called grub-bios. In Gentoo, it has to be unmasked before proceeding with the installation
  10. grub-install /dev/sda (install GRUB to MBR)
  11. grub-mkconfig -o /boot/grub/grub.cfg (generate grub.cfg)
  12. exit (exit the fake root environment)
  13. Unmount all the partitions – umount -l /mnt/dev{/shm,/pts,} && umount -l /mnt/gentoo{/boot,/proc,}
  14. cd (change directory to default)
  15. reboot

 

Well, that’s pretty much it, but here are a few extra pointers:

  1. A good source of info on GRUB2 can be found here: https://help.ubuntu.com/community/Grub2/Installing Though it is Ubuntu specific in a way, it may help you resolve some of your problems.
  2. Another excellent source is the Arch wiki: https://wiki.archlinux.org/index.php/GRUB
  3. Instead of mounting all the temporary file systems (like proc, sys and dev) before chrooting, you can use the arch-chroot script instead. It is part of the arch-install-scripts package.
  4. If GRUB does not have entries for Windows OS (in case you’re dual booting), make sure you have os-prober installed.
  5. If your boot resides on a separate partition, you’ll need to mount it too. (mount /boot /<mount-point>/boot).

For questions please refer to our Q/A forum at : http://ask.unixmen.com/


Share this Article: Facebook0Google+0Twitter9LinkedIn0Reddit0StumbleUpon0