Credit: Dell The btrfsck command is a filesystem-check command like fsck, but it works with the btrfs file system. First a little bit about btrfs. As the name implies, btrfs uses a B-tree data structure that is self-balancing and maintains sorted data, facilitating searches, sequential access, insertions, and deletions. It is also often referred to as the “better file system”. Oracle developed it and first used it about 15 years ago. By November 2013, it was declared adequately stable and began to be used by other distributions as well, and now its use is quite common. Benefits of btrfs The benefits of btrfs are impressive, although it’s still a work in progress and some concerns have kept it from playing a more dominant role on Linux systems. It keeps 2 copies of metadata on a volume, allowing for data recovery if and when the hard drive is damaged or suffers from bad sectors. It uses checksums and verifies them with each read. In addition, compared to ext4 volumes, btrfs does not require double the storage space to accommodate file versioning and history data. When you list file systems as shown below for a Fedora system, you may see that some of them are btrfs. The -T option provides the file system type while the -h option adjusts the sizes to be displayed in a human-friendly (size appropriate units) fashion. $ df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 2.9G 0 2.9G 0% /dev tmpfs tmpfs 2.9G 0 2.9G 0% /dev/shm tmpfs tmpfs 1.2G 3.1M 1.2G 1% /run /dev/sdb4 btrfs 31G 5.5G 25G 19% / tmpfs tmpfs 2.9G 132K 2.9G 1% /tmp /dev/sdb3 ext4 974M 237M 670M 27% /boot tmpfs tmpfs 593M 924K 592M 1% /run/user/1000 /dev/sdc1 ext4 974M 174M 733M 20% /extra /dev/sdc2 btrfs 2.0T 2.9G 2.0T 1% /data/xfer To use btrfsck, the targeted file system should first be unmounted from the system. $ sudo umount /dev/sdc2 The unmount can then be confirmed. $ df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 2.9G 0 2.9G 0% /dev tmpfs tmpfs 2.9G 0 2.9G 0% /dev/shm tmpfs tmpfs 1.2G 3.1M 1.2G 1% /run /dev/sdb4 btrfs 31G 5.5G 25G 19% / tmpfs tmpfs 2.9G 132K 2.9G 1% /tmp /dev/sdb3 ext4 974M 237M 670M 27% /boot tmpfs tmpfs 593M 924K 592M 1% /run/user/1000 /dev/sdc1 ext4 974M 174M 733M 20% /extra At this point, it is OK to run the file system check. The file system shown in this example is quite large, but only a small portion of it is in use. The output below shows the phases that the check runs through. $ sudo btrfsck /dev/sdc2 Opening filesystem to check... Checking filesystem on /dev/sdc2 UUID: 51749cdf-6fe9-4a1a-8379-18c913660f7b [1/7] checking root items [2/7] checking extents [3/7] checking free space cache [4/7] checking fs roots [5/7] checking only csums items (without verifying data) [6/7] checking root refs [7/7] checking quota groups skipped (not enabled on this FS) found 2909151232 bytes used, no error found As you can see, no errors were found. Checking mounted btrfs file systems Unmounting file systems before running btrfsck is the recommended approach. When you cannot—such as when the file system is your root (/) file system—it is possible to force a check using the --force option as shown below. # btrfsck --check --force /dev/sdb4 Opening filesystem to check... WARNING: filesystem mounted, continuing because of --force Checking filesystem on /dev/sdb4 UUID: 674d8f43-81a6-4713-81d5-9d7506cd6d69 [1/7] checking root items [2/7] checking extents [3/7] checking free space cache [4/7] checking fs roots [5/7] checking csums against data [6/7] checking root refs [7/7] checking quota groups skipped (not enabled on this FS) found 5864960000 bytes used, no error found total csum bytes: 5478800 total tree bytes: 225935360 total fs tree bytes: 206061568 total extent tree bytes: 12435456 btree space waste bytes: 50394664 file data blocks allocated: 16850681856 referenced 8673013760 Other file system types Other file system types used on this system include: The devtmpfs file system is one with includes automated device nodes populated by the kernel. The tmpfs file system is one which keeps all of its files in virtual memory. The ext4 file system is a journaling file system developed as the successor to ext3. A journaling file system is one that keeps track of changes not yet committed to the file system by recording the goal of such changes. Ext4 also provides large file system support, improved resistance to fragmentation, higher performance and improved timestamps. Related content how-to How to examine files on Linux Linux provides very useful options for viewing file attributes, such as owners and permissions, as well as file content. By Sandra Henry Stocker Oct 24, 2024 6 mins Linux how-to 8 easy ways to reuse commands on Linux Typing the same command again and again can become tiresome. Here are a number of ways you can make repeating commands – or repeating commands but with some changes – a lot easier than you might expect. By Sandra Henry-Stocker Oct 15, 2024 5 mins Linux news SUSE Edge upgrade targets Kubernetes and Linux at the edge SUSE Edge 3.1 includes a new stack validation framework and an image builder tool that are aimed at improving the scalability and manageability of complex Kubernetes and Linux edge-computing deployments. By Sean Michael Kerner Oct 15, 2024 6 mins Edge Computing Linux Network Management Software how-to Lesser-known xargs command is a versatile time saver Boost your Linux command line options and simplify your work with xargs, a handy tool for a number of data manipulation tasks. By Sandra Henry Stocker Oct 11, 2024 6 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe