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 anautodefrag
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 viazlib
,lzo
andzstd
, 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 orzfs
subvolumes,btrfs
subvolumes are not block devices and cannot be treated that way.) -
btrfs
subvolumes can be snapshotted with tools liketimeshift
and/orsnapper
, 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…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, withPRUNE_BIND_MOUNTS
set to “yes”,updatedb
will ignore any data residing onbtrfs
subvolumes.
-
If your
/boot
directory resides on abtrfs
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…COMPRESSION=cat
After this you will need to rebuild your
initramfs
with…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 wantmkinitcpio
compressing your kernel image and yourinitramfs
when you’re already using the compression built intobtrfs
.
-
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 thebtrfsmaintenance
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 ascrub
once a month, although once a week is also acceptable.You can do this manually or via the timed execution in
btrfsmaintenance
. Both thescrub
andbalance
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.