You are not logged in.

#1 2020-07-18 03:29:40

bbaserdem
Member
Registered: 2017-07-27
Posts: 43

LVM on LUKS; mount at boot time does not work.

Hello. I have the following setup;

* I have LVM on LUKS on my NVME drive; where my root partition lives.
* I have an additional SSD; which also has an LVM on LUKS setup; with LUKS keys inside the root partition.

When I boot; I want to mount a partition on the first drive (nvme one) to /home, and then unlock the extra SSD and mount it to /home/archive
The way that I set up; the extra SSD gets decrypted; but on boot, the mounting to /home/archive fails. After I login; if I issue a mount -a; it mounts it without a problem.
My issue is some services run automatically before I log in; (syncthing) and they start writing to the unmounted directory; which is a bad thing.
I have no idea why decryption occurs but mounting fails.

I checked journalctl for an informative message; but only have this

$ sudo journalctl -u home-archive.mount
-- Reboot --
Tem 17 22:42:47 sbp-server systemd[1]: Dependency failed for /home/archive.
Tem 17 22:42:47 sbp-server systemd[1]: home-archive.mount: Job home-archive.mount/start failed with result 'dependency'.
Tem 17 22:51:03 sbp-server systemd[1]: home-archive.mount: Succeeded.
Tem 17 22:51:09 sbp-server systemd[1]: Mounting /home/archive...
Tem 17 22:51:09 sbp-server systemd[1]: Mounted /home/archive.
Tem 17 22:51:52 sbp-server systemd[1]: home-archive.mount: Succeeded.

The successes are from me running mount -a manually.
My fstab, cryptsetup and commandline are as follows;

$ cat /etc/crypttab
cryptdata UUID=3893d492-ac30-448a-9fb9-7e592a7e5fa5   /root/serverdata.keyfile
$ cat /etc/fstab # Trimmed a bit; because it is very long.
/dev/mapper/Server-Arch / btrfs rw,noatime,nodiratime,compress=lzo,ssd,space_cache,subvol=@root 0 1
UUID=CD80-E558 /efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 2
/efi/EFI/Arch /boot none defaults,bind 0 0
/dev/mapper/Server-Home /home xfs rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 2
/dev/mapper/Serverdata-Archive /home/archive ext4 defaults 0 2
/home/archive/Videos /srv/nfs/media none defaults,rbind 0 0
$ cat /proc/cmdline
initrd=EFI/Arch/intel-ucode.img initrd=EFI/Arch/initramfs-linux.img rd.luks.name=b42b6551-17ff-45d0-bf4e-c8d304ce5a50=cryptlvm root=/dev/Server/Arch rootflags=subvol=@root resume=/dev/Server/Arch resume_offset=16400

Output of lsblk and blkid

$ lsblk
NAME                     MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                        8:0    0   3.7T  0 disk  
└─sda1                     8:1    0   3.7T  0 part  
  └─cryptdata            254:4    0   3.7T  0 crypt 
    ├─Serverdata-Seedbox 254:5    0     1T  0 lvm   
    └─Serverdata-Archive 254:6    0     2T  0 lvm   /home/archive
sdb                        8:16   0 931.5G  0 disk  
├─sdb1                     8:17   0   550M  0 part  /efi
└─sdb2                     8:18   0   931G  0 part  
  └─cryptlvm             254:0    0   931G  0 crypt 
    ├─Server-Arch        254:1    0   200G  0 lvm   /media/arch
    └─Server-Home        254:3    0   731G  0 lvm   /home
$ sudo blkid
/dev/sda1: UUID="3893d492-ac30-448a-9fb9-7e592a7e5fa5" TYPE="crypto_LUKS" PARTLABEL="Linux LUKS" PARTUUID="3d109b0e-262a-4a63-b8a7-9253e07e21aa"
/dev/sdb1: UUID="CD80-E558" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="b92a4270-e998-4b59-bd85-2c857f386a8b"
/dev/sdb2: UUID="b42b6551-17ff-45d0-bf4e-c8d304ce5a50" TYPE="crypto_LUKS" PARTLABEL="Linux LUKS" PARTUUID="877171e9-b26d-403c-93e4-4e6d38128b58"
/dev/mapper/cryptlvm: UUID="kIAl1w-Itme-qOxs-zfMp-SmHB-mTmn-rY9mtd" TYPE="LVM2_member"
/dev/mapper/Server-Arch: LABEL="Server-Arch" UUID="b7f0b5b4-bc8c-442f-ac82-bc188e4567fd" UUID_SUB="2a66115e-0d68-4012-a578-de760ebbd451" BLOCK_SIZE="4096" TYPE="btrfs"
/dev/mapper/Server-Home: LABEL="Server-Home" UUID="d7d9250d-0b90-4327-8183-7dd14d729adb" BLOCK_SIZE="4096" TYPE="xfs"
/dev/mapper/cryptdata: UUID="2gVvdN-NWbb-0V7s-Yh1s-UjxB-6hz1-4Zxhnd" TYPE="LVM2_member"
/dev/mapper/Serverdata-Seedbox: UUID="48c8d267-8f9e-453c-833f-0b9798683f12" BLOCK_SIZE="4096" TYPE="ext4"
/dev/mapper/Serverdata-Archive: UUID="8a16a7a9-7f24-409d-8ce9-5838ecf25ccd" BLOCK_SIZE="4096" TYPE="ext4"

Offline

#2 2020-07-21 18:44:15

Bevan
Member
Registered: 2009-09-08
Posts: 99

Re: LVM on LUKS; mount at boot time does not work.

I don't have a similar setup to test but my guess is that due to the LVM layer between cryptsetup and your fstab entry, systemd cannot correctly infer the dependencies. It wants to mount the volume but the volume is not available and not known to systemd at this point. Therefore, the mount fails. It might be possible to get around this by manually writing systemd mount units with proper dependencies instead of relying on /etc/fstab and the systemd-fstab-generator.

However, the easiest way to deal with this may just be to use the systemd automount functionality. Just replace the line in /etc/fstab by:

/dev/mapper/Serverdata-Archive /home/archive ext4 noauto,x-systemd.automount 0 2

This way, it will not be mounted at boot time but on first access which probably happens after cryptsetup und LVM are ready.

Offline

#3 2020-07-24 16:11:20

bbaserdem
Member
Registered: 2017-07-27
Posts: 43

Re: LVM on LUKS; mount at boot time does not work.

Thank you Bevan; I will default to those. My only concern is if trying to reach them through syncthing will trigger the automount or not. And how to do so in a non-systemd environment should I want to migrate to another distro.

The thing that has me baffled is that the LVM layer in between seems to be an issue only on this specific computer. I have it set up on three other computers the same way and it works just fine.

Offline

Board footer

Powered by FluxBB