You are not logged in.

#1 2019-07-15 10:40:17

nvteighen
Member
Registered: 2014-03-13
Posts: 31

[SOLVED] fstrim.service not trimming /home

Hi, fellow Archers!
I'm now using an SSD for the first time in my life. After reading the Wiki and docs, I've set up periodic trimming using the fstrim.timer method under the default configuration (i.e. once a week). It works for all relevant partitions, except the /home partition (a plain ext4 partition, no LVM whatsoever). This is the log of the last activation of fstrim.service by fstrim.timer.

[ugi@UGI ~]$ journalctl -u fstrim.service
-- Logs begin at Tue 2019-07-02 19:16:50 CEST, end at Mon 2019-07-15 12:28:58 CEST. --
jul 15 00:00:25 UGI systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
jul 15 00:00:29 UGI fstrim[8106]: /boot: 237,5 MiB (249032704 bytes) recortados en /dev/sda1
jul 15 00:00:29 UGI fstrim[8106]: /: 87,6 GiB (94002991104 bytes) recortados en /dev/sda2
jul 15 00:00:29 UGI systemd[1]: fstrim.service: Succeeded.
jul 15 00:00:29 UGI systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab.

If I run fstrim directly from a terminal, I do get /home trimmed:

[ugi@UGI ~]$ sudo fstrim -va
/boot: 237,5 MiB (249032704 bytes) recortados en /dev/sda1
/home: 311,3 GiB (334293999616 bytes) recortados en /dev/sda4
/: 87,6 GiB (94007967744 bytes) recortados en /dev/sda2

Just for reference, this is /etc/fstab:

[ugi@UGI ~]$ cat /etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/sda2
UUID=59c51254-b732-4d1c-85af-b9e2fa1fa706	/         	ext4      	rw,relatime	0 1

# /dev/sda1
UUID=9914-5C88      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro	0 2

# /dev/sda4
UUID=7fae1575-4b45-47b6-ba17-1e31697c3f11	/home     	ext4      	rw,relatime	0 2

# /dev/sda3
UUID=bd378907-28dd-42a3-92d3-ed53e8441c5d	none      	swap      	defaults,discard  	0 0

(Yes, using continuous trim on swap, as recommended by the wiki)

So, my guess is that something is wrong with the fstrim.timer/service configuration somewhere, because the drive and the /home partition do support trimming. I've been looking at the fstrim.service unit (unmodified from the util-linux package), but couldn't make any sense out of it. This is the file:

[ugi@UGI ~]$ cat /usr/lib/systemd/system/fstrim.service 
[Unit]
Description=Discard unused blocks on filesystems from /etc/fstab
Documentation=man:fstrim(8)

[Service]
Type=oneshot
ExecStart=/sbin/fstrim --fstab --verbose --quiet
ProtectSystem=strict
ProtectHome=yes
PrivateDevices=no
PrivateNetwork=yes
PrivateUsers=no
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
MemoryDenyWriteExecute=yes
SystemCallFilter=@default @file-system @basic-io @system-service

Is there anything I'm missing out so that the /home partition is trimmed by the service when activated by the timer?

Thanks in advance!

Last edited by nvteighen (2019-07-15 11:37:16)

Offline

#2 2019-07-15 11:29:50

merlock
Member
Registered: 2018-10-30
Posts: 235

Re: [SOLVED] fstrim.service not trimming /home

Comment out:

ProtectHome=yes (or change it to no).

And do a systemctl daemon-reload


Eenie meenie, chili beanie, the spirits are about to speak -- Bullwinkle J. Moose
It's a big club...and you ain't in it -- George Carlin
Registered Linux user #149839
perl -e 'print$i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10); '

Offline

#3 2019-07-15 11:36:59

nvteighen
Member
Registered: 2014-03-13
Posts: 31

Re: [SOLVED] fstrim.service not trimming /home

merlock wrote:

Comment out:

ProtectHome=yes (or change it to no).

And do a systemctl daemon-reload

Thank you! I manually activated the service to test your solution and fstrim is now effectively run on /home. Marking as solved!

Offline

#4 2019-07-22 10:17:30

frapox
Member
From: Southern Europe
Registered: 2017-06-24
Posts: 5

Re: [SOLVED] fstrim.service not trimming /home

I found out the same problem on my system, and I applied the same workaaround...

so I can confirm that disabling "ProtectHome" directive is solving this issue smile

Offline

Board footer

Powered by FluxBB