The officially official Devuan Forum!

You are not logged in.

#1 Today 12:29:30

Altoid
Member
Registered: 2017-05-07
Posts: 1,916  

fstrim and HDDs

Hello:

Ever since I put my system on a 2.5" 120Gb SSD, I set up fstrim as per the instructions I found on-line:

$ ls -1 /etc/cron.weekly
--- snip ---
dev-fstrim
--- snip ---
$ 
$ cat /etc/cron.weekly/dev-fstrim
#!/bin/sh
# trim all mounted file systems which support it
# added 20200315
#
# PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
LOG=/var/log/trim.log
echo "On $(date -R):" >> $LOG
/sbin/fstrim -a -v >> "$LOG" 2>&1
$ 

I then took to checking /var/log/trim.log every so often to check that it was working and eventually stopped doing it.
fstrim was doing it's thing and doing it well.
If anything went south, my MTA (not Exim4, DMA*) would let me know.

Today I was looking through the logs and on opening /var/log/trim.log I see that it is also working (?) on a 2.5" 1Tb HDD that I set up inside my box to serve as the first repository of my weekly Clonezilla and daily Timeshift backups.

$ cat /var/log/trim.log
--- snip ---
On Thu, 20 Nov 2025 02:11:33 -0300:
/media/1TB/IMG: 109.2 GiB (117271797760 bytes) trimmed on /dev/sda1
/media/1TB/TS: 159.1 GiB (170784149504 bytes) trimmed on /dev/sda2
/home: 27.2 GiB (29253963776 bytes) trimmed on /dev/sdb6
/var/log: 669.7 MiB (702242816 bytes) trimmed on /dev/sdb5
/: 27.4 GiB (29410951168 bytes) trimmed on /dev/sdb1
$

This was something I was not expecting.
And I understand that fstrim is not for use with HDDs, only for SDDs.

I recall adding the comments to the /etc/cron.weekly/dev-fstrim so I would remember what it was doing and the bit "# trim all mounted file systems which support it" stuck with me and I (incorrectly) assumed that support it meant that fstrim would act only on SSDs.
Unfortunately I neglected to add the link to the source of the data.

Q:
Should I leave things as they are or not?
If not, what to do?

Best,

A.

*Dragonfly Mail Agent  <-- useful reading

Last edited by Altoid (Today 12:33:30)

Offline

#2 Today 13:17:56

g4sra
Member
Registered: 2018-12-12
Posts: 105  

Re: fstrim and HDDs

sudo smartctl -i /dev/sda | grep Rotation

Online

#3 Today 14:02:44

Altoid
Member
Registered: 2017-05-07
Posts: 1,916  

Re: fstrim and HDDs

Hello:

g4sra wrote:
sudo smartctl -i /dev/sda | grep Rotation

Right ...

# smartctl -i /dev/sda
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.1.0-41-amd64] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Blue Mobile (SMR)
Device Model:     WDC WD10SPZX-80Z10T2
Serial Number:    WD-WXD2A70DDH3S
LU WWN Device Id: 5 0014ee 212db172a
Firmware Version: 04.01A04
User Capacity:    1,000,204,886,016 bytes [1.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm                                 ##### <--- HDD / spinning rust
Form Factor:      2.5 inches
TRIM Command:     Available, deterministic                 ##### <--- accepts TRIM 
Device is:        In smartctl database 7.3/5319
ATA Version is:   ACS-3 T13/2161-D revision 5
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:    Tue Nov 25 10:25:51 2025 -03
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
# 

My question was more than anything oriented to the utility of fstrim on spinning rust.
I have read on the web that, while it does no harm, it is also useless.

Edit:
It seems that while the firmware actually accepts the TRIM command, it is ignored.

1A blurb on the web about the WDC WD10SPZX wrote:

---
TRIM is supported, but not actively used: The drive's specifications indicate that clearing unused data (TRIM) is "supported" as part of its general ATA command set (ACS-3). However, TRIM is primarily an optimization feature for SSDs, where it helps manage data blocks to maintain write performance and longevity.

HDD operation: As a traditional HDD with spinning platters and magnetic storage, the WD10SPZX manages data internally through standard garbage collection and wear-leveling algorithms specific to mechanical drives. The TRIM command, while technically part of the command set, does no have the same functional effect as it does on flash-based storage (SSDs).
---

I guess that if fstrim is ignored by the HDD firmware (and does nothing in spite of reporting to the log file), I could leave things as they are.

Thanks for your input.

Best,

A.

Offline

#4 Today 14:58:07

EDX-0
Member
Registered: 2020-12-12
Posts: 179  

Re: fstrim and HDDs

it all depends on the specific hard drive, yours has a firmware scheme that accepts trim but ignores it, others may actively make use of the trim instruction but handle it differently at the firmware/hardware level

Offline

Board footer