You are not logged in.

#1 2024-07-06 07:28:28

mber
Member
Registered: 2024-07-06
Posts: 1

SSD Trimming with BTRFS and LUKS

My SSD has been hanging. Today it got very bad, programs started crashing and the system became un-usable. After some investigation, I determined that the trim feature is not enabled and this is likely the cause.

I am using BTRFS under a LUKS partition, which are the default settings from the arch installer script.

I'm seeing some conflicting information in the manuals and wiki regarding the trimming feature. As of kernel 6.2 BTRFS has trimming enabled by default. LUKS has trimming disabled by default. Given that the LUKS partition wraps the BTRFS, I would assume that by default trimming is therefore not enabled.

I am using the encrypt hook so I would now add: `cryptdevice=/dev/nvme1n1p2:root:allow-discards` to my systemd-boot settings. After this, would I then need to do anything further to enable trimming? With the BTRFS default, I would imagine that trimming would be turned on this way, but I'm not sure how these two defaults interact. Is this assumption correct?

e: I added allow-discards to my kernel options and rebooted. A dry run of fstrim returns 0 B trimmed, so I think this is maybe not sufficient.

e: It seems that the dry run doesn't actually trim anything and will always say 0 B trimmed. I did a proper run and it trimmed hundreds of GB so that's good news.

However, I still don't know if the BTRFS auto trim is enabled or not. How would I check?

e: `cat /proc/mounts | grep discard` seems to show it as enabled with `discard=async`. I guess it just did not get around to running the trim before I executed the manual fstrim. Does that sound right?

Last edited by mber (2024-07-06 08:06:19)

Offline

#2 2024-07-06 09:33:42

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,223

Re: SSD Trimming with BTRFS and LUKS

Your SSD/programs ran from it should not start crashing just because it hasn't been trimmed in a while and they normally do a bunch of internal housekeeping anyway.

Generally speaking, "plain" filesystem level discards are often not sufficient because they don't actually trigger the TRIM command the SSD responds to in order to do internal housekeeping. But even so I'd strongly doubt your issues are related to that.

Offline

#3 2024-07-06 09:53:13

ua4000
Member
Registered: 2015-10-14
Posts: 558

Offline

Board footer

Powered by FluxBB