You are not logged in.

#1 2016-08-28 14:27:52

dartos
Member
Registered: 2016-08-28
Posts: 4

LVM on LUKS with GRUB fails to boot - unable to find root device

I have a drive with LVM on LUKS following Pavel Kogan's instructions, including the bonus at the end of the instructions with GRUB handing over the decrypted drive to the kernel, avoiding having to decrypt to drive twice. This has been working fine for many months.

I put the drive into a new system and tried to boot from it. After decrypting the drive, I received errors (will post more details at a later time) indicating the root drive could not be found.

To try to reproduce the problem, I downloaded Arch (2016.08.01), did a fresh install on a spare drive again following the Kogan's guide, and I experienced the same issues on my new system.

I ended up solving it by:
1) using '/dev/disk/by-uuid' in my '/etc/default/grub' file instead of '/dev/disk/sda1', and
2) manually editing the /boot/grub/grub.cfg file as the root device mapper parameter was incorrect. The 'root=UUID=<UUID>' parameter was correct, which is odd (by <UUID> I mean my actual UUID, not shown). See the snippet below.

I replaced each instance of 'root=/dev/...' in '/boot/grub/grub.cfg' with the correct device mapper name (using 'lsblk' or 'blkid'):

		...
		linux	/boot/vmlinuz-linux root=UUID=<UUID> rw cryptdevice=/dev/disk/by-uuid/<UUID>:lvm root=/dev/mapper/vg-root quiet
		...

I looked at dm-crypt/Encrypting an entire system and dm-crypt/System configuration and noticed there was a root device parameter. However, there was a tip stating this was unnecessary:

Tip: This parameter is not needed to be specified manually when using GRUB. Executing grub-mkconfig is meant to determine the correct UUID of the decrypted root filesystem and specify it in the generated grub.cfg automatically.

Still, I tried specifying the root device mapper parameter in grub anyways, but then grub-mkconfig failed and my grub.cfg file did not appear to be updated as it still had the incorrect root device mapper parameter. It's possible the root device parameter in '/etc/default/grub' is unnecessary and causes grub-mkconfig to fail.

I will be doing one more test run on a different spare drive, seeing if it works on my old system vs. new my system, recording all steps and errors and will post the details here.

Offline

#2 2016-08-28 16:20:12

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: LVM on LUKS with GRUB fails to boot - unable to find root device

Random third party guides are unsupported; use the Official Installation Guide.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2016-08-28 16:44:10

dartos
Member
Registered: 2016-08-28
Posts: 4

Re: LVM on LUKS with GRUB fails to boot - unable to find root device

Did another test install and was able to reproduce the issue.

Hooks in '/etc/mkinitcpio.conf':

HOOKS="base udev autodetect modconf block encrypt lvm2 filesystems keyboard fsck"

Linux commandline options in '/etc/default/grub':

GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda1:lvm"

The intel-ucode package was installed, grub re-installed, config file regenerated.

Rebooted. Successfully decrypted drive and was able to log in on original system.

Switched out drive to second system. Successfully decrypted drive, then it booted to a recovery shell:

starting version 231
ERROR: device '/dev/mapper/vg-root' not found. Skipping fsck.
ERROR: Unable to find root device '/dev/mapper/vg-root'.
You are being dropped to a recovery shell
	Type 'exit' to try and continue booting
sh: can't access tty: job control turned off
[rootfs ]#

And my keyboard doesn't work.

For reference sake, here's the initial /boot/grub/grub.cfg:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux' ...
...
linux /boot/vmlinuz-linux root=/dev/mapper/vg-root rw cryptdevice=/dev/sda1:lvm
...
submenu 'Advanced options for Arch Linux' ...
...
	linux /boot/vmlinuz-linux root=/dev/mapper/vg-root rw cryptdevice=/dev/sda1:lvm quiet

I suspect using 'root=/dev/disk/by-uuid/<UUID>' or 'cryptdevice=/dev/disk/by-uuid/<UUID>:lvm' is what resolved the issue on my primary drive.

Offline

#4 2016-08-28 16:50:22

dartos
Member
Registered: 2016-08-28
Posts: 4

Re: LVM on LUKS with GRUB fails to boot - unable to find root device

jasonwryan wrote:

Random third party guides are unsupported; use the Official Installation Guide.

Understood. However, I do note the guide is referenced in the Arch wiki in the dm-crypt/Encrypting an entire system guide in the LVM on LUKS section:

Tip: Two variants of this setup:
* Instructions at Dm-crypt/Specialties#Encrypted system using a remote LUKS header use this setup with a remote LUKS header on a USB device to achieve a two factor authentication with it.
* Instructions at Pavel Kogan's blog show how to encrypt the /boot partition while keeping it on the main LUKS partition when using GRUB, but be aware of FS#43663.

Offline

#5 2016-08-29 09:09:44

alive4ever
Member
Registered: 2016-07-10
Posts: 65

Re: LVM on LUKS with GRUB fails to boot - unable to find root device

dartos wrote:

Did another test install and was able to reproduce the issue.

Hooks in '/etc/mkinitcpio.conf':

HOOKS="base udev autodetect modconf block encrypt lvm2 filesystems keyboard fsck"

Linux commandline options in '/etc/default/grub':

GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda1:lvm"

The intel-ucode package was installed, grub re-installed, config file regenerated.

Rebooted. Successfully decrypted drive and was able to log in on original system.

Switched out drive to second system. Successfully decrypted drive, then it booted to a recovery shell:

starting version 231
ERROR: device '/dev/mapper/vg-root' not found. Skipping fsck.
ERROR: Unable to find root device '/dev/mapper/vg-root'.
You are being dropped to a recovery shell
	Type 'exit' to try and continue booting
sh: can't access tty: job control turned off
[rootfs ]#

And my keyboard doesn't work.

For reference sake, here's the initial /boot/grub/grub.cfg:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux' ...
...
linux /boot/vmlinuz-linux root=/dev/mapper/vg-root rw cryptdevice=/dev/sda1:lvm
...
submenu 'Advanced options for Arch Linux' ...
...
	linux /boot/vmlinuz-linux root=/dev/mapper/vg-root rw cryptdevice=/dev/sda1:lvm quiet

I suspect using 'root=/dev/disk/by-uuid/<UUID>' or 'cryptdevice=/dev/disk/by-uuid/<UUID>:lvm' is what resolved the issue on my primary drive.

You have to match cryptdevice mapping with root device mapper name.

Since you put root=/dev/mapper/vg-root, the cryptdevice has to be mapped to vg-root instead of lvm.

GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda1:vg-root"

The resulting grub.cfg should contain

...
linux /boot/vmlinuz-linux root=/dev/mapper/vg-root rw cryptdevice=/dev/sda1:vg-root
...

Offline

#6 2016-09-03 22:38:04

dartos
Member
Registered: 2016-08-28
Posts: 4

Re: LVM on LUKS with GRUB fails to boot - unable to find root device

alive4ever wrote:

You have to match cryptdevice mapping with root device mapper name.

Since you put root=/dev/mapper/vg-root, the cryptdevice has to be mapped to vg-root instead of lvm.

GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda1:vg-root"

The resulting grub.cfg should contain

...
linux /boot/vmlinuz-linux root=/dev/mapper/vg-root rw cryptdevice=/dev/sda1:vg-root
...

I tried 'cryptdevice=/dev/sda1:vg-root' and reinstalled/reconfigured GRUB, but I got the same error as above not being able to find root device.

I also took the drive that I got working with both my old and new system and put it into third system and I got the same error about not finding the root device, so I don't think my solution in the first post really solved the root issue.

For now I'm happy that I was able to get my old drive working on my new system, so my issue is resolved without knowing the real issue.

I'm not sure what debugging I can do in case others have this issue, but if anyone has suggestions please let me know.

Offline

Board footer

Powered by FluxBB