Kernel 6.2 BTRFS and TRIM

Anyone testing Kernel 6.2 with BTRFS ?

I would like to know if the discard=async option is now the default mount option for BTRFS, as mentioned in a Phonorix article.

I suppose a mount | grep btrfs would show if it is active or not.
If so, what should we do with fstrim.timer ? Should we disabled it once we start to use 6.2 ?

I installed the the 6.2 kernel a while back from testing on btrfs and didn’t know anything regarding this?

[ricklinux@eos-plasma ~]$ mount | grep btrfs
/dev/nvme1n1p2 on / type btrfs (rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=443,subvol=/@)
/dev/nvme1n1p2 on /home type btrfs (rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@home)
/dev/nvme1n1p2 on /swap type btrfs (rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=260,subvol=/@swap)
/dev/nvme1n1p2 on /var/cache type btrfs (rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@cache)
/dev/nvme1n1p2 on /var/log type btrfs (rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@log)
[ricklinux@eos-plasma ~]$ 

Let me know on this? I don’t know either? I’m just not very familiar with all btrfs!

hmm, so discard=async is being used.
Do you mind showing your /etc/fstab ?

Edit: More details about it:

[ricklinux@eos-plasma ~]$ cat /etc/fstab
# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=7DD4-731C                            /boot/efi      vfat    defaults,noatime 0 2
UUID=d2451021-8cca-4935-b73b-ba725647fcdd /              btrfs   subvol=/@,defaults,noatime,compress=zstd 0 0
UUID=d2451021-8cca-4935-b73b-ba725647fcdd /home          btrfs   subvol=/@home,defaults,noatime,compress=zstd 0 0
UUID=d2451021-8cca-4935-b73b-ba725647fcdd /var/cache     btrfs   subvol=/@cache,defaults,noatime,compress=zstd 0 0
UUID=d2451021-8cca-4935-b73b-ba725647fcdd /var/log       btrfs   subvol=/@log,defaults,noatime,compress=zstd 0 0
UUID=d2451021-8cca-4935-b73b-ba725647fcdd /swap          btrfs   subvol=/@swap,defaults,noatime 0 0
/swap/swapfile                            swap           swap    defaults   0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
[ricklinux@eos-plasma ~]$ 

Edit: I never changed anything. I just installed the 6.2 kernel from the testing repo. Been running it for a while.

This is on an nvme drive. I do have an ssd which probably would be the same if it is installed on that?

Async discard will be turned on automatically for SSDs unless using the new “async=nodiscard” mount option for forcing off the support.

hm, so that article was correct, this means that TRIM/discard is running by default now.

To disabled it, according to that article, you would need to use async=nodiscard mount option in /etc/fstab.

Not sure if we can run fstrim.timer along with that option. Perhaps no harm done or should we disable fstrim.service ?
Or maybe disable discard=async with the option async=nodiscard and keep fstrim.timer running ?

1 Like

I think so, I’m not sure if the Kernel checks if the drive supports TRIM and enable that option, or if its something that it’s done without checking compatibility of the drive.
Btw, I believe that most SSD drives support it.

Edit: I’m using discard=async since last year, with fstrim.disabled, it is safe or at least safe for my use case.
So, when people get Kernel 6.2, they would need to choose if they want systemd timer for fstrim or disable it and use the asynchronous mode which will be the default for that Kernel.
I don’t think that you should use both at the same.

The difference for me now is that I don’t need that option in my fstab anymore since will be the default.
Thanks ricklinux for showing your /etc/fstab and clarifying that the defaults really changed for this matter.

1 Like

Do you have any non-btrfs partitions/disks that need to be trimmed?

IMO, an extra trim once per week is not really material so I leave the timer enabled.


I have a NTFS mount in which I almost don’t use in Linux, its mounted but usually Windows take care of it during system maintenance.
Sometimes I copy a file to it so I can access in both systems, but it’s not that usual for me to do it.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.