Installer failed to write grub to EFI, installing to root on logical volume inside LUKS wrapper, then later crashed

Bug #1889107 reported by Jonathan Watt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub-installer (Ubuntu)
New
Undecided
Unassigned

Bug Description

I tried to install 20.04, creating the following custom partition layout:

nvme0n1 259:0 0 1.9T 0 disk
├─nvme0n1p1 259:3 0 512M 0 part /target/boot/efi
└─nvme0n1p2 259:4 0 1.9T 0 part
  └─cryptdata 253:0 0 1.9T 0 crypt
    ├─vg0-root 253:1 0 1.5T 0 lvm /target
    └─vg0-vms 253:2 0 371.2G 0 lvm

Everything proceeded fine until I got a popup window with the message:

  Executing 'grub-install /dev/nvme0n1' failed.
  This is a fatal error.

In the details part of the main installer window was:

  ubuntu grub-installer: grub-install: error: attempting to install to encrypted disk without cryptodisk enabled. Set 'GRUB_ENABLE_CRYPTODISK=y' in file /etc/default/grub

The default install allows the disk to be encrypted with the default partition layout, so presumably it knows how to set up grub to work with encrypted root, and it could be made to be a bit smarter about detecting when a custom partition layout includes encryption and set up grub appropriately?

In the meantime, if anyone has any tips on how to get the install to succeed I'd be very grateful to hear them. :)

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: ubiquity 20.04.15
ProcVersionSignature: Ubuntu 5.4.0-26.30-generic 5.4.30
Uname: Linux 5.4.0-26-generic x86_64
NonfreeKernelModules: zfs zunicode zavl icp zcommon znvpair
ApportVersion: 2.20.11-0ubuntu27
Architecture: amd64
CasperMD5CheckResult: pass
CasperVersion: 1.445
Date: Mon Jul 27 17:19:19 2020
InstallCmdLine: BOOT_IMAGE=/casper/vmlinuz file=/cdrom/preseed/ubuntu.seed maybe-ubiquity quiet splash ---
LiveMediaBuild: Ubuntu 20.04 LTS "Focal Fossa" - Release amd64 (20200421)
SourcePackage: grub-installer
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Jonathan Watt (jwatt) wrote :
Revision history for this message
Jonathan Watt (jwatt) wrote :

Running the following in Terminal early on during the installation gets rid of the 'grub-install' error and subsequent Ubuntu installer crash:

  sudo sh -c "echo GRUB_ENABLE_CRYPTODISK=y>> /target/etc/default/grub"

On booting up the installed system the prompt to enter the password for the encrypted LUKS partition is presented, and the partition is decrypted successfully.

However, grub almost immediately fails to boot and I end up at a 'grub>' prompt.

Revision history for this message
Jonathan Watt (jwatt) wrote :

The following shows that the contents of /efi/ubuntu/grub.cfg are broken, and shows my attempt to rerun the contents of that file with corrected values to try to boot. This gets me to a boot menu where I can choose Ubuntu, get the spinning throbber indicating that Ubuntu is loading, but then I get dumped into an '(initramfs)' prompt.

grub> ls
(crypto0) (proc) (lvm/vg-root) (hd0) (hd0,gpt2) (hd0,gpt1)

# Examine first partitions contents:
grub> ls (hd0,gpt1)
        Partition hd0,gpt1: Filesystem type fat, <...>
grub> ls (hd0,gpt1)/
efi/
grub> ls (hd0,gpt1)/efi/
ubuntu/ boot/
grub> ls (hd0,gpt1)/efi/boot/
bootx64.efi fbx64.efi mmx64.efi
grub> ls (hd0,gpt1)/efi/ubuntu/
grubx64.efi shimx64.efi mmx64.efi bootx64.csv grub.cfg

# Examine /efi/ubuntu/grub.cfg
grub> cat (hd0,gpt1)/efi/ubuntu/grub.cfg
cryptomount -u <a-UUID>
search.fs_uuid <another-UUID> root lvmid/<long-identifier>/<another-identifier>
set prefix=($root)'/@/boot/grub'
configfile $prefix/grub.cfg

# Examine second partition's contents:
grub> ls (lvm/vg-root)
Device lvm/vg-root: Filesystem type btrfs, UUID <a-UUID> - ...
grub> ls (lvm/vg-root)/
@/ @home/
grub> ls (lvm/vg-root)/@
dev/ run/ lib32 boot/ lib sbin cdrom/ srv/ media/ usr/ opt/ lib64 swapfile bin home/ etc/ swap/ var/ tmp/ libx32 sys/ mnt/ proc/ root/

# Fix $root
# Note: I include parenthesis and append '/@' (since it's BTRFS) - is that okay?
grub> echo $root
hd0,gpt1
grub> set root=(lvm/vg-root)/@

# Fix $prefix
# Note: Given the changes to $root, I don't include parenthesis or "/@" here.
grub> echo $prefix
(hd0,gpt1)/@/boot/grub
grub> ls $prefix
error: file '/@/boot/grub' not found.
set prefix=$root'/boot/grub'

# Now try to boot:
configfile $prefix/grub.cfg

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.