Btrfs as the default filesystem in Manjaro 25.0 — advice for new installations

Ever since Manjaro 25.0.0 Zetar, unless one has chosen differently, the default filesystem upon a fresh installation of Manjaro is btrfs.

btrfs is a very modern and robust filesystem with an integrated volume manager. Among its many features are…

  • It uses B-trees (“balanced trees”) for just about everything, which means that it’s very fast.

  • It will auto-detect whether the underlying storage device is an SSD or a HDD, and will automatically enable certain optimizations if the underlying device is an SSD. This includes (among other things) the default activation of the discard=async mount option — i.e. a queued TRIM operation — even if it is not explicitly set in the mount options.

  • It is copy-on-write. In other words, whenever a file is changed, the file is not overwritten in its entirety, but instead only the modified blocks are written to the drive. On HDDs, this may lead to fragmentation over time, but btrfs has an autodefrag mount option. btrfs will also attempt to avoid fragmentation in the first place by allocating contiguous blocks for data that is yet to be written to the storage device, and it uses delayed allocation, just in case the data is changed in memory before being written out.

  • btrfs supports transparent inline compression via zlib, lzo and zstd, whereby it will recognize the compression algorithm used on already existing files. New files will be compressed with the default algorithm as specified in the mount options.

  • btrfs supports subvolumes. btrfs subvolumes largely behave as if they were individual partitions, and can thus be mounted with their own dedicated mount options per subvolume, although some mount options — e.g. space_cache — must always be shared with the parent filesystem itself.

  • Unlike with separate partitions or lvm2 logical volumes, btrfs subvolumes can be nested — in other words, you can have subvolumes within subvolumes, within yet other subvolumes, and so on — and all subvolumes share the total amount of available free space on the filesystem.
    (Note: Unlike partitions, lvm2 logical volumes or zfs subvolumes, btrfs subvolumes are not block devices and cannot be treated that way.)

  • btrfs subvolumes can be snapshotted with tools like timeshift and/or snapper, in order to create rollback points to a previous version of your subvolume(s). This process — as well as the restoring — is very fast, because it relies on the copy-on-write principle.

  • Subvolumes — and snapshots, which themselves are also subvolumes — can be exported to another storage device via “btrfs send” and “btrfs receive”. (Note: They need to be read-only snapshots, i.e. created with the -r flag.)

  • Snapshots can also be used as seeds to populate a new subvolume in a way similar to how unionfs works.

  • In combination with grub-btrfs, it is possible to boot into a (read-only) earlier and working snapshot of your system in the event that you’ve managed to break your system somehow, and to then quickly restore your system from the working snapshot.

  • btrfs maintains checksums on both data and metadata.

  • btrfs supports RAID levels 0, 1 and 10, as well as data deduplication and file cloning.

  • btrfs allows for multiple physically separate filesystems to be combined into a single logical volume.


However, for those new to btrfs, there are a few things to pay attention to. I will list them below.

  • If you find that the command locate does not work, edit the file /etc/updatedb.conf and change the line… :point_down:

    PRUNE_BIND_MOUNTS = "yes"
    

    … into…

    PRUNE_BIND_MOUNTS = "no"
    

    The explanation here lies with how btrfs subvolumes are mounted, which to the system is very similar to a bind-mount. As such, with PRUNE_BIND_MOUNTS set to “yes”, updatedb will ignore any data residing on btrfs subvolumes.


  • If your /boot directory resides on a btrfs filesystem, then you should comment out — i.e. put a “#” in front of the line — all of the compression-related options in /etc/mkinitcpio.conf, and add the following line below them… :point_down:

    COMPRESSION=cat
    

    After this you will need to rebuild your initramfs with… :point_down:

    sudo mkinitcpio -P
    

    The change will persist for future system updates.

    The explanation for this lies with the fact that btrfs already uses compression of its own, and having two compression algorithms running against the same file may actually yield a file that’s bigger than if it were not compressed at all. Therefore, you do not want mkinitcpio compressing your kernel image and your initramfs when you’re already using the compression built into btrfs.


  • Due to how btrfs physically organizes the data on disk, you may at some point find that you’re running out of disk space even if you still have plenty of free space according to the traditional tools — e.g. df.

    This is however easily remedied by running a “btrfs balance” operation, which will relocate and spread out the data and/or metadata to physically different storage blocks on your drive. This can be done manually, or automatically in the background — for an automatic balancing, you need to have the btrfsmaintenance package installed, which will run a number of scheduled maintenance tasks on your filesystem (if enabled).


  • In line with the above, the btrfsmaintenance package also allows you to enable a timed “btrfs scrub”, which checks the metadata on your filesystem for consistency and will repair it if necessary. It is recommended to run a scrub once a month, although once a week is also acceptable.

    You can do this manually or via the timed execution in btrfsmaintenance. Both the scrub and balance operations are atomic, interruptible — e.g. because you shut down the computer while it was running, or because there was a power outage — and will always leave the filesystem in a consistent state. If the machine was shut down during the operation, then it will resume upon the next boot-up.


In closing, nothing changes for existing installations on different filesystems — the default up until now having been ext4 — and people new to Manjaro can still opt for ext4 (or another Linux-native filesystem) at installation time if they choose to, by selecting manual partitioning in the calamares installer.

:vulcan_salute:

21 Likes

I have a question about the automated TRIM function via discard=async: Does this discard=async make the weekly TRIM with fstrim.timer unnecessary?

I switched to btrfs a few months ago. In my experience btrfs is slightly slower than ext4. For me, disabling copy-on-write for a few directories helped. Btrfs is still a good choice and I have stayed with it, but if absolute performance is important then it might not be best choice for everyone.

If RAID is not enabled, scrub can only detect that the data is corrupted (more so than other file systems). BTRFS cannot repair anything with scrub .

unless you have RAID 1 enabled in BTRFS.

Wiki: → btrfs RAID1

If RAID 1 is enabled, corrupted data is detected every time a data block is read and repaired using the “good copy on the other drive”. This only happens for data that is actually read.

Wiki: → btrfs scrub

Scrub causes all data to be read “uselessly”. However, this triggers the automatic repair of this data.

:footprints:

Hello everyone, I used BTRFS for a long time, it has a lot of advantages, but there are also disadvantages

  1. Low disk speed compared to Ext4
  2. In my opinion, BTRFS kills the SSD disk resource faster
  3. When I got a failure, I could not restore data
    I have an old computer, and as far as I know in the new BTRFS nuclei become better.
1 Like

It could indeed be used instead of fstrim.timer, but on the other hand, it won’t hurt to leave the timer enabled.

I myself have both active. :wink:


There will always be scenarios where one filesystem performs better than another one, and circumstances where the other one is faster.

Everything depends on which operation you’re timing, whether you have lots of large files or small files, and so on.

Also, do keep in mind that compression and decompression will always run away with some CPU cycles, and especially so when choosing a high compression ratio. :wink:


Maybe not the data, but I believe it can repair the metadata based upon the checksums. :thinking:

3 Likes

OK, thanks @Aragorn , then I continue to use the two together.

2 Likes

i see lately that Manjaro switch to Wayland,BTRFS and early on to Pipewire.
i don’t mind it if i can choose otherwise upon installation.
i read forum posts every day and the most recurring threads are issues related to those.

i prefer for the time being to stay on the old more reliable options.
i don’t need what BTRFS has to offer and reading here seems to indicate that it has it cons that matters to me.

same for pipewire; im fine with Pulse audio,
and for Wayland,i had to temporarily switch in order to fix an issue.

I agrree about BTRFS, unless you’re a RAID user, and I’m not. Ext4 works just fine, and I’m reading conflicting posts (not just here) whether it’s actually faster.

As for Pulseaudio vs. Pipewire I can’t tell the difference, other than my use of the Pulseeffects package. Pulseaaudio needs the legacy package (in AUR). Pipewire uses Easyeffects (extra repo) which looks similar, only it displays in monochrome. Pulseeffects works with Pipewire, whereas Easyeffects does not work with Pulseaudio.

Wayland is more difficult to tell. I did encounter it when I first came to Linux (Ubuntu) a few years ago, and again there seemed to be no difference between using it or X11. You had the choice at login. However whilst using Manjaro I’ve been on X11 and since then I’ve read some accounts of users running into issues with Wayland, especially those who use screen recorders, which I now use a fair bit. I’m on Xfce which so far doesn’t use Wayland, but am considering trying KDE Plasma which does.

I reckon the average user (unless they have an Nvidia card) will probably find changing from Xorg to Wayland pretty much seamless. For users (like me) with more complex needs, the migration takes a lot more work.
For example, if you need to re-map your mouse keys, it’s simple with Xorg as all you need to do is drop in a config file. With Wayland it’s a far more complex operation which needs to be triggered through a startup script for every desktop session.

Advanced window manipulation needs a whole load of new commands to be used, as well-documented tools like xdotool no longer work.

Only read-only snapshots can be sent and received.
https://wiki.archlinux.org/title/Btrfs#Send/receive

2 Likes