About trim support on LUKS encrypted devices.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have, on one Leap 15.1 machine: /etc/crypttab: cr_home /dev/disk/by-id/ata-...-part5 none timeout=300,discard /etc/fstab: /dev/mapper/cr_home /home xfs lazytime,exec,nofail 1 2 Isengard:~ # cat /proc/cmdline BOOT_IMAGE=/boot/vmlinuz-4.12.14-lp151.28.67-default root=UUID=0d457df1-... showopts resume=/dev/disk/by-label/Swap splash=verbose Isengard:~ # Isengard:~ # mount | grep /home /dev/mapper/cr_home on /home type xfs (rw,relatime,lazytime,attr2,inode64,noquota) Isengard:~ # And apparently, trim is working: Isengard:~ # service fstrim status ● fstrim.service - Discard unused blocks on filesystems from /etc/fstab Loaded: loaded (/usr/lib/systemd/system/fstrim.service; static; vendor preset: disabled) Active: inactive (dead) since Mon 2020-12-28 00:01:26 CET; 12h ago Docs: man:fstrim(8) Process: 24826 ExecStart=/usr/sbin/fstrim -Av (code=exited, status=0/SUCCESS) Main PID: 24826 (code=exited, status=0/SUCCESS) Dec 28 00:00:03 Isengard systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab... Dec 28 00:01:26 Isengard fstrim[24826]: /home: 62.6 GiB (67245150208 bytes) trimmed on /dev/mapper/cr_home <======= Dec 28 00:01:26 Isengard fstrim[24826]: /: 1.7 GiB (1831469056 bytes) trimmed on /dev/sda4 Dec 28 00:01:26 Isengard systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab. Isengard:~ # So I understand from that that trim is working, yet I'm not using "allow_discards" as a kernel option. On another machine, running Leap 15.2 (upgraded from 15.1 on 2020-11-08), it is not working with similar settings. I have: /etc/crypttab: cr_crypta /dev/disk/by-uuid/f9ef602f-... none noauto,discard /etc/fstab: /dev/mapper/cr_crypta /data/cripta xfs defaults,lazytime 1 2 minas-tirith:~ # cat /proc/cmdline BOOT_IMAGE=/vmlinuz-5.3.18-lp152.47-default root=UUID=7d8f7fc8-df18-474b-be96-e43862cf3289 resume=/dev/disk/by-label/Swap splash=verbose console=tty1 loglevel=3 showopts rd.convertfs minas-tirith:~ # minas-tirith:~ # mount | grep data /dev/mapper/cr_crypta on /data/cripta type xfs (rw,relatime,lazytime,attr2,inode64,logbufs=8,logbsize=32k,noquota) minas-tirith:~ # service fstrim status ● fstrim.service - Discard unused blocks on filesystems from /etc/fstab Loaded: loaded (/usr/lib/systemd/system/fstrim.service; static; vendor preset: disabled) Active: inactive (dead) since Mon 2020-12-28 12:48:46 CET; 11min ago Docs: man:fstrim(8) Process: 13106 ExecStart=/usr/sbin/fstrim -Av (code=exited, status=0/SUCCESS) Main PID: 13106 (code=exited, status=0/SUCCESS) minas-tirith:~ # Notice that in this machine the journal does not have information. 15.1 had the same problem, yet the journal is persistent. Syslog does have the entries: minas-tirith:~ # grep -i trim /var/log/messages <3.6> 2020-11-09 00:01:35 minas-tirith fstrim 20497 - - /other: 1.6 GiB (1716981760 bytes) trimmed on /dev/sda9 <3.6> 2020-11-09 00:01:35 minas-tirith fstrim 20497 - - /: 5.1 GiB (5511180288 bytes) trimmed on /dev/sda7 <3.6> 2020-11-09 00:01:35 minas-tirith fstrim 20497 - - /boot: 113.7 MiB (119165952 bytes) trimmed on /dev/sda6 <3.6> 2020-12-01 09:09:20 minas-tirith btrfs-trim.sh 11836 - - Path / is not btrfs, skipping <3.6> 2020-12-21 21:18:43 minas-tirith fstrim 5069 - - /other: 0 B (0 bytes) trimmed on /dev/sda9 <3.6> 2020-12-21 21:18:43 minas-tirith fstrim 5069 - - /: 1.9 GiB (1998217216 bytes) trimmed on /dev/sda7 <3.6> 2020-12-21 21:18:43 minas-tirith fstrim 5069 - - /boot: 9.4 MiB (9889792 bytes) trimmed on /dev/sda6 <3.6> 2020-12-28 12:48:46 minas-tirith fstrim 13106 - - /other: 0 B (0 bytes) trimmed on /dev/sda9 <3.6> 2020-12-28 12:48:46 minas-tirith fstrim 13106 - - /: 781.9 MiB (819888128 bytes) trimmed on /dev/sda7 <3.6> 2020-12-28 12:48:46 minas-tirith fstrim 13106 - - /boot: 4.9 MiB (5072896 bytes) trimmed on /dev/sda6 minas-tirith:~ # Previous 15.1 messages: <3.6> 2020-09-15 18:30:18 minas-tirith fstrim 14184 - - /other: 1.6 GiB (1716981760 bytes) trimmed on /dev/sda9 <3.6> 2020-09-15 18:30:18 minas-tirith fstrim 14184 - - /: 6 GiB (6432956416 bytes) trimmed on /dev/sda7 <3.6> 2020-09-15 18:30:18 minas-tirith fstrim 14184 - - /boot: 123.2 MiB (129189888 bytes) trimmed on /dev/sda6 But observe that /data/cripta does not appear, it is not trimmed. Why not? minas-tirith:~ # fstrim -v /data/cripta fstrim: /data/cripta: the discard operation is not supported minas-tirith:~ # mount | grep /data/cripta /dev/mapper/cr_crypta on /data/cripta type xfs (rw,relatime,lazytime,attr2,inode64,logbufs=8,logbsize=32k,noquota) minas-tirith:~ # On the other machine, it works: Isengard:~ # fstrim -v /home /home: 62.6 GiB (67245076480 bytes) trimmed Isengard:~ # mount | grep /home /dev/mapper/cr_home on /home type xfs (rw,relatime,lazytime,attr2,inode64,noquota) Isengard:~ # minas-tirith:~ # dmsetup info /dev/mapper/cr_crypta Name: cr_crypta State: ACTIVE Read Ahead: 256 Tables present: LIVE Open count: 1 Event number: 0 Major, minor: 254, 0 Number of targets: 1 UUID: CRYPT-LUKS1-...-cr_crypta minas-tirith:~ # Isengard:~ # dmsetup info /dev/mapper/cr_home Name: cr_home State: ACTIVE Read Ahead: 1024 Tables present: LIVE Open count: 1 Event number: 0 Major, minor: 254, 0 Number of targets: 1 UUID: CRYPT-LUKS1-...-cr_home Isengard:~ # I have another laptop running 15.1 where it works: /etc/crypttab: cr_sda8 UUID=1edf494d-d697-40b2-ba00-c7da0a1d5fbe none timeout=300,discard /etc/fstab: /dev/mapper/cr_sda8 /home xfs lazytime 0 1 Legolas:~ # cat /proc/cmdline BOOT_IMAGE=/boot/vmlinuz-4.12.14-lp151.28.67-default root=UUID=8c1f1030-... resume=/dev/disk/by-label/Swap splash=verbose showopts Legolas:~ # Legolas:~ # mount | grep /home /dev/mapper/cr_sda8 on /home type xfs (rw,relatime,lazytime,attr2,inode64,noquota) Legolas:~ # Legolas:~ # service fstrim status ● fstrim.service - Discard unused blocks on filesystems from /etc/fstab Loaded: loaded (/usr/lib/systemd/system/fstrim.service; static; vendor preset: disabled) Active: inactive (dead) since Mon 2020-12-28 13:36:52 CET; 3min 38s ago Docs: man:fstrim(8) Process: 10462 ExecStart=/usr/sbin/fstrim -Av (code=exited, status=0/SUCCESS) Main PID: 10462 (code=exited, status=0/SUCCESS) Dec 28 13:35:33 Legolas.valinor systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab... Dec 28 13:36:52 Legolas.valinor fstrim[10462]: /home: 69.2 GiB (74332495872 bytes) trimmed on /dev/mapper/cr_sda8 <===== Dec 28 13:36:52 Legolas.valinor fstrim[10462]: /: 2.3 GiB (2484498432 bytes) trimmed on /dev/sda11 Dec 28 13:36:52 Legolas.valinor systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab. Legolas:~ # Information links: <https://superuser.com/questions/1546128/ssd-trim-on-archlinux/1546136#1546136> SSD Trim on Archlinux <https://wiki.archlinux.org/index.php/Solid_state_drive#dm-crypt> <https://wiki.debian.org/SSDOptimization#Mounting_SSD_filesystems> <https://blog.christophersmart.com/2013/06/05/trim-on-lvm-on-luks-on-ssd/> TRIM on LVM on LUKS on SSD - -- Cheers Carlos E. R. (from 15.1 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- iHoEARECADoWIQQZEb51mJKK1KpcU/W1MxgcbY1H1QUCX+nYrhwccm9iaW4ubGlz dGFzQHRlbGVmb25pY2EubmV0AAoJELUzGBxtjUfVgoQAnAue8M23DsVSZ8/Ahsvp T7e6D1nJAJ4pwLCXnBdHe/5VuVg+VGWHrtnO1Q== =d2w8 -----END PGP SIGNATURE-----
participants (1)
-
Carlos E. R.