Friday 27 February 2015

A bit of unplanned Grub2 surgery

PROBLEM: Late night experiments loading GRUB on USB sticks resulted in mucking up Grub on my primary machine. After a reboot instead of a boot menu I was greeted with:

grub >

Whoops.

Ubuntubook is running Ubuntu 14.04 LTS with a boot partition on sda1, LUKS-encrypted root on sda3, and the 3.19.0 Linux kernel. Since the boot loader hadn't fallen into rescue mode there was hope that the essential stuff was in place but for some reason the config was not being read. A quick ls in the Grub shell confirmed that /boot/grub/grub.cfg, kernels, initrd files were present.

FIX: After a few tries I found the right parameters for a manual boot... specifically root=/dev/mapper/sda3_crypt NOT root=/dev/sda3:

grub> linux (hd0,1)/vmlinuz-3.19.0-031900-generic root=/dev/mapper/sda3_crypt ro
grub> initrd (hd0,1)/initrd.img-3.19.0-031900-generic
grub> boot

Boot process begins, pauses for the LUKS passphrase prompt to unlock root, and makes it to the login screen. Good stuff.

Examine /etc/default/grub and everything looks OK. Update and reinstall grub to the MBR:

$ sudo update-grub
$ sudo grub-install /dev/sda

Reboot and back in business!

Source: Grub 2 Troubleshooting - Post Boot Follow Up