Yesterday I was working on my Manjaro Linux laptop when everything slowed to a crawl. I determined the cause to be extremely slow disk write speeds (slow as in maxed out at 2MB/s with the activity light solid on). The drive is a half-full 1TB SATA SSD (T-Force Vulcan Z) that is less than a year old, so I wasn’t expecting it to fail, but I checked the SMART diagnostics anyway. It was mostly fine, other than a pre-fail warning for the number of bad blocks. Out of curiosity I decided to calculate how much data I had written to it using the statistics for the lifetime number blocks written. The total data written came out to about 998GB– almost exactly the size of the drive!
Upon further investigation, I discovered that nothing was TRIMming the SSD and marking blocks as containing deleted data, so even though the filesystem was only half full, the drive thought it was almost completely full. There are two suggested ways to deal with this: mount the drive with the discard
option, to immediately trim unused blocks, or use a weekly systemd timer that trims the whole filesystem. That timer is provided by util-linux
on Arch but not enabled by default. All it took was
# systemctl enable fstrim.timer [--now]
and the drive is back to its speedy self again.
There are lots of places on the Internet that talk about enabling fstrim
, but I didn’t find any of them while trying to figure out why my drive was running so slow, so I wrote this.