Partition table instead of LVM inside a LUKS container

Mistave <[email protected]> Sun, 25 Feb 2024 16:14:53 +0100
Newsgroups dev.linux.lists.cryptsetup
Message-ID <[email protected]>
Hello,

Just a request for some opinions and suggestions.

In most online tutorials about encrypted linux setups it's recommended 
to use LVM (and by that I mean tools like pvcreate, vgcreate and 
lvcreate) on-top of a LUKS container to further partition the encrypted 
block device. However, my question is that, provided you are using a 
full device encryption (e.g. "cryptsetup luksFormat /dev/sdb" and then 
"cryptsetup open /dev/sdb container"), are there any negative effects of 
simply skipping LVM and creating a partition table with partitions 
directly on the new dm-crypt device?

I tried creating a test setup on an empty drive, and the system (Ubuntu 
22.04 LTS) was able to recognize the partitions after creating a new GPT 
partition table with two ext4 primary partitions on 
/dev/mapper/container device. The partitions appeared as 
/dev/mapper/container1 and /dev/mapper/container2, and were also visible 
in /dev/disk/by-id/ folder. No /dev/loop devices or LVM ("lvs" command 
returned nothing) appear to have been used while setting up the environment.

The setup was like (as root):
cryptsetup luksFormat /dev/sdb
cryptsetup open /dev/sdb container
gparted /dev/mapper/container => New GPT table + 2x 10G ext4 partitions
mount /dev/mapper/container1 /mnt/disk => Mounted OK.


- Are there any benefits or drawbacks by using this approach over using 
LVM inside the LUKS container?

- Is this recommended or generally well supported?

- Can such setup be used to host the linux rootfs and other mount points 
in an encrypted Linux setup (including /boot)? Grub?

- Can I expect problems unmounting and closing the dm-crypt device i.e. 
by system shutdown scripts? For example, if I (after unmounting 
/mnt/disk) tried to close the device by doing "cryptsetup close 
container" in my test setup, it complained that the device is still in 
use. I had to first close the "container2" device, then "continer1" and 
finally the "container" device in /dev/mapper to remove the dm-crypt 
mapping.


Thanks in advance.