I’m wondering if there is any “house keeping” to be done if you have BTRFS as your file system. I currently have it installed (Manjaro KDE) and I noticed that deleting files is slow (not how it used to be). I have a decent SSD for anyone wondering. I noticed the same slowness on my laptop (Also Manjaro KDE). I’m wondering if this has to do with BTRFS or if it’s something else?
It is probably caused by something else, unless you have the filesystem mounted with the sync
option, and/or with the discard
option. Check your /etc/fstab
for those two mount options, and if they are present, remove them.
Rationale:
-
discard
is deprecated. Enabling thefstrim.timer
is much better. -
The default mount options for filesystems on an SSD or an HDD include
async
, which buffers the writes. This is much more efficient thansync
, which immediately commits all write operations to the drive.
Here is what I have in my fstab
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=A077-8C9B /boot/efi vfat umask=0077 0 2
UUID=1949a224-fc40-4844-9b85-9bac441667b0 / btrfs subvol=@,defaults,noatime,space_cache 0 1
UUID=1949a224-fc40-4844-9b85-9bac441667b0 /home btrfs subvol=@home,defaults,noatime,space_cache 0 2
UUID=34bde0d2-cd72-49fd-8d42-585fce212fbf swap swap defaults,noatime 0 0
/dev/sdb1 /Media/D auto nosuid,nodev,nofail,x-gvfs-show 0 0
To make sure, you saying to add fstrim.timer
and async
to the options for the btrfs partitions?
No, not at all. async
is already in effect ─ it is part of the defaults
─ and fstrim.timer
isn’t a mount option; it’s a systemd
timer. Chances are that it’s already running on your system. You can easily check that…
[nx-74205:/dev/pts/3][/home/aragorn]
[04:17:29][aragorn] > systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
Loaded: loaded (/usr/lib/systemd/system/fstrim.timer; enabled; vendor preset: disabled)
Active: active (waiting) since Wed 2022-01-12 19:59:42 CET; 4 days ago
Until: Wed 2022-01-12 19:59:42 CET; 4 days ago
Trigger: Mon 2022-01-24 01:23:28 CET; 6 days left
Triggers: ● fstrim.service
Docs: man:fstrim
Jan 12 19:59:42 nx-74205 systemd[1]: Started Discard unused blocks once a week.
[nx-74205:/dev/pts/3][/home/aragorn]
[04:17:42][aragorn] >
Note: If it’s not running, start it as follows…
sudo systemctl enable --now fstrim.timer
But that all said, I don’t see any immediate reason as to why you report that your system is slow at deleting files.
On a side note, you really shouldn’t mount this with this type of identifier, this is unreliable, as the other mounts, use the UUID instead of /dev/sdb1
I suggest to remove space_cache
Please have a look at
https://btrfs.readthedocs.io/en/latest/Administration.html
And an aditional Question:
- Do you use snapshots?
- How many ?
- Do you clean them up ?
Please provide:
sudo sudo btrfs device usage /
Btrfs
Thank you and everyone else for the suggestions I will apply them. I do have fstrim.timer
running in systemd.
I have 6 snapshots. If by clean you mean delete old ones, yes. I just reduced it to 2 snapshots.
here is the paste:
/dev/nvme0n1p2, ID: 1
Device size: 228.39GiB
Device slack: 0.00B
Data,single: 139.01GiB
Metadata,single: 5.01GiB
System,single: 4.00MiB
Unallocated: 84.38GiB
I do have 60 Snapshots of / and 40 of /home and my Unallocated is at 50%
When keeping snapshots, you have to watch closely this value. It should never go under 10% of your device size
When you got under 10% (accidentally), an balance (once) may improve performance. But before balancing it is good to get over 10%