This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!
Btrfs¶
Btrfs CoW file system for Linux aimed at implementing advanced features while focusing on fault tolerance, repair, and easy administration.
Reference(s)
- https://btrfs.wiki.kernel.org/index.php/Status
- https://btrfs.wiki.kernel.org/index.php/FAQ
- https://wiki.gentoo.org/wiki/Btrfs
- https://wiki.archlinux.org/index.php/Btrfs
- https://btrfs.wiki.kernel.org/index.php/Main_Page
- https://btrfs.wiki.kernel.org/index.php/SysadminGuide
- https://www.reddit.com/r/linux/comments/9z7h7u/zfs_vs_btrfs/
Table of contents¶
Install¶
A correct kernel config is needed:
$ cd /usr/src/linux
# make nconfig # or `# make menuconfig`
# Activate Btrfs in the kernel
# Double check here: <https://wiki.gentoo.org/wiki/Btrfs#Kernel>
#
> File systems --->
> <*> Btrfs filesystem support # Symbol: BTRFS_FS [=y]
Warning
After configuring the kernel don't forget to do a kernel make and rebuild!
Config¶
/dev/sdXNwill be the disk partition to format ("X" the disk number, "N" the partition letter)
Create OR convert a FS to a "simple" Btrfs¶
- Create a Btrfs file system on the
/dev/sdXNpartition :
OR
- Convert a whole disk ext4 based file system to Btrfs file system:
Create a FS to RAID 1 Btrfs¶
- Create a Btrfs file system on the
/dev/sdXand/dev/sdYdisks:
Add an fstab entry¶
- Configure fstab to mount Btrfs disks (e.g. with
zstdcompression, other options arezliborlzo):
Use¶
-
Global usage: https://wiki.archlinux.org/index.php/Btrfs#Usage
-
Re compress the whole file system (e.g. with
zstdcompression method): -
Report file space usage with Btrfs:
-
Report disk space usage with Btrfs:
-
Report full breakdown of device allocation and usage stats:
CoW¶
Warning
Turning off CoW also turns off checksums which puts your data "at risk" (as much as with ext4). Without checksums, Btrfs can't self heal from disk corruptions (even on RAID1 setups). See https://btrfs.wiki.kernel.org/index.php/FAQ#Can_I_have_nodatacow_.28or_chattr_.2BC.29_but_still_have_checksumming.3F.
Compression¶
Scrub¶
A scrub is an online file system checking tool. Reads all the data and metadata on the file system, and uses checksums and the duplicate copies from RAID storage to identify and repair any corrupt data.
-
Start a (background) scrub:
-
Check the status of a running scrub:
Sub volumes¶
Quota¶
Commit interval¶
If this cheat sheet has been useful to you, then please consider leaving a star here.