I have a SanDisk Extreme USB Flash Drive
(http://www.sandisk.com/products/usb/drives/extreme/), which does NOT
support UASP so is running under usb-storage.
According to `hdparm`, it seems to supports TRIM; and according to
`sg3_opcodes`, it seems to support ATA Pass-Through (12/16). However,
all TRIM/DISCARD related ioctl doesn't work with it at all.
So my question is, is TRIM/DISCARD possible at all in linux for usb
drives? If so, what are the requirements? If not, is it just not
implemented yet or an inherit problem of usb which cannot be fixed?
P.S. Although there's an SG_IO error, ATA Secure Erase seems to works
according to hexdump, and the drive is NOT bricked after many trials.
[tom@localhost ~]$ sudo blkdiscard /dev/sdc
blkdiscard: /dev/sdc: BLKDISCARD ioctl failed: Operation not supported
[tom@localhost ~]$ sudo blkdiscard -s /dev/sdc
blkdiscard: /dev/sdc: BLKSECDISCARD ioctl failed: Operation not supported
[tom@localhost ~]$ sudo mount /dev/sdc1 /mnt/
[tom@localhost ~]$ sudo fstrim /mnt/
fstrim: /mnt/: the discard operation is not supported
[tom@localhost ~]$ sudo hdparm -I /dev/sdc
/dev/sdc:
ATA device, with non-removable media
Model Number: SanDisk pSSD
Serial Number: 0a1e4434c
Firmware Revision: 3
Transport: Serial, ATA8-AST, SATA Rev 2.6
Standards:
Used: ATA-8-ACS revision 2d
Supported: 8 7 6 5
Configuration:
Logicalmaxcurrent
cylinders1638316383
heads1616
sectors/track6363
--
CHS current addressable sectors: 16514064
LBAuser addressable sectors: 61282631
LBA48 user addressable sectors: 61282631
Logical Sector size: 512 bytes
Physical Sector size: 512 bytes
device size with M = 1024*1024: 29923 MBytes
device size with M = 1000*1000: 31376 MBytes (31 GB)
cache/buffer size = unknown
Form Factor: 1.8 inch
Nominal Media Rotation Rate: Solid State Device
Capabilities:
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 = 1Current = 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
Commands/features:
EnabledSupported:
*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
*NOP cmd
*DOWNLOAD_MICROCODE
Advanced Power Management feature set
*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
*WRITE_{DMA|MULTIPLE}_FUA_EXT
*64-bit World wide name
*WRITE_UNCORRECTABLE_EXT command
*Segmented DOWNLOAD_MICROCODE
*Gen1 signaling speed (1.5Gb/s)
*Gen2 signaling speed (3.0Gb/s)
*Gen3 signaling speed (6.0Gb/s)
*Native Command Queueing (NCQ)
*Software settings preservation
*DEVICE CONFIGURATION SET/IDENTIFY DMA commands
*Data Set Management TRIM supported (limit 8 blocks)
*Deterministic read ZEROs after TRIM
Security:
Master password revision code = 65534
supported
notenabled
notlocked
notfrozen
notexpired: security count
notsupported: enhanced erase
2min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5001b400e4a14c43
NAA: 5
IEEE OUI: 001b40
Unique ID: 0e4a14c43
Checksum: correct
[tom@localhost ~]$ sudo sg_opcodes /dev/sdc
SanDisk Extreme 0001
Peripheral device type: disk
Opcode ServiceCDBName
(hex) action(h) size
---
00 6Test Unit Ready
03 6Request Sense
04 6Format Unit
08 6Read(6)
0a 6Write(6)
12 6Inquiry
15 6Mode select(6)
1a 6Mode sense(6)
1b 6Start stop unit
1d 6Send diagnostic
1e 6Prevent allow medium removal
23 10Read Format capacities
25 10Read capacity(10)
28 10Read(10)
2a 10Write(10)
2f 10Verify(10)
35 10