Btrfs and the future of the filesystem
New Butter
The Btrfs filesystem offers advanced features such as RAID, subvolumes, snapshots, checksums, and transparent compression, but do desktop users really need all that power?
A filesystem functions below the operating system, ensuring that abstract data is converted into physical address attributes such as tracks and sectors. Some filesystems go beyond this basic functionality. One powerful and popular filesystem for Linux is Btrfs. The Btrfs filesystem [1], which is affectionately pronounced "ButterFS," is sometimes called the next generation filesystem. Btrfs is a copy-on-write filesystem [2] originally developed by Oracle Corporation and masterminded by Chris Mason. In some ways, Btrfs is best understood as an implementation of the Solaris 10 transactional filesystem ZFS [3] for the Linux platform. Oracle acquired ZFS in 2010 when it acquired Sun Microsystems. Btrfs is free software under the GPL and was adopted into Linux kernel 2.6.29 early in 2009.
Btrfs was declared suitable for production use in April 2013. Btrfs developer Chris Mason moved from SUSE, where he worked on ReiserFS, to Oracle, and he has worked at Facebook for several years, where Btrfs is widely used in the back end. Btrfs is now no longer limited to Linux; the WinBtrfs [4] project offers what are still experimental drivers for Windows. In the Linux world, Oracle started using Btrfs in its Unbreakable Linux release, version 2, four years ago, and SUSE in SUSE Linux Enterprise Server 12 (SLES 12) and openSUSE 13.2 (Figure 1). OpeSUSE Leap uses Btrfs as the default for the root partition; most other distributions include Btrfs in their archives and offer it as an alternative in the installer. Fedora plans to make Btrfs the default with Fedora 24.
Trees, Nodes, and Leaves
Btrfs is not just well equipped for future desktops, it is also well suited for data centers. A maximum filesystem size of 16 exbibytes (EiB) corresponds to 16 million terabytes, or just over a trillion bytes. (Compare this with ext4, which can only handle 1EiB.) The filesystem can consist of one file of that size, or you can store 18 trillion files, and filenames can comprise 255 bytes. Whereas the directories in ext4 are organized in a table as an HTree, Btrfs uses a B-tree [5], with metadata in the nodes and the data in the leaves.
The idea is to reduce access times for file elements by reducing the height of the tree structure and expanding horizontally. The use of a B-tree also explains the origin of the name Btrfs, which expands to "B-tree FS." Another feature in the filesystem structure is pseudo-subdirectories, or subvolumes, that act like separate drives but only store changes from the main volume and thus do not occupy a great deal of space. Additionally, Btrfs can never run out of inodes [6], which is possible with the ext family, even if free space is available on the partition.
Differences and USPs
In contrast to the currently unofficial default Linux filesystem ext4, Btrfs offers some features that are generally not attributed to the functionality of a filesystem but are hugely popular, especially in professional environments such as data centers. Useful features include built-in Logical Volume Management functionality and built-in RAID levels 0, 1, 5, 6, and 10. Compared with traditional hardware or software RAID, the advantage to Btrfs is that it can distinguish between used and unused data blocks and thus save much time on recovery. Moreover, Btrfs has mastered the art of converting RAID levels on the fly.
Btrfs offers optional transparent data compression, deduplication [7], checksums for data and metadata, filesystem checks and defragmentation at run time, and optimizations for solid-state drives (SSDs). Additionally, btrfs-convert
can reversibly convert existing ext3 and ext4 filesystems to Btrfs, and reverting to ext4 is possible as long as the snapshot created when converting the metadata of the ext4 system is not deleted. The Btrfs filesystem encryption feature, although planned from the outset, has not yet been implemented.
Snapshots Undo Mistakes
One outstanding feature for desktop users is the ability to create snapshots on a running system (Figure 2). Snapshots are images of a subvolume frozen in time. Particularly in connection with the Snapper [8] tool developed by openSUSE (Figure 3), snapshots allow rolling back a system with problems to its previous state, with relatively little effort. Once Snapper is configured, the ability to create a snapshot before a system upgrade removes the worries about upgrades for many users. In SUSE, snapshots are handled graphically via a YaST module for Snapper; external GUIs exist for other operating systems. Btrfs snapshots are less limited than with LVM, because you do not need to allocate space first and run the risk of an overflow. Even a large number of snapshots will not slow the system down.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.