10

I have two external USB 3.0 SSD drives from Samsung (one is Model T1, other T3).

I would like to trim them with my Ubuntu 16.04.1 LTS.

While doing that I receive a error message. Here an example:

sudo fstrim -v  /media/techo/Samsung_T3
fstrim: /media/techno/Samsung_T3: the discard operation is not supported

But the device support the TRIM Command:

techno@server:~$ sudo hdparm -I /dev/sdb |grep -i TRIM
       *    Data Set Management TRIM supported (limit 8 blocks)

thx. What do I wrong?

luckyrings

  • 1
    fstrim via USB is not supported as discussed extensively here: https://ubuntuforums.org/showthread.php?t=2315800 – WinEunuuchs2Unix Dec 14 '16 at 17:49
  • Irregardless of whether drive supports trim, when connected thru usb you can't run a trim command as it's a SATA command. Case closed... – doug Dec 14 '16 at 17:52
  • Plus - any high quality usb3 ssd should be able to handle garbage collection on it's own. – doug Dec 14 '16 at 17:58
  • 3
    I don't think so, that USB generally does not support it. Trim should work via USB Attached SCSI Protocol. Question is if USAP is proper implemented in Linux - https://en.wikipedia.org/wiki/USB_Attached_SCSI – Luckyrings Dec 15 '16 at 19:39
  • 3
    Maybe fstrim does not support USAP. But the Samsung SSD T3 Portable drive support USAP. While in Windows 8+ it connects with USB Attached SCSI (UASP), enabling advanced functionality like NCQ and TRIM (SCSI Unmap). So what about Linux now? – Luckyrings Dec 15 '16 at 19:45
  • 7
    I second that. Trim works over USB and should definitely work on linux. The attitude of the user @doug is really unacceptable. – Pa_ Aug 06 '17 at 16:09
  • According to https://support.wdc.com/knowledgebase/answer.aspx?ID=26014 Western Digital external SSDs and HDDs support UNMAP which is considered equal to TRIM command. Does anybody have any info about if Seagate or other manufacturers support such a thing and if so, which software I can use under Linux? I'm prefer running fstrim over having discard mount option. – Mikko Rantalainen Dec 17 '18 at 05:13
  • Looking more about this it seems that the discard mount option and fstrim both need kernel support for "discard operation" which is only supported for USB-SATA bridges that support SCSI UNMAP command and map that to SATA DISCARD. Technically it should be possible to speak over USB-UAS-SCSI-SAT-SATA and directly send DISCARD as ATA command but Linux kernel does not support that. If you don't need LVM or LUKS, you may be able to use wiper.sh (part of hdparm) script that uses raw ATA commands. – Mikko Rantalainen Jan 01 '19 at 21:42
  • 1
    @doug disagree. I got an sdcard supporting discard and fstrim works in that case through an usb reader. – user2284570 Feb 02 '21 at 10:13
  • See answer 262154 for adding a udev rule to pick up the device (which claims to support UASP, but fstrim fails). – ubfan1 Jun 19 '24 at 04:14

1 Answers1

6

USB drives use a USB<>SATA translation via an IC. Different ICs offer slightly more or less SATA command translations. They all translate the SATA commands required for typical disk usage.

So, the hdparm -I (inquiry) command will work. It will tell the user that 'trim' is supported. But that doesn't mean the USB<>SATA translation includes translating the trim command.

It isn't that the inquiry -I command gives incorrect information. The USB<>SATA translation chip just isn't designed to translate the trim command. If enough users complain, something might be done to make the translations more complete.

Brian
  • 374
  • I recently learned, after speaking at length with tier-one tech support at Startech, that USB<>SATA and USB<>NVME translation ICs (bridges) run a tiny blob of firmware that can be updated to add more translations. – Brian Nov 25 '21 at 04:08
  • That comment is very interesting! I've got a Startech adapter, and I wonder how you can get this upgrade? Note that this source claims that In Debian GNU/Linux TRIM is disabled by default on USB connected SSDs. I'm now using a udev rule to overcome the limitation! Based on your information (adapter chip translation doesn't pass TRIM), I don't quite understand why this udev rule works. A real f***g mystery!! PS recommend you add yr comment to yr answer. – Seamus Apr 05 '25 at 00:52