0

I have installed Ubuntu 20.04 on LUKS/LVM but unfortunately on booting I am only getting a grub> prompt.

# lsblk
NAME                  MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                     8:0    0 465.8G  0 disk
├─sda1                  8:1    0   731M  0 part  /boot
└─sda5                  8:5    0   465G  0 part     
  └─sda5_crypt        253:0    0   465G  0 crypt  
    ├─ubuntu--vg-home 253:1    0   356G  0 lvm   /home
    └─ubuntu--vg-root 253:2    0   109G  0 lvm   /

Install grub to MBR and generate grub.cfg (see 1, 2)

# grub-install /dev/sda

# grub-mkconfig -o /boot/grub/grub.cfg

Grub.cfg seems to have correct LVM root volume UUID:

# cat /boot/grub/grub.cfg
....
set root='lvmid/MGzfKv-uhLG-wmry-Yqb2-D09r-OfKh-SDs3eb/lZDSre-QLBU-9OvM-aVrN-kR6V-DFXg-lBhRn7'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='lvmid/MGzfKv-uhLG-wmry-Yqb2-D09r-OfKh-SDs3eb/lZDSre-QLBU-9OvM-aVrN-kR6V-DFXg-lBhRn7'  617f84d9-1433-4620-a0c0-833fb8ce1e2f
else
  search --no-floppy --fs-uuid --set=root 617f84d9-1433-4620-a0c0-833fb8ce1e2f
fi
....

# blkid
/dev/sda5: UUID="3fbd1007-9f85-4b85-bdf2-ae55e0244bb6" TYPE="crypto_LUKS" PARTUUID="005a4774-05"
/dev/sda1: UUID="27ca1bd4-7811-4c3a-b319-2b8dd1ce57cd" TYPE="ext4" PARTUUID="005a4774-01"
/dev/mapper/sda5_crypt: UUID="UoR32h-GB2N-GYf4-XBEP-P0rd-RrZ6-f6PK6d" TYPE="LVM2_member"
/dev/mapper/ubuntu--vg-home: UUID="0d81e74f-fe7b-4ef4-ba61-6d664d54d77c" TYPE="ext4"
/dev/mapper/ubuntu--vg-root: UUID="617f84d9-1433-4620-a0c0-833fb8ce1e2f" TYPE="ext4"

# ls -l /dev/disk/by-id
rwxrwxrwx 1 root root 10 Oct 19 21:45 dm-name-sda5_crypt -> ../../dm-0
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-name-ubuntu--vg-home -> ../../dm-1
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-name-ubuntu--vg-root -> ../../dm-2
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-uuid-CRYPT-LUKS2-3fbd10079f854b85bdf2ae55e0244bb6-sda5_crypt -> ../../dm-0
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-uuid-LVM-MGzfKvuhLGwmryYqb2D09rOfKhSDs3ebHvMqdeqlhxMFcNl0XqdTRiC9sdWUmnVU -> ../../dm-1
lrwxrwxrwx 1 root root 10 Oct 19 21:45 dm-uuid-LVM-MGzfKvuhLGwmryYqb2D09rOfKhSDs3eblZDSreQLBU9OvMaVrNkR6VDFXglBhRn7 -> ../../dm-2
lrwxrwxrwx 1 root root 10 Oct 19 21:45 lvm-pv-uuid-UoR32h-GB2N-GYf4-XBEP-P0rd-RrZ6-f6PK6d -> ../../dm-0

Add sda5 UUID & volume UUID to crypttab and fstab (see 1):

# cat /etc/crypttab
sda5_crypt UUID=3fbd1007-9f85-4b85-bdf2-ae55e0244bb6 none luks

# cat /etc/fstab:
UUID=27ca1bd4-7811-4c3a-b319-2b8dd1ce57cd  /boot       ext4    defaults      0       2
UUID=617f84d9-1433-4620-a0c0-833fb8ce1e2f / ext4 defaults,errors=remount-ro 0 1
/swapfile                                 none            swap    sw              0       0

Generate initramfs (see 1):

# update-initramfs -c -k all

# ls -lah /boot
drwxr-xr-x  4 root root 4.0K Oct 19 21:31 grub
-rw-r--r--  1 root root  81M Oct 19 20:55 initrd.img-5.4.0-42-generic
0

Since your LVM is on a LUKS-encrypted partition, the LVM root volume UUID will not be visible until the encryption is unlocked.

By default, Debian/Ubuntu GRUB configuration may refer to several things located on the root filesystem, including:

  • font file /usr/share/grub/unicode.pf2
  • GRUB background image, e.g. /usr/share/desktop-base/futureprototype-them/grub/grub-16x9.png on Debian 10

If you don't want to enter your LUKS passphrase twice (once for GRUB, then again for initramfs), you'll need to make sure these are copied to /boot (or any other unencrypted filesystem GRUB will be able to access) and that GRUB will look for them from there.

For the font file, you can set the GRUB_FONT=/boot/grub/unicode.pf2 in /etc/default/grub and copy the font file to /boot/grub before running grub-mkconfig.

At least on Debian 10, the /etc/grub.d/05_debian_theme script seems to have built-in functionality to copy the background image to e.g. /boot/grub/.background_cache.png if the root filesystem will not be directly readable by GRUB (as in your case, as it will be encrypted). You'll need to verify that this functionality (or its equivalent in a corresponding Ubuntu script) gets properly triggered, and if not, use the GRUB_BACKGROUND=/boot/grub/<filename> in /etc/default/grub to override the background image path and copy the appropriate image file to /boot/grub/ manually.

Note: whenever grub.cfg has a set root=<something> or search ... --set=root command, it is only to specify the filesystem from which any subsequent GRUB commands will load any files. It does not have to refer to the root filesystem of your Ubuntu installation: that will be specified exclusively by the root=... kernel boot option on the linux /boot/vmlinuz-... line.

In your case, unlocking the LUKS encryption and finding the root filesystem within it will be initramfs's job, not GRUB's.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.