From Fedora Project Wiki

< Changes

Revision as of 01:22, 3 February 2021 by Alexgartrell (talk | contribs) (I added a simple analysis of various compression levels as justification for zstd:1)

Make btrfs the default file system for desktop variants


For laptop and workstation installs of Fedora, we want to provide file system features to users in a transparent fashion. We want to add new features, while reducing the amount of expertise needed to deal with situations like running out of disk space. Btrfs is well adapted to this role by design philosophy, let's make it the default.


  • Products: All desktop editions, spins, and labs
  • Responsible WGs: Workstation Working Group, KDE Special Interest Group

Current status

Detailed Description

Fedora desktop edition/spin variants will switch to using Btrfs as the filesystem by default for new installs. Labs derived from these variants inherit this change, and other editions may opt into this change.

The change is based on the installer's custom partitioning Btrfs preset. It's been well tested for 7 years.

Current partitioning
vg/root LV mounted at / and a vg/home LV mounted at /home. These are separate file system volumes, with separate free/used space.

Proposed partitioning
root subvolume mounted at / and home subvolume mounted at /home. Subvolumes don't have size, they act mostly like directories, space is shared.

/boot will be a small ext4 volume. A separate boot is needed to boot dm-crypt sysroot installations; it's less complicated to keep the layout the same, regardless of whether sysroot is encrypted. There will be no automatic snapshots/rollbacks.

If you select to encrypt your data, LUKS (dm-crypt) will be still used as it is today (with the small difference that Btrfs is used instead of LVM+Ext4). There is upstream work on getting native encryption for Btrfs that will be considered once ready and is subject of a different change proposal in a future Fedora release.

Optimizations (Optional)

The detailed description above is the proposal. It's intended to be a minimalist and transparent switch. It's also the same as was proposed (and accepted) for Fedora 16. The following optimizations improve on the proposal, but are not critical. They are also transparent to most users. The general idea is agree to the base proposal first, and then consider these as enhancements. NOTE: These optimizations will not be used by default in Fedora 33, but are available for opt-in adoption and evaluation.

Boot on Btrfs

  • Instead of a 1G ext4 boot, create a 1G Btrfs boot.
  • Advantage: Makes it possible to include in a snapshot and rollback regime. GRUB has stable support for Btrfs for 10+ years.
  • Scope: Contingent on bootloader and installer team review and approval. blivet should use mkfs.btrfs --mixed.


  • Enable transparent compression using zstd on select directories: /usr, /var/lib/flatpak, ~/.local/share/flatpak
  • Advantage: Saves space and significantly increase the lifespan of flash-based media by reducing write amplification. It may improve performance in some instances.
  • Scope: Contingent on installer team review and approval to enhance anaconda to perform the installation using mount -o compress=zstd, then set the proper XATTR for each directory. The XATTR can't be set until after the directories are created via: rsync, rpm, or unsquashfs based installation.

Additional subvolumes

  • /var/log/, /var/lib/libvirt/images and ~/.local/share/gnome-boxes/images/ will use separate subvolumes.
  • Advantage: Makes it easier to excluded them from snapshots, rollbacks, and send/receive. (Btrfs snapshotting is not recursive, it stops at a nested subvolume.)
  • Scope: Anaconda knows how to do this already, just change the kickstart to add additional subvolumes (minus the subvolume in ~/. GNOME Boxes will need enhancement to detect that the user home is on Btrfs and create ~/.local/share/gnome-boxes/images/ as a subvolume.


Red Hat doesn't support Btrfs? Can Fedora do this?

Red Hat supports Fedora well, in many ways. But Fedora already works closely with, and depends on, upstreams. And this will be one of them. That's an important consideration for this proposal. The community has a stake in ensuring it is supported. Red Hat will never support Btrfs if Fedora rejects it. Fedora necessarily needs to be first, and make the persuasive case that it solves more problems than alternatives. Feature owners believe it does, hands down.

The Btrfs community has users that have been using it for most of the past decade at scale. It's been the default on openSUSE (and SUSE Linux Enterprise) since 2014, and Facebook has been using it for all their OS and data volumes, in their data centers, for almost as long. Btrfs is a mature, well-understood, and battle-tested file system, used on both desktop/container and server/cloud use-cases. We do have developers of the Btrfs filesystem maintaining and supporting the code in Fedora, one is a Change owner, so issues that are pinned to Btrfs can be addressed quickly.

What about device-mapper alternatives?

dm-thin (thin provisioning): Issue #152 still happens, because the installer won't over provision by default. It still requires manual intervention by the user to identify and resolve the problem. Upon growing a file system on dm-thin, the pool is over committed, and file system sizes become a fantasy: they don't add up to the total physical storage available. The truth of used and free space is only known by the thin pool, and CLI and GUI programs are unprepared for this. Integration points like rpm free space checks or GNOME disk-space warnings would have to be adapted as well.

dm-vdo: is not yet merged, and isn't as straightforward to selectively enable per directory and per file, as is the case on Btrfs using chattr +c on /var/lib/flatpaks/.

Btrfs solves the problems that need solving, with few side effects or pitfalls for users. It has more features we can take advantage of immediately and transparently: compression, integrity, and IO isolation. Many Btrfs features and optimizations can be opted into selectively per directory or file, such as compression and nodatacow, rather than as a layer that's either on or off.

What about UI/UX and integration in the desktop?

If Btrfs isn't the default file system, there's no commitment, nor reason to work on any UI/UX integration. There are ideas to make certain features discoverable: selective compression; systemd-homed may take advantage of either Btrfs online resize, or near-term planned native encryption, which could make it possible to live convert non-encrypted homes to encrypted; and system snapshot and rollbacks.

Anaconda already has sophisticated Btrfs integration.

What Btrfs features are recommended and supported?

The primary goal of this feature is to be largely transparent to the user. It does not require or expect users to learn new commands, or to engage in peculiar maintenance rituals.

The full set of Btrfs features that is considered stable and enabled by default upstream will be enabled in Fedora. Fedora is a community project. What is supported within Fedora depends on what the community decides to put forward in terms of resources.

The upstream Btrfs feature status page.

Are subvolumes really mostly like directories?

Subvolumes behave like directories in terms of navigation in both the GUI and CLI, e.g. cp, mv, du, owner/permissions, and SELinux labels. They also share space, just like a directory.

But it is an incomplete answer.

A subvolume is an independent file tree, with its own POSIX namespace, and has its own pool of inodes. This means inode numbers repeat themselves on a Btrfs volume. Inodes are only unique within a given subvolume. A subvolume has its own st_dev, so if you use stat FILE it reports a device value referring to the subvolume the file is in. And it also means hard links can't be created between subvolumes. From this perspective, subvolumes start looking more like a separate file system. But subvolumes share most of the other trees, so they're not truly independent file systems. They're also not block devices.

Benefit to Fedora

Problems Btrfs helps solve:

  • Users running out of free space on either / or /home Workstation issue #152
    • "one big file system": no hard barriers like partitions or logical volumes
    • transparent compression: significantly reduces write amplification, improves lifespan of storage hardware
    • reflinks and snapshots are more efficient for use cases like containers (Podman supports both)
  • Storage devices can be flaky, resulting in data corruption
    • Everything is checksummed and verified on every read
    • Corrupt data results in EIO (input/output error), instead of resulting in application confusion, and isn't replicated into backups and archives
  • Poor desktop responsiveness when under pressure Workstation issue #154
    • Btrfs has been tested in production to have proper IO isolation capability via cgroups2
    • Completes the resource control picture: memory, cpu, IO isolation
  • File system resize
    • Whether provisioning an additional OS, or possible integration of systemd-homed, shrink capability is desired.
    • Online shrink and grow are fundamental to Btrfs design
  • Complex storage setups are... complicated
    • Simple and comprehensive command interface. One master command
    • Simpler to boot, all code is in the kernel, no initramfs complexities
    • Simple and efficient file system replication, including incremental backups, with btrfs send and btrfs receive


  • Proposal owners:
    • Submit PR's for Anaconda to change default_scheme = BTRFS to the proper product files. √
    • Disk image variants of desktops will have their kickstarts adjusted to produce btrfs disk images. √
    • The catch-all "Everything" netinstaller will use Btrfs by default. √
    • Test days: including building a community support network. √ (on-going)
    • Aid with documentation (in-progress)
    • Make btrfs in kernel built-in instead of a module (CONFIG_BTRFS_FS=mCONFIG_BTRFS_FS=y) √
    • Bugs related to btrfs user-space commands should be filed against the btrfs-progs component. All other bugs should be filed against the kernel component, while also setting the Assignee field to:
  • Other developers:
    • Anaconda, review PRs and merge
    • Bootloader team, review PRs and merge
    • Recommended optimization chattr +C set on the containing directory for virt-manager and GNOME Boxes, via libvirt
  • Release engineering: #9545
  • Policies and guidelines: N/A
  • Trademark approval: N/A

Upgrade/compatibility impact

Change will not affect upgrades.

Documentation will be provided for existing Btrfs users to "retrofit" their setups to that of a default Btrfs installation (base plus any approved options). Layout has not been changed in Fedora 33.

How To Test

Do a custom partitioning installation; change the scheme drop-down menu to Btrfs; click the blue "automatically create partitions"; and install.
Fedora 31, 32, Rawhide, on x86_64 and ARM.

Once change lands
It should be simple enough to test, just do a normal install.

User Experience


  • Mostly transparent.
  • Users won't run out of space in / or /home as a result of competition for free space between them.
  • Space savings and extend hardware life, via compression.
  • Utilities for used and free space, CLI and GUI, are expected to behave the same. No special commands are required.
  • More detailed information can be revealed by btrfs specific commands.
  • cp command will create reflink copies by default.

Enhancement opportunities

Nice UX if a MOTD popped up a link to support/recovery docs upon read-only boot.

updatedb does not index /home when /home is a bind mount Also can affected rpm-ostree installations, including Silverblue.

GNOME Usage: Incorrect numbers when using multiple btrfs subvolumes This isn't Btrfs specific, happens with "one big ext4" volume as well.

GNOME Boxes, RFE: create qcow2 with 'nocow' option when on btrfs /home This is Btrfs specific, and is a recommended optimization for both GNOME Boxes and virt-manager.

containers/libpod: automatically use btrfs driver if on btrfs



Contingency Plan

  • Contingency mechanism: Owner will revert changes back to LVM+ext4
  • Contingency deadline: Beta freeze
  • Blocks release? Yes
  • Blocks product? Workstation and KDE


Strictly speaking no documentation is required reading for users. But there will be some Fedora documentation to help get the ball rolling.

For those who want to know more:

btrfs wiki main page and full feature list.

man 5 btrfs contains: mount options, features, swapfile support, checksum algorithms, and more
man btrfs contains an overview of the btrfs subcommands
man btrfs <subcommand> will show the man page for that subcommand

NOTE: The btrfs command will accept an initial part of a subcommand name, as long as it is not ambiguous. These are equivalent commands:
btrfs subvolume snapshot
btrfs sub snap
btrfs su sn

You'll discover your own convention. It might be preferable to write out the full command on forums and lists, but then maybe some folks don't learn about this useful shortcut?

For those who want to know a lot more:

Btrfs developer documentation
Btrfs trees

Simple Analysis of btrfs zstd compression level

Workstation root fs disk space savings


For an installed root directory of Fedora 32, zstd:1 yields a 40% storage savings as compared to uncompressed ext4. zstd:9 yields a 43% storage savings.

Test Steps

1. Obtain an “installed.dir” by

   1. Prep the image
       1. truncate -s 64G installed.raw
   2. Booting the live cd (in the case F32) in a qemu-kvm 
       1. qemu-kvm -drive file=installed.raw -cdrom $ISO -m 1G
   3. Installing it in the graphical installer
       1. I used regular partitions, and did not create a new one for /home
   4. Shutting down the qemu instance3105440
   5. Mount it to the directory
       1. losetup -Pf installed.raw
       2. mkdir -p installed.dir
       3. mount /dev/loop1p2 installed.dir

2. Run the script below


set -e


if [ $EUID -ne 0 ] ; then
    echo "Needs to be root" >&2
    exit 2

for compress_level in 1 3 9 ; do
    truncate -s $SIZE $raw
    mkfs.btrfs -f $raw
    mkdir -p $dir
    mount -o compress=zstd:${compress_level} $raw $dir
    perf record -g -o perf${compress_level}.data bash -c "cp -r installed.dir/* $dir ; sync $dir"

==== Results ====

zstd:1 - 40% savings
zstd:3 - 41% savings
zstd:9 - 43% savings

This is the result from df. Ignore Use% because the installed directory is a different size.

Filesystem                              1K-blocks     Used Available Use% Mounted on
/dev/loop1p3                             61665068  5458980  53043976  10% /scratch/installed.dir
/dev/loop0                               16777216  3257192  13356936  20% /scratch/zstd1.dir
/dev/loop2                               16777216  3197668  13415468  20% /scratch/zstd3.dir
/dev/loop3                               16777216  3105440  13502704  19% /scratch/zstd9.dir

/dev/urandom copy cpu cost

    • note: this test is a lot less scientific than the other one, because it’ll be CPU dependent and I had other stuff going on (chrome was open, etc). It’s likely still a reasonable proxy for CPU impact though.**


zstd:1 added 9% and zstd:9 added 15% of system time to the baseline.

Test Steps

1. Get a 2GB blah file that will compress very poorly

   1. dd if=/dev/urandom of=blah bs=256K count=8192

2. Run the script


set -e


if [ $EUID -ne 0 ] ; then
    echo "Needs to be root" >&2
    exit 2

for compress_level in 0 1 3 9 ; do
    truncate -s $SIZE $raw    #perf record -g -o perf${compress_level}.data bash -c    #perf record -g -o perf${compress_level}.data bash -c
    mkfs.btrfs -f $raw 2>/dev/null >/dev/null
    mkdir -p $dir
    if [ $compress_level -eq 0 ] ; then
        mount $raw $dir
        mount -o compress=zstd:${compress_level} $raw $dir
    echo Compression Level ${compress_level}
    time bash -c \
         "dd if=blah of=$dir/blah ; sync $dir"


Compression Level 0
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 13.3657 s, 161 MB/s

real    0m13.386s
user    0m2.891s
sys     0m9.486s
Compression Level 1
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 14.8094 s, 145 MB/s

real    0m14.913s
user    0m3.313s
sys     0m10.380s
Compression Level 3
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 15.1291 s, 142 MB/s

real    0m15.259s
user    0m3.261s
sys     0m10.720s
Compression Level 9
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 15.4792 s, 139 MB/s

real    0m15.499s
user    0m3.442s
sys     0m10.913s

/dev/zero cpu copy test


Easily compressed data is a lot more expensive at higher levels. zstd:1 added 16%, zstd:9 added 82%

Test Steps

Same as above, but swap /dev/urandom for /dev/zero


Compression Level 0
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 14.1791 s, 151 MB/s

real    0m14.196s
user    0m2.971s
sys     0m9.909s
Compression Level 1
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 16.4391 s, 131 MB/s

real    0m16.536s
user    0m3.403s
sys     0m11.511s
Compression Level 3
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 14.9807 s, 143 MB/s

real    0m15.094s
user    0m3.398s
sys     0m10.833s
Compression Level 9
4194304+0 records in
4194304+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 18.0451 s, 119 MB/s

real    0m18.066s
user    0m3.758s
sys     0m12.173s

Release Notes

The default file system on the desktop is Btrfs. It specifically excludes Fedora Server, Cloud, IoT, and CoreOS. As a consequence of release engineering complexities, the seldom marketed "Everything" netinstaller will use Btrfs by default. It's advised that headless and PXE installation use cases should use the Fedora Server netinstaller.

All installer images continue to have a custom partitioning option, enabling users to choose their preferred layout and file system.