FS#64046 - [util-linux] fstrim.service does not trim home partition

Attached to Project: Arch Linux
Opened by Leon Möller (jkhsjdhjs) - Sunday, 06 October 2019, 21:43 GMT
Last edited by freswa (frederik) - Tuesday, 28 April 2020, 20:05 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Dave Reisner (falconindy)
Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 6
Private No

Details

Description:
The service "fstrim.service" provided by this package does not trim partitions mounted on /home, because of "ProtectHome=yes" set in the unit file. "ProtectHome=yes" makes the /home directory inaccessible and empty for the process invoked by the unit.

Additional info:
* Changing ProtectHome to read-only makes it work while still protecting the home directory from writes.
* package version(s): 2.34-3
* config and/or log files etc.:

Log with ProtectHome=yes:
Oct 06 23:25:11 benziumini systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
Oct 06 23:25:11 benziumini fstrim[1519]: /boot: 0 B (0 bytes) trimmed on /dev/sda2
Oct 06 23:25:11 benziumini fstrim[1519]: /: 0 B (0 bytes) trimmed on /dev/mapper/lvm-root
Oct 06 23:25:11 benziumini systemd[1]: fstrim.service: Succeeded.
Oct 06 23:25:11 benziumini systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab.

Log with ProtectHome=read-only:
Oct 06 23:35:02 benziumini systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
Oct 06 23:35:02 benziumini fstrim[1737]: /home: 0 B (0 bytes) trimmed on /dev/mapper/lvm-home
Oct 06 23:35:02 benziumini fstrim[1737]: /boot: 0 B (0 bytes) trimmed on /dev/sda2
Oct 06 23:35:02 benziumini fstrim[1737]: /: 0 B (0 bytes) trimmed on /dev/mapper/lvm-root
Oct 06 23:35:02 benziumini systemd[1]: fstrim.service: Succeeded.
Oct 06 23:35:02 benziumini systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab.


Steps to reproduce:
Install Arch Linux on an SSD and mount a separate partition on /home. Start fstrim.service and check the output logged.
This task depends upon

Closed by  freswa (frederik)
Tuesday, 28 April 2020, 20:05 GMT
Reason for closing:  Fixed
Additional comments about closing:  https://git.archlinux.org/svntogit/packa ges.git/commit/trunk?h=packages/util-lin ux&id=8bff1d2c92d5d7ee0add4755a2f301 5ea5f3208b
Comment by nl6720 (nl6720) - Monday, 07 October 2019, 08:32 GMT Comment by Leon Möller (jkhsjdhjs) - Thursday, 06 February 2020, 04:56 GMT
The issue has been resolved upstream by changing ProtectHome=yes to ProtectHome=read-only: https://github.com/karelzak/util-linux/commit/c64d452b3eb85fe55e238144082247b05cc143ea
But one month and a few days earlier the following changes have been commited, making fstrim ignore read-only file systems: https://github.com/karelzak/util-linux/commit/2d22ac64e4d6e6732640f38b7232b5bcdc84a877
Thus, when util-linux 2.35 was released half a year later, fstrim.service had ProtectHome=read-only, which makes /home read-only for the fstrim process, and ProtectSystem=strict, which makes the entire filesystem hierarchy read-only. Because of this, fstrim would ignore every filesystem.
The issue was reported again and has been fixed two days ago, by removing ProtectHome and ProtectSystem from the systemd unit file: https://github.com/karelzak/util-linux/issues/948

This issue can probably be closed with the release of util-linux 2.35.2.
Comment by Konstantin Y (tm4ig) - Monday, 24 February 2020, 17:46 GMT
With 5.5.5 kernel, systemd 244.3, 2.35.1 util-linux and

ProtectSystem=strict
ProtectHome=read-only
values in /usr/lib/systemd/system/fstrim.service unit file
Periodic TRIM not work for all partitions (/, /boot, /boot/efi, /home).
After remove or comment ProtectSystem and ProtectHome lines trim work nornaly

Loading...