I am running ubuntu 18.04. No lvm or encryption. I am attempting to run trim on a brand new external sdd, western digital wd green 120 gb in a usb external case ADATA ED600 that shows trim available on hdparm.

yet fstrim reports

sudo fstrim -v /media/****/644f7d88-df12-4d0e-9423-bdf787d0fd78 

fstrim: /media/****/644f7d88-df12-4d0e-9423-bdf787d0fd78: the discard operation is not supported

I cannot figure out what else I could do to get fstrim to run.

hdparm output below.

****:~$ sudo hdparm  -I /dev/sdb


ATA device, with non-removable media
    Model Number:       WDC WDS120G2G0A-00JH30                  
    Serial Number:      1821B3802831        
    Firmware Revision:  UE450000
    Media Serial Num:   
    Media Manufacturer: 
    Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
    Used: unknown (minor revision code 0x0110) 
    Supported: 9 8 7 6 5 
    Likely used: 9
    Logical     max current
    cylinders   16383   0
    heads       16  0
    sectors/track   63  0
    LBA    user addressable sectors:   234455040
    LBA48  user addressable sectors:   234455040
    Logical  Sector size:                   512 bytes
    Physical Sector size:                   512 bytes
    Logical Sector-0 offset:                  0 bytes
    device size with M = 1024*1024:      114480 MBytes
    device size with M = 1000*1000:      120040 MBytes (120 GB)
    cache/buffer size  = unknown
    Form Factor: 2.5 inch
    Nominal Media Rotation Rate: Solid State Device
    LBA, IORDY(can be disabled)
    Queue depth: 32
    Standby timer values: spec'd by Standard, no device specific minimum
    R/W multiple sector transfer: Max = 1   Current = 1
    Advanced power management level: disabled
    DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
         Cycle time: min=120ns recommended=120ns
    PIO: pio0 pio1 pio2 pio3 pio4 
         Cycle time: no flow control=120ns  IORDY flow control=120ns
    Enabled Supported:
       *    SMART feature set
            Security Mode feature set
       *    Power Management feature set
       *    Write cache
       *    Look-ahead
       *    Host Protected Area feature set
       *    WRITE_BUFFER command
       *    READ_BUFFER command
            Advanced Power Management feature set
            SET_MAX security extension
       *    48-bit Address feature set
       *    Device Configuration Overlay feature set
       *    Mandatory FLUSH_CACHE
       *    FLUSH_CACHE_EXT
       *    SMART error logging
       *    SMART self-test
       *    General Purpose Logging feature set
       *    64-bit World wide name
       *    WRITE_UNCORRECTABLE_EXT command
       *    {READ,WRITE}_DMA_EXT_GPL commands
       *    Segmented DOWNLOAD_MICROCODE
            unknown 119[8]
       *    Gen1 signaling speed (1.5Gb/s)
       *    Gen2 signaling speed (3.0Gb/s)
       *    Gen3 signaling speed (6.0Gb/s)
       *    Native Command Queueing (NCQ)
       *    Phy event counters
       *    READ_LOG_DMA_EXT equivalent to READ_LOG_EXT
            Device-initiated interface power management
            Software settings preservation
            Device Sleep (DEVSLP)
       *    SANITIZE feature set
       *    BLOCK_ERASE_EXT command
       *    WRITE BUFFER DMA command
       *    READ BUFFER DMA command
       *    Data Set Management TRIM supported (limit 8 blocks)
       *    Deterministic read data after TRIM
    Master password revision code = 65534
    not enabled
    not locked
    not frozen
    not expired: security count
    not supported: enhanced erase
Logical Unit WWN Device Identifier: 5001b448b60a0235
    NAA     : 5
    IEEE OUI    : 001b44
    Unique ID   : 8b60a0235
Device Sleep:
    DEVSLP Exit Timeout (DETO): 50 ms (drive)
    Minimum DEVSLP Assertion Time (MDAT): 31 ms (drive)
Checksum: correct

additional comments

eventually got it to work.

****:/media$ sudo hdparm --user-master u --security-set-pass 123456 /dev/sdb
security_password: "123456"

 Issuing SECURITY_SET_PASS command, password="123456", user=user, mode=high
****:/media$ sudo hdparm --user-master u --security-erase 123456 /dev/sdb
security_password: "123456"

 Issuing SECURITY_ERASE command, password="123456", user=user
SG_IO: bad/missing sense data, sb[]:  70 00 01 00 00 00 00 0a 00 00 00 00 00 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

It waits for some 10 seconds and returns with no further information. The security "enabled" flag turns to "not enabled". I am assuming that does the trick.


1 Answer 1


There are USB enclosures on the market that support trim. For example if your enclosure uses the JMICRON JMS583 chip then it supports trim. I don't know if yours does or not, but if it does:

Hare are the steps required to get it to work if it is supported, but if you want a more detailed walk-through see the source link below.

  1. Get the vendor and product ids from lsusb
  2. Create /etc/udev/rules.d/50-usb-ssd-trim.rules with the following content, but change the vendor and product ids to match the ones found in step 1:
ACTION=="add|change", ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0583", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
  1. Reload the udev configuration sudo service udev force-reload
  2. Make sure you don't have the USB enclosure mounted and then replug the USB enclosure.
  3. You can check if trim is supported with lsblk --discard /dev/sda

See: https://www.glump.net/howto/desktop/enable-trim-on-an-external-ssd-on-linux

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.