Skip to content

fstrim.service is no longer trimming filesystems

Edit: Bug raised and fixed in v2.35.2 by 61b384b

I posted this on the arch forums in this thread but it got very little response so posting here. See that thread for more details.

Ever since the recent upgrade to the util-linux package to v2.35 the fstrim.timer has been running but has not been trimming drives. If fstrim is run manually it works fine. Here is the output of journalctl -u fstrim.service.

util-linux was upgraded after fstrim.timer ran on Jan 25 on boot up. Booting the laptop today you can see there is no log of fstrim being run against my root filesystem. I have confirmed this on three separate machines running Arch now and confirmed by a user in the arch forum thread. Are you guys getting the same issue?

-- Reboot --
Jan 25 14:20:31 hp-laptop systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
Jan 25 14:20:42 hp-laptop fstrim[414]: /: 217.7 GiB (233766383616 bytes) trimmed on /dev/sda1
Jan 25 14:20:42 hp-laptop systemd[1]: fstrim.service: Succeeded.
Jan 25 14:20:42 hp-laptop systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab.
-- Reboot --
Feb 01 12:57:58 hp-laptop systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
Feb 01 12:57:59 hp-laptop systemd[1]: fstrim.service: Succeeded.
Feb 01 12:57:59 hp-laptop systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab.

Edited 4 Feb 2020. We only hold this version.

51 points21 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
51 · 100% up
Kind
Text
ID
ex64oz

Author

2
posts
221
comments
0
media
View profile

25 comments

The problem is ProtectSystem=strict, removing that fixes it. But why this is only a problem recently I have no idea, as this has been there since util-linux v2.34.

Edit: A strace shows this error: access("/mnt/storage0", W_OK) = -1 EROFS (Read-only file system)

Possibly this commit that caused it: f227757c fstrim: ignore non-directory mountpoints, also this issue. I think ProtectSystem=strict uses bind mounts and was overlooked by that commit.

17 points

Just to add to this, if you have your /home on a separate partition you will now also need to comment this line out or set to 'no'

ProtectHome=read-only
2 points

Thanks. Yes, that worked for me too. As you say, very strange why this suddenly manifested itself in v2.35.

1 points
unknown author5 hidden

Deleted before we saved it.

4 points

I thought that but when it did run with output on my other machines with more filesystems to do, the time between starting and succeeded was longer than it currently is which leads me to believe it's not actually doing anything.

5 points
unknown author

Deleted before we saved it.

2 points
unknown author2 hidden

if there is no other output you could try running it with strace

/usr/bin/strace -ff -tt -o /dev/shm/fstrim.strace /usr/bin/fstrim --fstab --verbose --quiet

and see a bit more of what its doing

(/dev/shm will be gone after reboot, feel free to change the output target location)

1 points

Did you open a bug report?

3 points

I did with systemd originally but it got closed as they said the timer ran on schedule and said successful. I was told it was a fstrim or util-linux issue as the fstrim.service/timer is created by that.

1 points

Yup. My first guess would be that it's still working, but not recording the specifics...

2 points

Just checked, same for me. Worked on 20/01 but not on 27/01, when it took 1 second to run instead of 15-16 like before. Launching manually seems to work

2 points
unknown author

Deleted before we saved it.

1 points
unknown author3 hidden

I have fstrim.timer disabled. It wakes up all of my hard drives from standby, which is an absolute nightmare really.

I'm fine with running it once a while manually. It's not like anything breaks if you don't.

-7 points
unknown author1 hidden

Deleted before we saved it.

5 points
unknown author

why do your hard drives even wake up? Trim is a command that only works on flash storage

I guess it scans all drives for UUIDs or something

3 points
unknown author

fstrim is also dangerous, it's a data ditcher

https://bugs.archlinux.org/task/62693

... which causes fstrim to discard either wrong or way too many blocks under certain circumstances. This leads to massive data loss.

Such bugs happen from time to time, no incident since... 9 months

it's better to run this manually, and run it on a known stable kernel (.15, not .1), or ... just not run it at all. Because it's not worth the risk, and most users wouldn't even notice any difference, ever.

trim is so overrated

ymmv

-4 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.