There is news about Kernel 6.2 for Btrfs:
The filesystem BTRFS enables
discard=async on some modern SSDs by
default. This is why it does not need to use
See the changelog:
discard=async by default for devices that support it
If You have multiple different filesystems Ext4, XFS and Btrfs …, disabling systemD service
fstrim is not a good idea for all filesystems on multiple SSDs on your same computer.
If You need to fstrim other filesystems e.g. EXT4 and disable fstrim for Btrfs only.
Currently fstrim has no option to ignore any selected filesystem e.g. Btrfs, but there is a trick to exclude Btrfs from fstrim.
How to exclude or ignore Btrfs from fstrim service
$ sudo systemctl edit --full fstrim.service
Change the line:
ExecStart=/usr/bin/fstrim --listed-in /etc/fstab:/proc/self/mountinfo --verbose --quiet-unsupported
ExecStart=/usr/bin/sh -c "/bin/grep -v btrfs /proc/self/mountinfo > /tmp/noBtrfs.mountinfo && /usr/bin/fstrim --listed-in /tmp/noBtrfs.mountinfo --verbose --quiet-unsupported"
Why not use the file directly as an argument to the grep?
Plus i would suggest to use a drop-in to override the original instead…
Below is a little bit enhanced version of what you did but as a drop-in:
By the way according to
It’s much easier to add
X-fstrim.notrim to the mount options in
fstab of the BTRFS volumes you use…
Which would totally remove the need to do all the above…
I like your suggestion. But you do not need to add the first line for fstab, because
mountinfo is sufficient and more flexible than fstab, it can detect when connecting any other external SSD via USB.
Yes, I did not know that before. Thanks for the suggestion. But the default config of fstrim.services uses
mountinfo which collects all mount-points.
fstrim added a new option
-t,--types to filter out by filesystems
11:38AM - 24 Jan 23 UTC
06:04PM - 24 Jan 23 UTC
I read some news about Kernel 6.2: The filesystem BTRFS enables `discard=async`
I literally used the same command as the default service uses, just changed the files it uses, eg. double-collon separated and in same order
You are free to comment-out the first line ofcourse, which would result in only the mountinfo tobe used
(Commenting is done using a
# at line start)
Maybe a weird question, but, how do i know if my device (a ssd pcie4) supports it ?
There are two possible ways to determine if your SSD supports Trim/Discard
$ lsblk --discard
DISC-MAX are not 0, that means your SSD supports it.
$ sudo fstrim --all --dry-run --verbose
It automatically detects if your SSD and some official filesystem support it.
If you use encryption LUKS on your SSD, but Trim/Discard is disabled for LUKS by default.
You can manually enable it.
For internal SSD:
My disk layout is:
nvme0n1 259:0 0 931,5G 0 disk
├─nvme0n1p1 259:1 0 500M 0 part /boot
├─nvme0n1p2 259:2 0 431G 0 part /Windows
└─nvme0n1p3 259:3 0 500G 0 part
└─cryptroot 254:0 0 500G 0 crypt /var/cache
Linux is installed on cryptroot (btrfs).
In fstab I have noatime option, and I have enabled fstrim.timer
Today after a few disk manipulations I did fstrim…
For any external SSD via USB:
Do you get the following message when you try to TRIM your external SSD?
the discard operation is not supported
We can easily overcome this by creating a udev rule in /etc/udev/rules.d
How to do it
Identify the VendorID and ProductID of your device.
in your terminal and locate your external SSD. In my case:
Bus 002 Device 005: ID 04e8:61f5 Samsung Electronics Co., Ltd Portable SSD T5
You’ll see an ID value, mine is 04e8:61f5 The VendorID is the first par…