[systemd-devel] Mount options for ESP, LUKS and rootfs in automatic partition discovery and mounting

Bastien Traverse neitsab at esrevart.net
Sat Nov 28 00:26:37 UTC 2020


Hello everyone,

Is it possible to specify mount options for ESP, root and LUKS devices 
when using automatic partition discovery and mounting with no fstab?

I got a new Arch Linux installation to boot without fstab, crypttab or 
specifying the `root/luks.uuid` kernel options, however the 
`luks.options=discard` and `rootflags=noatime` aren't honored. I have 
read man systemd-cryptsetup-generator, systemd-fstab-generator and 
systemd-remount-fs and can't seem to find the answer so as to why those 
settings aren't passed down.

My setup is as follow:

+----------------------------+ +---------------------------+
|                            | |                           |
| EFI System Partition (ESP) | | LUKS encrypted partition  |
|                            | |                           |
| /dev/nvme0n1p1             | | /dev/nvme0n1p2            |
| FAT32                      | | XFS                       |
|                            | |                           |
| mounted on /efi            | | mounted on /              |
|                            | |                           |
+----------------------------+ +---------------------------+

* partitioning was done using Partition Type GUIDs following the 
Discoverable Partition Specification:

# sgdisk --zap-all --clear /dev/nvme0n1 \
   --new=1:0:+488M --typecode=1:ef00 --change-name=1:"EFI System 
Partition" \
   --new=2:0:0   --typecode=2:8304 --change-name=2:"Linux LUKS"
# fdisk -l /dev/nvme0n1
...
Device           Start        End   Sectors   Size Type
/dev/nvme0n1p1    2048    1001471    999424   488M EFI System
/dev/nvme0n1p2 1001472 1000215182 999213711 476.5G Linux root (x86-64)

* initramfs uses systemd with the following mkinitcpio hooks:

$ grep systemd /etc/mkinitcpio.conf
HOOKS=(base systemd autodetect keyboard sd-vconsole modconf block 
sd-encrypt filesystems fsck)

* systemd-boot is used to load a unified EFI kernel image made with:

```
objcopy \
     --add-section .osrel="/usr/lib/os-release" --change-section-vma 
.osrel=0x20000 \
     --add-section .cmdline="cmdline.txt" --change-section-vma 
.cmdline=0x30000 \
     --add-section .splash="/usr/share/systemd/bootctl/splash-arch.bmp" 
--change-section-vma .splash=0x40000 \
     --add-section .linux="vmlinuz-linux" --change-section-vma 
.linux=0x2000000 \
     --add-section .initrd="ucode-initrd.img" --change-section-vma 
.initrd=0x3000000 \
     "/usr/lib/systemd/boot/efi/linuxx64.efi.stub" 
"/efi/EFI/Linux/linux.efi"
```

$ cat cmdline.txt
luks.options=discard rootflags=noatime

$ bootctl list
Boot Loader Entries:
         title: Arch Linux (default)
            id: linux.efi
        source: /efi/EFI/Linux/linux.efi
         linux: EFI/Linux/linux.efi
       options: luks.options=discard rootflags=noatime

Logs show the correct command line:

journalctl -b | grep noatime
nov. 27 21:32:16 archlinux kernel: Command line: luks.options=discard 
rootflags=noatime

However once booted:

$ findmnt /
TARGET                                SOURCE           FSTYPE     OPTIONS
/                                     /dev/mapper/root xfs 
rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota

# dmsetup table
root: 0 999180943 crypt aes-xts-plain64 
:64:logon:cryptsetup:LUKS-U-U-I-D-xx 0 259:2 32768

I have tried specifying the LUKS header UUID as in 
`luks.option=UUID=discard`, using different wording like discards, 
allow-discards, allow_discards... and using the `rw` option but to no avail.

For LUKS I know I can set the desired flags using `cryptsetup refresh` 
and make them permanent with the `--persistent` option, but I would like 
to know whether it is possible using just systemd and kernel options. As 
for rootflags, I am even more at a loss so as to why it isn't honored.

It is likely to be something I don't understand in how systemd works in 
early boot or maybe it is simply not possible, but from the doc it looks 
like it should. Could someone shed some light on this issue?

Bonus question: is setting mount options for the ESP doable via the same 
means, otherwise than manualy editing efi.mount?

Thanks and regards,
Bastien


More information about the systemd-devel mailing list