You are not logged in.
I've used the wiki advice GPT partition automounting to setup a UKI installation for a simple ext4 efi, root and home partition scheme on a SATA SSD. I have no /etc/fstab defined and I've enabled the fstrim.timer for periodic trimming.
The SSD, if this information is important, is a 2.5" SATA (c.2019):
$ hdparm -I /dev/sda
/dev/sda:
ATA device, with non-removable media
Model Number: PNY CS900 480GB SSD
Serial Number: PNY291900229002024D2
Firmware Revision: CS900BB3
Transport: Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
Supported: 11 10 9 8 7 6 5
Likely used: 11
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 937703088
Logical Sector size: 512 bytes
Physical Sector size: 512 bytes
Logical Sector-0 offset: 0 bytes
device size with M = 1024*1024: 457862 MBytes
device size with M = 1000*1000: 480103 MBytes (480 GB)
cache/buffer size = unknown
Form Factor: 2.5 inch
Nominal Media Rotation Rate: Solid State Device
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = 16
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
* DOWNLOAD_MICROCODE
SET_MAX security extension
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* WRITE_{DMA|MULTIPLE}_FUA_EXT
* 64-bit World wide name
* WRITE_UNCORRECTABLE_EXT command
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Gen3 signaling speed (6.0Gb/s)
* Native Command Queueing (NCQ)
* Phy event counters
* READ_LOG_DMA_EXT equivalent to READ_LOG_EXT
* DMA Setup Auto-Activate optimization
* Device-initiated interface power management
* Software settings preservation
* DOWNLOAD MICROCODE DMA command
* SET MAX SETPASSWORD/UNLOCK DMA commands
* WRITE BUFFER DMA command
* READ BUFFER DMA command
* DEVICE CONFIGURATION SET/IDENTIFY DMA commands
* Data Set Management TRIM supported (limit 8 blocks)
Security:
Master password revision code = 59304
supported
not enabled
not locked
frozen
not expired: security count
supported: enhanced erase
20min for SECURITY ERASE UNIT. 60min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5f8db4c2919024d2
NAA : 5
IEEE OUI : f8db4c
Unique ID : 2919024d2
Checksum: correct
$ lsblk --discard
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda 0 512B 2G 0
├─sda1 0 512B 2G 0
├─sda2 0 512B 2G 0
└─sda3 0 512B 2G 0
When I view the mount options for the auto-mounted partitions, I notice that the /home partition has been mounted with the discard option.
$ mount | grep "/dev/sda"
/dev/sda2 on / type ext4 (rw,nodev,relatime)
/dev/sda3 on /home type ext4 (rw,nodev,relatime,discard)
/dev/sda1 on /efi type vfat (rw,nosuid,nodev,noexec,relatime,nosymfollow,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
My understanding is that ext4 will perform continuous trim on this partition. This mount option choice seems to be at odds with the advice on continuous vs. periodic trim: https://wiki.archlinux.org/title/Solid_state_drive#TRIM.
I realise that I can override this behaviour with an /etc/fstab entry for /home, but my question is:
Why has systemd-gpt-auto-generator chosen to add the discard mount option (as a presumably, sane default)? And why just to the /home partition?
Offline
The root partition options are set from the kernel command line parameters. The /home/ partition is presumably using the kernel default values for ext4 mounts.
Does this change the options for the root partition:
# mount -o remount,defaults /
Para todos todo, para nosotros nada
Offline
No, the options remain the same:
$ mount -o remount,defaults /
$ mount | grep "/dev/sda"
/dev/sda2 on / type ext4 (rw,nodev,relatime)
/dev/sda3 on /home type ext4 (rw,nodev,relatime,discard)
The reason for the post is that I'm being steered by https://wiki.archlinux.org/title/Solid_state_drive#TRIM is set up periodic trim. It even has the quote use either:
Note: If you want to use TRIM, use either periodic TRIM or continuous TRIM. Continuous TRIM is not the most preferred way to issue TRIM commands among the Linux community. For example, Ubuntu enables periodic TRIM by default [2], Debian does not recommend using continuous TRIM and Red Hat recommends using periodic TRIM over using continuous TRIM if feasible [3].
and following the link in the next table for ext4 TRIM notes: "discard, nodiscard(*)" in [5] (https://docs.kernel.org/admin-guide/ext4.html#options
discard, nodiscard(*)
Controls whether ext4 should issue discard/TRIM commands to the underlying block device when blocks are freed. This is useful for SSD devices and sparse/thinly-provisioned LUNs, but it is off by default until sufficient testing has been done.
but the GPT partition automounting is mounting one ext4 partition with the discard option...
With respect to my particular SATA SSD, I'm unsure whether to override the /home partition mount (to disable continuous trim), the root partition mount (to enable continuous trim) or leave them both as they've been defaulted.
GPT partition automounting seems to use ext4 mount options inconsistent with the wiki TRIM advice...
Last edited by shbon (2025-02-02 16:18:11)
Offline
What happens with the root partition if you add a specific line to /etc/fstab, like this:
/dev/sda2 / ext4 defaults 0 1
Does it have the discard option applied?
It's best to disable the discard option, I agree with Debian & Red Hat on that issue. I remember I had to run an fstab just for that purpose when I was running F2FS.
Also I think /efi/ should be using autofs if there's no fstab so please share the full output of
findmnt
Thanks.
Para todos todo, para nosotros nada
Offline
Thanks for your help.
What happens with the root partition if you add a specific line to /etc/fstab, like this:
/dev/sda2 / ext4 defaults 0 1
Does it have the discard option applied?
No, but it did change from rw,nodev,relatime to rw,relatime
Also I think /efi/ should be using autofs if there's no fstab so please share the full output of
Yes, /efi is using autofs (and a vfat fstype if I force a mount of the partition with ls /efi)
$ findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda2 ext4 rw,relatime
├─/dev devtmpfs devtmpfs rw,nosuid,size=4096k,nr_inodes=980180,mode=755,inode64
│ ├─/dev/mqueue mqueue mqueue rw,nosuid,nodev,noexec,relatime
│ ├─/dev/hugepages hugetlbfs hugetlbfs rw,nosuid,nodev,relatime,pagesize=2M
│ ├─/dev/shm tmpfs tmpfs rw,nosuid,nodev,inode64
│ └─/dev/pts devpts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
├─/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/tracing tracefs tracefs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/debug debugfs debugfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/fuse/connections fusectl fusectl rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup cgroup2 cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot
│ ├─/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
│ ├─/sys/firmware/efi/efivars efivarfs efivarfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/bpf bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700
│ └─/sys/kernel/config configfs configfs rw,nosuid,nodev,noexec,relatime
├─/proc proc proc rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=38,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=6252
│ └─/proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime
├─/run tmpfs tmpfs rw,nosuid,nodev,size=1572836k,nr_inodes=819200,mode=755,inode64
│ ├─/run/credentials/systemd-resolved.service tmpfs tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap
│ ├─/run/credentials/systemd-journald.service tmpfs tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap
│ ├─/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relatime,size=786416k,nr_inodes=196604,mode=700,uid=1000,gid=1000,inode64
│ │ └─/run/user/1000/gvfs gvfsd-fuse fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
│ ├─/run/firejail/dbus tmpfs[/firejail/dbus] tmpfs rw,nosuid,nodev,noexec,size=1572836k,nr_inodes=819200,mode=755,inode64
│ ├─/run/firejail/firejail.ro.dir tmpfs[/firejail/firejail.ro.dir] tmpfs ro,nosuid,nodev,size=1572836k,nr_inodes=819200,mode=755,inode64
│ ├─/run/credentials/getty@tty1.service tmpfs tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap
│ └─/run/firejail/firejail.ro.file tmpfs[/firejail/firejail.ro.file] tmpfs ro,nosuid,nodev,size=1572836k,nr_inodes=819200,mode=755,inode64
├─/tmp tmpfs tmpfs rw,nosuid,nodev,size=3932088k,nr_inodes=1048576,inode64
├─/home /dev/sda3 ext4 rw,nodev,relatime,discard
└─/efi systemd-1 autofs rw,relatime,fd=69,pgrp=1,timeout=120,minproto=5,maxproto=5,direct,pipe_ino=1242
└─/efi /dev/sda1 vfat rw,nosuid,nodev,noexec,relatime,nosymfollow,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro
I could go back to specifying /etc/fstab to implement the desired periodic trim behaviour, but GPT partition automounting (+ UKI) has dangled the carrot of NOT having to specify /etc/fstab (or configure a boot loader) for this 'simple' Arch Linux setup!
I'd like to work out why the discard option is being applied to /home, seeing as it appears not to be a default ext4 option...
EDIT: In fact with a /etc/fstab of:
/dev/sda2 / ext4 defaults 0 1
/dev/sda3 /home ext4 defaults 0 2
/swapfile none swap defaults 0 0
I get /home mounted with rw,relatime too:
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda2 ext4 rw,relatime
├─/dev devtmpfs devtmpfs rw,nosuid,size=4096k,nr_inodes=980180,mode=755,inode64
│ ├─/dev/mqueue mqueue mqueue rw,nosuid,nodev,noexec,relatime
│ ├─/dev/hugepages hugetlbfs hugetlbfs rw,nosuid,nodev,relatime,pagesize=2M
│ ├─/dev/shm tmpfs tmpfs rw,nosuid,nodev,inode64
│ └─/dev/pts devpts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
├─/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/tracing tracefs tracefs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/debug debugfs debugfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/fuse/connections fusectl fusectl rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/config configfs configfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup cgroup2 cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot
│ ├─/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
│ ├─/sys/firmware/efi/efivars efivarfs efivarfs rw,nosuid,nodev,noexec,relatime
│ └─/sys/fs/bpf bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700
├─/proc proc proc rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=38,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=272
│ └─/proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime
├─/run tmpfs tmpfs rw,nosuid,nodev,size=1572836k,nr_inodes=819200,mode=755,inode64
│ ├─/run/credentials/systemd-resolved.service tmpfs tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap
│ ├─/run/credentials/systemd-journald.service tmpfs tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap
│ ├─/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relatime,size=786416k,nr_inodes=196604,mode=700,uid=1000,gid=1000,inode64
│ │ └─/run/user/1000/gvfs gvfsd-fuse fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
│ ├─/run/firejail/dbus tmpfs[/firejail/dbus] tmpfs rw,nosuid,nodev,noexec,size=1572836k,nr_inodes=819200,mode=755,inode64
│ ├─/run/firejail/firejail.ro.dir tmpfs[/firejail/firejail.ro.dir] tmpfs ro,nosuid,nodev,size=1572836k,nr_inodes=819200,mode=755,inode64
│ ├─/run/credentials/getty@tty1.service tmpfs tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap
│ └─/run/firejail/firejail.ro.file tmpfs[/firejail/firejail.ro.file] tmpfs ro,nosuid,nodev,size=1572836k,nr_inodes=819200,mode=755,inode64
├─/tmp tmpfs tmpfs rw,nosuid,nodev,size=3932088k,nr_inodes=1048576,inode64
├─/home /dev/sda3 ext4 rw,relatime
└─/efi systemd-1 autofs rw,relatime,fd=68,pgrp=1,timeout=120,minproto=5,maxproto=5,direct,pipe_ino=3484
Last edited by shbon (2025-02-02 18:39:33)
Offline
So that looks like systemd is mounting /home/ with the extra option, which shouldn't happen.
I did run a similar system myself but with a single root partition, no fstab, no root= line for the bootloader, and it was fine with btrfs & xfs, I would have noticed an added discard option because I use periodic TRIM.
Perhaps pursue this upstream?
Para todos todo, para nosotros nada
Offline
So that looks like systemd is mounting /home/ with the extra option, which shouldn't happen.
Yes. Specifically, systemd-gpt-auto-generator is generating the following for /home:
$ cat /run/systemd/generator.late/home.mount
# Automatically generated by systemd-gpt-auto-generator
[Unit]
Description=Home Partition
Documentation=man:systemd-gpt-auto-generator(8)
Before=local-fs.target
Requires=systemd-fsck@dev-disk-by\x2ddiskseq-1\x2dpart3.service
After=systemd-fsck@dev-disk-by\x2ddiskseq-1\x2dpart3.service
After=blockdev@dev-disk-by\x2ddiskseq-1\x2dpart3.target
[Mount]
What=/dev/disk/by-diskseq/1-part3
Where=/home
Type=ext4
Options=discard,rw,nodev,suid,exec
Offline
Some clues here: https://unix.stackexchange.com/question … ed-filesys
And it looks like systemd uses discard automatically for all partitions except ESP & XBOOTLDR types:
Para todos todo, para nosotros nada
Offline
And it looks like systemd uses discard automatically for all partitions except ESP & XBOOTLDR types:
Yes, but for root it must be filtered out somewhere:
$ cat /run/systemd/generator.late/-.mount
# Automatically generated by systemd-gpt-auto-generator
[Unit]
Description=Root Partition
Documentation=man:systemd-gpt-auto-generator(8)
Before=local-fs.target
After=blockdev@dev-gpt\x2dauto\x2droot.target
[Mount]
What=/dev/gpt-auto-root
Where=/
Options=rw,nodev,suid,exec
EDIT: OK...
So for the root partition call of partition_pick_mount_options (https://github.com/systemd/systemd/blob … tor.c#L706), this line may be filtering out (i.e. not adding) the discard option: https://github.com/systemd/systemd/blob … ge.c#L1931. It looks like the arg_root_fstype argument of partition_pick_mount_options function is determined from the rootfstype parameter of the kernel cmdline: https://github.com/systemd/systemd/blob … tor.c#L926, otherwise it's NULL...
EDIT2: Yes, that seems to hold up. If I add rootfstype=ext4 to my kernel cmdline, I get root mounted with the discard option too:
$ cat /etc/cmdline.d/kernel-cmdline.conf
rw quiet loglevel=3 nowatchdog bgrt_disable zswap.enabled=1 rootfstype=ext4
$ findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda2 ext4 rw,nodev,relatime,discard
├─/dev devtmpfs devtmpfs rw,nosuid,size=4096k,nr_inodes=980180,mode=755,inode64
│ ├─/dev/hugepages hugetlbfs hugetlbfs rw,nosuid,nodev,relatime,pagesize=2M
│ ├─/dev/mqueue mqueue mqueue rw,nosuid,nodev,noexec,relatime
│ ├─/dev/shm tmpfs tmpfs rw,nosuid,nodev,inode64
│ └─/dev/pts devpts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
├─/sys sysfs sysfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/tracing tracefs tracefs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/debug debugfs debugfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/fuse/connections fusectl fusectl rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/config configfs configfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup cgroup2 cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot
│ ├─/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
│ ├─/sys/firmware/efi/efivars efivarfs efivarfs rw,nosuid,nodev,noexec,relatime
│ └─/sys/fs/bpf bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700
├─/proc proc proc rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=38,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=2420
│ └─/proc/sys/fs/binfmt_misc binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime
├─/run tmpfs tmpfs rw,nosuid,nodev,size=1572836k,nr_inodes=819200,mode=755,inode64
│ ├─/run/credentials/systemd-resolved.service tmpfs tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap
│ ├─/run/credentials/systemd-journald.service tmpfs tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap
│ ├─/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relatime,size=786416k,nr_inodes=196604,mode=700,uid=1000,gid=1000,inode64
│ └─/run/credentials/getty@tty1.service tmpfs tmpfs ro,nosuid,nodev,noexec,relatime,nosymfollow,size=1024k,nr_inodes=1024,mode=700,inode64,noswap
├─/efi systemd-1 autofs rw,relatime,fd=70,pgrp=1,timeout=120,minproto=5,maxproto=5,direct,pipe_ino=5379
│ └─/efi /dev/sda1 vfat rw,nosuid,nodev,noexec,relatime,nosymfollow,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro
├─/tmp tmpfs tmpfs rw,nosuid,nodev,size=3932088k,nr_inodes=1048576,inode64
└─/home /dev/sda3 ext4 rw,nodev,relatime,discard
So as you say, it seems like the intention is to set the discard option for root and other partitions (except ESP & XBOOTLDR types) where the fstype supports discard, but it's only actually set for root if the rootfstype is explicitly set on the kernel cmdline...
Is that a bug or intended behaviour?...
Last edited by shbon (2025-02-03 00:02:24)
Offline