Btrfs/Mount Options

From Forza's ramblings

Mount options

Picture of a radio telescope ontop of a hill with cloudy sky.
The 26m Radio Telescope at Mount Pleasant Radio Observatory, Tasmania, Australia

Btrfs has many mount options that controls how the filesystem behaves. Except for the subvol and subvolid, all mount options affect the whole filesystem, and not the individual subvolume mounts. This means that specifying for example compress=zstd on the first mount, all subsequent mounts will inherit the compression option.

Linux VFS mount options like noatime do apply per mount point. See the chapter about filesystem independent mount options in the mount man page.

The full set of btrfs mount options are available in the official Btrfs man page.

Mount option Description
noatime Disables atime updates. This is good to use by default because atime updates increases metadata writes. Atimes are especially costly performance-wise when you have many snapshots.
compress=<algo> Enables compression on the filesystem.
compress-force=<algo> Forces compression, even on data that doesn't compress well. Can increase compression ratio. Also increases fragmentation.
<algo> can be any of zlib:1-9, lzo and zstd:1-15.
space_cache=v2 Enables the new B-tree version of space cache. It is much more performant on large filesystems than The original v1. See Btrfs/Space Cache for details.
subvol=<subvol> Specifies what subvolume to mount.
subvolid=<id> Specifies what subvolume to mount using its ID. Can be used instead of subvol
degraded Is used to mount a filesystem that has a missing disk. Works with a redundant profile such as RAID 1.

The basic mount command is mount -o <options> <device> <path>

# mount -o noatime,compress=zstd,subvol=my-vault /dev/sdc1 /media/vault


This is fstab on one of my machines. The disk is an SSD so I use compress-force=zstd:2 to reduce amount of data written to the disk, increasing its life span.

The 0 0 at the end of each fstab line means the filesystem should not be checked with fsck. Btrfs does not need it, and it should not be used regularly.

UUID=446d32cb-a6da-45f0-9246-1483ad3420e0   /               btrfs   compress-force=zstd:2,noatime,subvol=volume/root            0 0
UUID=446d32cb-a6da-45f0-9246-1483ad3420e0   /home           btrfs   compress-force=zstd:2,noatime,subvol=volume/home            0 0
UUID=446d32cb-a6da-45f0-9246-1483ad3420e0   /var/tmp        btrfs   compress-force=zstd:2,noatime,noexec,subvol=volume/var_tmp  0 0
UUID=446d32cb-a6da-45f0-9246-1483ad3420e0   /mnt/rootvol/   btrfs   compress-force=zstd:2,noatime                               0 0
tmpfs                                       /tmp            tmpfs   rw,nosuid,noexec,nodev,size=4G,mode=1777                    0 0

/mnt/rootvol is where the filesystem top level subvolume mounted. From here it is possible to access all snapshots and subvolumes directly.

Many distributions prefix subvolume names with @ so it is easier to distinguish them from normal directories.

Take a moment to read up on flat vs nested subvolume layouts over at Btrfs/Getting_Started#Subvolumes