Reinstall GRUB after BIOS Update on LUKS encrypted system

Due to reasons unknown I upgraded my Lenovos BIOS via a USB Stick. ๐Ÿ™‚ Everything went well, however after reboot, all my boot options for Linux Mint were gone.
Turns out, somehow my boot setup was erased as well.

Using UEFI without CSM and without secure boot with LUKS encrypted Linux Mint, this was already an issue when first installing. Getting everything right seems to be more of good luck.

This answer ist mainly for straight forward installations of Ubuntu/Mint with LVM on LUKS and unencrypted boot. If you have a different setup, make sure to adapt the different mounts.

Advice on using boot-repair utility: Don’t. The tool messes with a lot of configs unnecessarily. If you are not absolutely sure, what it does, don’t use it.
As an example for myself: When using it to restore Grub, it edited my fstab and uncommented my root mapper and set it to noauto.
Result: You end up after Grub in an initramfs prompt, as the volume has not been unlocked. Possibly wasting time by checking on why LVM times out, cryptsetup not working, etc.

So what is the solution

To get back your boot menu, I tried several things, e.g. boot-repair. However since my system is LUKS encrypted, I guess the tools all had some problems.

To get back my system, I accessed my old system via chroot from a Linux Live CD. In this case Linux Mint Live CD.

1. Boot from Linux Live CD, get keyboard locale and network set up. Unlock your LUKS device. Make sure, that the name in the end (sda3_crypt) is as specified in your original /etc/crypttab (yes, if you do not know, you need to open the crypt device somewhere, take a look, close and reopen it). Otherwise you might get a warning later on.

If you have a different setup, make sure to take the correct device.

cryptsetup luksOpen /dev/sda3 sda3_crypt

For all LUKS informations and commands, take a look here: https://wiki.ubuntuusers.de/LUKS/

2. Mount all necessary partitions out of old system
To find the LUKS drives, use lvscan:

sudo lvscan

For me my /root turns out to be in /dev/mint-vg/root
If you have separated partitions, e.g. for home, or other devices, make sure to adapt parts below for mounting.

sudo mount /dev/mint-vg/root /mnt
sudo mount /dev/sda2 /mnt/boot
for i in /dev /dev/pts /proc /sys /run ; do sudo mount -B $i /mnt$i ; done
sudo mount -o bind /etc/resolv.conf /mnt/etc/resolv.conf
sudo mount /dev/sda1 /mnt/boot/efi/

Make sure you add the /mnt/boot/efi, otherwise grub will complain grub-install: “cannot find EFI directory”. It is not included in your boot partition, but a separate partition.

3. Enter the chroot environment

sudo chroot /mnt /bin/bash

4. Install GRUB

sudo grub-install /dev/sda

Just a reboot and the system should work as before.

Addendum: If you are here because something on boot is not working and you messed things up even further as I did, additionally updating initramfs could help.

update-initramfs -c -k all
Advertisements