1

I'm setting up a server running Ubuntu Precise, and I'm trying to verify if SSD TRIM is working.

fstrim is failing:

~  sudo fstrim -v /
fstrim: /: FITRIM ioctl failed: Operation not supported

So I tried wiper.sh in hdparm:

wiper-3.5  sudo ./wiper.sh --verbose  --commit /dev/sda1

wiper.sh: Linux SATA SSD TRIM utility, version 3.5, by Mark Lord.
rootdev=/dev/sda1
fsmode2: fsmode=read-write
/: fstype=ext4
freesize = 169502088 KB, reserved = 1695020 KB
Preparing for online TRIM of free space on /dev/sda1 (ext4 mounted read-write at /).

This operation could silently destroy your data.  Are you sure (y/N)? y
Creating temporary file (167807068 KB)..
Syncing disks..
Beginning TRIM operations..
get_trimlist=/sbin/hdparm --fibmap WIPER_TMPFILE.11503

/dev/sda:
trimming 3211263 sectors from 64 ranges
succeeded
trimming 3571713 sectors from 64 ranges
succeeded
trimming 3915776 sectors from 64 ranges
succeeded
(...)
trimming 3657913 sectors from 60 ranges
succeeded
Removing temporary file..
Syncing disks..
Done.

It seems to be working, but I'm wondering if it really is. Are there any cases where wiper.sh should work when fstrim isn't? Is there any way I can check if the TRIMing actually has succeeded (other than trusting the wiper.sh-log)?

Kernel version: Linux 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

2 Answers2

1

What version kernel are you running? The FITRIM ioctl was added around Aug 2010, so older kernels won't have it. My guess would be that wiper.sh is using a different method of trimming, which is why it would work without the ioctl.

  • Thanks for the suggestion. The kernel version is Linux 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux (I've updated my question with that). I have got fstrim working on another machine with the same kernel, thought with different hardware. – Aleksander Blomskøld Oct 09 '12 at 04:21
0

fstrim uses kernel interfaces to speak to the drive and if your kernel does not know how to send the TRIM command to the drive, fstrim will emit Operation not supported. (For example, some drives need TRIM to be translated to UNMAP or DISCARD.)

On the other hand, hdparm directly speaks to your storage device without kernel support (which is the reason it always needs to be run by root). As a result, it may support devices that kernel (yet?) does not know well enough to support. The wiper.sh script is just a frontend for hdparm so that you don't need to manually compute and enter the sector numbers.

I believe that if you're running any recent Linux kernel, then TRIM should be supported if the device is directly connected to the system. However, the kernel may not support TRIM for your device if it's connected over USB using SAT over UAS/UASP bridge.

Note that nowadays you may need to execute TRIM on HDDs, too, because SMR HDD drives will have better performance if big blocks can be discarded.

Mikko Rantalainen
  • 858
  • 12
  • 27