You are not logged in.

#1 2020-06-27 14:29:37

Schmoho
Member
Registered: 2020-05-06
Posts: 8

reusing existing GRUB Legacy boot install with new LUKS partition

I have finally shreddered my Windows 7 to make way for an Arch Install.
I've somewhat successfully experimented with a LVM on LUKS setup on a UEFI bootable USB drive, using syslinux. Now I wanted to apply what I've learned to my HDD and sure enough I failed.
Currently I'm using an Ubuntu that was dual booting with the Windows 7 and I'd like to preserve as much as possible of my setup for now.
So I did not install grub again but just ran update-grub, after setting up the new install.

However, my boot process is somewhat confused. I'm usually booting Ubuntu 18.04 with grub2, which Legacy boots from a 100MB NTFS/exFAT partition that was originally set up by Windows, when I got/remember that right.

Now, I've set up a partition on my HDD, put a LUKS 1 container in there

# cryptsetup --type luks1 luksFormat $BACKING_DEVICE

and set up LVM2 on it with a logical root partition.
After that I've run update-grub with the LUKS Container open.
That created the following /boot/grub/grub.cfg entry under os_prober entries.

menuentry 'Arch Linux (on /dev/mapper/$VOLUME_GROUP-root)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-$LOGICAL_ROOT_UUID' {
	insmod part_msdos
	insmod cryptodisk
	insmod luks
	insmod gcry_rijndael
	insmod gcry_rijndael
	insmod gcry_sha256
	insmod lvm
	insmod ext2
	cryptomount -u $BACKING_DEVICE_UUID
	set root='lvmid/$VG_UUID/$LV_ROOT_UUID'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint='lvmid/$VG_UUID/$LV_ROOT_UUID'  $LOGICAL_ROOT_UUID
	else
	  search --no-floppy --fs-uuid --set=root $LOGICAL_ROOT_UUID
	fi
	linux /boot/vmlinuz-linux root=/dev/dm-1
	initrd /boot/initramfs-linux.img
}

When I try to boot that entry, I get asked to enter a password for the decryption of the master-key

Attempting to decrypt master key...
Enter passphrase for hd0,msdos2 ($BACKING_DEVICE_UUID):

and then the boot fails after

:: running hook [encrypt]
Waiting 10 seconds for device /dev/dm-1 ...
Waiting 10 seconds for device /dev/dm-1 ...
ERROR: device '/dev-dm1' not found. Skipping fsck.
:: mounting '/dev/dm-1' on real root
mount: /new_root: special device /dev/dm-1 does not exist.
You are now being dropped into an emergency shell.

In the emergency shell I could see that the crypto container was indeed not opened, but I could open it with

# cryptsetup open $BACKING_DEVICE $CRYPTO_CONTAINER_NAME

and chroot into logical root just fine.

Some more context:

# ls /dev/mapper
$VG-root -> ../dm-1
$CRYPTO_CONTAINER_NAME -> ../dm-0

My fstab has the UUID of the logical root for /.

This is from my mkinitcpio.conf:

MODULES=(ext4)
HOOKS=(base udev autodetect modconf block encrypt lvm2 filesystems keyboard fsck)

in my /etc/default/grub I have

GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="cryptdevice=UUID=$BACKING_DEVICE_UUID:$CRYPTO_CONTAINER_NAME"
GRUB_ENABLE_CRYPTODISK=y
GRUB_PRELOAD_MODULES="lvm"

Interestingly, the kernel params are appended to the commands of all the Ubuntu entries, but not to the Arch one. Maybe it's just a problem with os_prober?

Any hints on what I'm trying to accomplish here, or some hints on how to debug this, would be much appreciated.

I'm rather uncertain about the

linux /boot/vmlinuz-linux root=/dev/dm-1
initrd /boot/initramfs-linux.img

bits of the grub entry, since the folders this refers to should actually be encrypted too, as I don't have a boot partition for this install. However the cryptomount seems to run beforehand and I thought that might suffice.
If it doesn't, how can I pull this off, given that I don't have a boot partition on the system anyhow? (grub, ubuntu kernel and initrd are all in one large partition for ubuntu ... kinda screwed this up back when I "set this up")

Last edited by Schmoho (2020-06-27 16:11:12)

Offline

#2 2020-06-27 16:23:06

Schmoho
Member
Registered: 2020-05-06
Posts: 8

Re: reusing existing GRUB Legacy boot install with new LUKS partition

Well ... I just manually appended the cryptdevice kernel param to the Arch entry in the grub.cfg and replaced root=/dev/dm-1 with root=/dev/$VG/root and now the boot seems to work.

So the problem at least seems somewhat tangled with the usage of os-prober/update-grub. Since the grub.cfg ought to be auto-generated and all, I wonder how I could fix this up properly.

Offline

Board footer

Powered by FluxBB