SSD upgrade - TRIM command required?

Hi

I’ve upgraded to an (Samsung T5), updated my fstab entry to new UUID … do i need to worry about TRIM commands or schedule to keep it ticking over? I’m using ext4.

Cheers, Geoff.

Running fstrim from time to time doesn’t harm

thx. what about a discard or any other fstab entries?

Might be set already, can check with mount

thx

I’ve added discard to my fstab, but when i run fstrim i get an message that discard not supported.

sudo fstrim /mnt/storage-fstab/

fstrim: /mnt/storage-fstab/: the discard operation is not supported

Here is my logic:

  1. My SSD (USB Samsung T5) supports TRIM under ext4
  2. my fstab has discard option
  3. mount reports entry in fstab
    /dev/sda1 on /mnt/storage-fstab type ext4 (rw,nosuid,nodev,noexec,noatime,discard,data=ordered,user)
  4. fstab - UUID=d46a5822-90cc-48d4-9a27-8fd20cdf0563 /mnt/storage-fstab ext4 auto,nofail,user,noexec,rw,async,noatime,discard 0 0

did i miss a step?

Cheers, Geoff

Hi,

Not all SSDs support trim, you should be able to check with:

sudo hdparm -I /dev/sda | grep TRIM

Thanks Tom.

While you haven’t actually provided any evidence for this, a quick search suggests that it should be supported in the T5.

However, I came across this thread: TRIM support for USB drives? | The FreeBSD Forums While it’s from a FreeBSD forum, there was this:

It turned out that the cause of the problem is that FreeBSD does not support UAS / UASP. That’s a newer USB protocol for accessing storage devices. Well, “newer” means it was introduced as part of USB 3.0 in 2010. It’s supported by all major OS like Windows, Linux, MacOS, and even uncommon ones like Solaris. That’s also the reason why the Samsung T5 SSDs are five times faster (!) in Windows and Linux. Also, NCQ and TRIM support works fine with Windows and Linux, but does not work with FreeBSD because it requires UAS / UASP.

I can’t find any evidence that the Vero4K supports UAS (modinfo comes up blank) and the Pi 2/3 version of the OSMC kernel config contains the line CONFIG_USB_UAS is not set, suggesting that the older Vero4K kernel is unlikely to support it.

This thread How can I check whether USB3.0 UASP (USB Attached SCSI Protocol) mode is enabled in Linux? - Super User shows how to see if the uas driver is being used.

1 Like

thx Tom

does this output mean ssd and 4K+ Vero OSMC support trim ? I think it looks good, but i’m not sure how to interpret the first line below …

       *    Data Set Management TRIM supported (limit 8 blocks)                                                                            
       *    Deterministic read ZEROs after TRIM

Cheers, Geoff

It seems that UAS/UASP isn’t supported on the Raspberry Pi 2/3. Does Raspberry Pi 3 B+ support UASP? - Raspberry Pi Forums

While UAS can theoretically be implemented on USB 2.0, it will depend on the Vero4K’s hardware capabilities. USB Attached SCSI - Wikipedia. I think @sam_nazarko will be best placed to answer this one.

We use the same DesignWare OTG IP block for USB; so the same limitations exist.

Sam

thanks, does ‘OTG IP block limitations’ that mean my SSD with Vero4K+ doesn’t support the TRIM command?

Is there a TRIM package i can download?

If i can’t get TRIM to work then I’m assuming that my SSD will become quite cluttered with junk and will stop working at some point.

Thanks, Geoff.

You can use tune2fs to set the discard flag on the filesystem itself instead of relying on adjusting /etc/fstab.

UAS isn’t supported, but TRIM should work.
Does fstrim work when you run it on your drive (i.e. /dev/sda1)?

Sam

thx,

i get the ‘discard operation is not supported’ msg.

cheers, Geoff.

Run fstrim and see if it does anything. This is a periodic trim.

here is what i have done …

  1. edited fstab and removed discard
  2. added discard via tune2fs sudo tune2fs -o discard /dev/sda1, resultant -l output:
    tune2fs 1.43.4 (31-Jan-2017)
    Filesystem volume name: 1.42.6-24922
    Last mounted on: /mnt/storage-fstab
    Filesystem UUID: d46a5822-90cc-48d4-9a27-8fd20cdf0563
    Filesystem magic number: 0xEF53
    Filesystem revision #: 1 (dynamic)
    Filesystem features: has_journal ext_attr resize_inode filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra
    _isize
    Filesystem flags: unsigned_directory_hash
    Default mount options: user_xattr acl discard
    Filesystem state: clean
    Errors behavior: Continue
    Filesystem OS type: Linux
    Inode count: 61054976
    Block count: 244189976
    Reserved block count: 0
    Free blocks: 24878603
    Free inodes: 61047885
    First block: 0
    Block size: 4096
    Fragment size: 4096
    Reserved GDT blocks: 965
    Blocks per group: 32768
    Fragments per group: 32768
    Inodes per group: 8192
    Inode blocks per group: 512
    Flex block group size: 16
    Filesystem created: Wed Oct 23 17:04:32 2019
    Last mount time: Sun Oct 27 08:22:08 2019
    Last write time: Mon Oct 28 07:52:45 2019
    Mount count: 15
    Maximum mount count: -1
    Last checked: Wed Oct 23 17:04:32 2019
    Check interval: 0 ()
    Lifetime writes: 1041 GB
    Reserved blocks uid: 0 (user root)
    Reserved blocks gid: 0 (group root)
    First inode: 11
    Inode size: 256
    Required extra isize: 28
    Desired extra isize: 28
    Journal inode: 8
    Default directory hash: half_md4
    Directory Hash Seed: 929a2024-baa0-4a85-b2e7-a4b6a60c6682
    Journal backup: inode blocks
  3. sudo fstrim /dev/sda1: output: fstrim: /dev/sda1: not a directory
  4. sudo fstrim /mnt/storage-fstab fstrim: output: the discard operation is not supported

Cheers, Geoff.

Looks like TRIM is not active here then

Sam

thx, by not active do you mean my drive doesn’t support TRIM?

i ran Tom’s suggested command sudo hdparm -I /dev/sda | grep TRIM, and output does suggest TRIM support, but i’m not sure.

Data Set Management TRIM supported (limit 8 blocks)
Deterministic read ZEROs after TRIM

Cheers, Geoff.

I’m not sure either – I also believe it’s dependent on the caddy used.

thanks. I think your post was spot on … just took a bit of research on my part to actuals understand the requirement for UAS / UASP.

Cheers for the info.

Geoff.

Thanks for the feedback. I don’t have a USB SSD (yet) so couldn’t test anything out for myself but quickly came to the conclusion that TRIM requires UAS/UASP – which isn’t currently available on OSMC.

Perhaps it’ll finally arrive on the Pi 4, which comes with two USB3 ports. STICKY: If you have a Raspberry Pi 4 and are getting bad speeds transferring data to/from USB3.0 SSDs, read this - Raspberry Pi Forums (I don’t have a Pi 4, either. :wink: )

1 Like