Enable SSD TRIM #6271
Replies: 11 comments
|
Can i take this issue |
|
SSD trim is not needed on modern nvmes. So not going to do this setup as a default. But if you'd like to document it for those with vintage hardware, please add it to the discussions under Manual 👍 |
|
Is this accurate? My understanding was modern nvme still require trim but can use continuous trim, discard=async on the partition in fstab. I can't find any documentation saying nvme don't need trim. Does this also apply to usb nvme drives? I have a framework with a usb expansion card holding omarchy. This isn't legacy hardware. Typically, you need to enable trim on usb ssd's manually. |
|
I think there is some misunderstanding about modern nvme drives not needing trim. While technically they will function without it, they will still have all the same negative effects of not using it as older drives, like slowing down massively over time and increased wear. I know there is some discussion about the security implications of using trim on encrypted SSDs, because the wear leveling does technically expose at least some drive use information. But I would say more importantly, not having trim increases other risks, like old LUKS encryption keys not being removed when the password is changed. (More or less what the Arch wiki says). But in terms of basic good SSD maintenance and best performance, the need for trim is still definitely there. |
|
Reopening this with concrete data from a current-gen NVMe. Hardware: WD PC SN5000S 1TB (PCIe Gen 4, shipped in 2024/2025 laptops — not vintage hardware) After a fresh Omarchy install with LUKS encryption, TRIM was completely non-functional. Running
After fixing both, The Arch Wiki explicitly recommends TRIM for all SSDs, including NVMe. Internal garbage collection helps, but it cannot replace TRIM because the controller has no way to know which blocks the filesystem considers free unless told via TRIM/DEALLOCATE. The only legitimate argument against Suggested default for Omarchy:
|
|
I'd be happy to look at a PR for this. |
|
Both achieve the same exact thing, just that one option does it periodically, and the other (already default) does in in batches / semi-real time. If this shows fluctuating output, then it is enabled, which in my case it is on an SSD: If it instead shows different output, it might be up to the timer service which I do not know if it's enabled by default but most probably is, depending on support of the hardware alone. More sources: |
|
Apparently, there is need for a |
Not necessarily true, though. ext4 remembers discarded blocks only since last mount, btrfs never remembers any. So repeated fstrim calls might report already trimmed blocks, or even blocks never touched in entire disk lifetime. |
|
I hit this on a LUKS Omarchy install and tracked it down. The missing TRIM was real and worth fixing, but on my machine a second dm-crypt setting mattered more. Which could be relevant here because #5332 only covers the first one. I wanted to contribute with my numbers, hopefully it will be useful. Problem: the desktop became unresponsive for several seconds at a time whenever I tracked it down to two separate causes. Self-check for anyone reading this: run Cause 1: the SSD had never been TRIMmedZero TRIMs in 17.6 TB of writes, because two independent settings combine to
Together they mean an encrypted Arch install never issues a TRIM, but neither are wrong. I believe it's my bad as Arch user to not enable it manually, but since Omarchy is setting up the LUKS install, maybe it's well placed to set the flag, or at least warn the potentially unaware user that they should take the action. The first
(O_DIRECT means no RAM pre-write. QD8 means eight requests at the same time to keep the drive busy) The drive is rated ~3000 MB/s, so it had degraded to about 3% of spec. Reads were This drive is an older mid-range model, so the degradation here is Throughput was restored, but the freezes continued. Cause 2: dm-crypt's write workqueueThis is what actually froze the desktop. By default dm-crypt hands every write to a single kernel thread called While the system was frozen I sampled that thread's state once a second for twelve Fixed with How I measured it: a bulk writer (4 threads writing hard, simulating the patch) running alongside a small write (simulating the desktop). The measurement is how long the small write had to wait each time (this aims to represent the frozen desktop time).
32× worse tail latency, for 25% less throughput. Worth noting: with the workqueues enabled, typical latency is actually (To be clear about the order: this A/B ran on an already-TRIMmed drive. TRIM End result: a 172 GB Steam staging job that I'd previously had to kill now One implementation note for whoever picks this up: On kernel 6.2+ auto-enabling
|
| Omarchy | 3.8.4, installed 2026-04-19 |
| Kernel | 7.1.4 |
| CPU / RAM | AMD Ryzen 9 7950X (16c/32t) · 64 GB |
| Storage | LUKS2 + btrfs (zstd:3) |
| Drive | XPG SPECTRIX S40G 1TB, Realtek RTS5762, PCIe 3.0 x4 (link verified 8GT/s x4) |
| Rated | 3500 MB/s read / 3000 MB/s write |
| SMART | 1% used, 100% spare, 0 media errors, 17.6 TB written |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
What do you need?
I did a fresh installation of Omachy v3.0.2 on a laptop with an nvme SSD, and SSD TRIM does not seem to be working out of the box. This can result in poor performance and reduced life of my SSD.
My enhancement request is to enable SSD trimming automatically within in the installer, or maybe following a prompt. I understand that Arch Linux does not enable it by default because it can have theoretical security implications (see wiki), but I think that's pretty far fetched, and it's not just me: I believe that basically all Linux distros enable it out-of-the box for systems with full disk encryption, including Ubuntu.
See my investigation below, including how to enable it.
Following the Arch Wiki on SSD TRIM, I can confirm that by default my encrypted root partition is not supporting TRIM (by having zero in the column
DISC-GRAN:And triggering a manual trimming also confirms this:
The fix is documented in the LUKS2 page:
It is persistent, and even starts to work immediately (note the
4Kvalue ofrootand thatfstrimreported trimming the root partition):I am not sure what's the best when it comes to how to actually execute the trimming, but I enabled Periodic TRIM):
Another option would be to use asynchronous discarding through a mount option.
All reactions