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:

6 Likes

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.

3 Likes

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: