Enable TRIM / UNMAP on the Storage Expansion Card

If you’re using a Storage Expansion Card (SEC) like I do to house your root file system, you may want to enable TRIM / UNMAP on it. It seems like Linux is currently unaware that this device supports TRIM / UNMAP and it doesn’t enable it by default. Not to worry, all you need to do in order to enable it is to add a udev rule:

echo 'ACTION=="add|change", ATTRS{idVendor}=="13fe", ATTRS{idProduct}=="6500", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"' | sudo tee /etc/udev/rules.d/10-framework-sec-trim.rules

Restart your Framework for the change to take effect.

This rule works for the 1TB SEC. If you have another model check the vendor and product IDs using lsusb and replace them in the command if they differ.

PS: LVMRAID mirror between an NVMe drive and the SEC works just fine :grin:


And what benefits does this bring?

Was gonna type something up but it turns out Crucial explains it well enough here. In a single sentence - if you want your SSD to keep writing quickly over time and last long, especially when the data is encrypted before it’s written (the controller can’t tell a used from unused piece of data), you want to have TRIM working.


Tangentially related, but do you know if UNMAP is exposed through the microSD expansion card? In my experience, built-in SD readers do expose it, but USB readers don’t.

Unfortunately I don’t know. Don’t have the reader.

As the expansion cards are connected via USB C, you are going to be using a USB based reader. I don’t think this is definitive on whether it supports UNMAP, but just for your information.

@lightrush By the way, this is valid for almost every USB SSD that you attach under Linux. Don’t know why, but by default there is no TRIM enabled for external SSDs under Linux.

While doing the research on this, I found some reports claiming that doing TRIM on some devices that don’t support it ended up erasing part of their firmware. I don’t know how veritable that is but if at all possible, then we probably have to enable it on case-by-case basis. Unfortunately. :expressionless:

Is it possible to use the command(change the framework to other names) work on any other external known SSDs(not flash memory USB thumb drive)?

Read the post right above yours. It may not be safe on all drives.

I have an SSD reused from an older laptop as a portable drive (Samsung 870 QVO) and it trimmed successfully. How I can only trim this on Windows and if the drive is formatted as NTFS, I can’t trim on Linux even if I format this drive as ext4