citizen428.blog()

Try to learn something about everything

Fixing Grub on a LUKS-encrypted Disk

When I rebooted my new work notebook (a very nice x201s, with a dual-core i7, 8GB RAM and an SSD by the way), it seemed that for whatever reason there was no Grub installed. Strange, but not the only problem I had with the alternate Ubuntu installer that I used for setting up LUKS-encrypted root and swap partitions. Since this turned out to be more involved than I originally thought, I decided to document what I did to maybe save others the trouble. BTW: You’ll need a Linux Live-CD for this, I recommend the excellent Debian-based Grml.

First we need to open the LUKS partition, which can be done with cryptsetup.

Step 1: Unlock LUKS
1
2
$ cryptsetup luksOpen /dev/<device> <name>
# you'll be asked for your password

With that out of the way, you’ll have to mount your LVM volumes. This took me a bit because my VG wasn’t active, but thanks to an excellent blog post I found (see sources) this problem was solved quickly.

Step 2: Mounting LVM
1
2
3
4
5
6
7
8
# do a lvm disk scan
$ lvmdiskscan
# activate the volume group
$ vgchange -ay
# make sure the VG is active now
$ lvscan
# mount the actual volume
$ mount /dev/<volume_group_name>/<volume> /mnt/external

I then needed to mount the unencrypted /boot partition as well as some special filesystems (with bind mounts) at the appropriate mount points.

Step 3: Preparing for the chroot
1
2
3
4
5
6
# mount the boot partion
$ mount /dev/<device> /mnt/external/boot
# bind mount some things we need in the chroot env
$ mount --bind /dev /mnt/external/dev
$ mount --bind /proc /mnt/external/proc
$ mount --bind /sys /mnt/external/sys

With everything set up, all that’s left to do is chrooting into the system and fixing Grub.

Step 4: chrooting and fixing Grub
1
2
$ chroot /mnt/external
chroot$  grub-setup # grub-install, whatever you need

Sources:

Comments