I came across two good Btrfs documentation when working with btrfs
(in production), the docs and best practices are for those brave hearts who use Btrfs on a daily basis;-)
NOTE: Btrfs is experimental and under heavy development. Don’t use it to store critical data. DO backup your data (it is a good idea to place backup on an ext4
file system, don’t put all eggs in one basket) before trying it out. No one can save you without good backups;-)
Use tips based on practice
/
, especially when you ONLY have a single block device (partition)-m single
when creating the file system, dangerous!), BUT you ONLY have 1 copy of data.lxc-create
, the -B
NEED NOT to be specified as it will be used automatically if the /var/lib/lxc
filesystem is found to be Btrfs.mkfs.btrfs -m raid1 -d raid1 /dev/sdc /dev/sdd
metadata is by default replicated on all devices so you don’t have to explicitly specify -m raid1
df -hT
output, use btrfs filesystem df /mount_point
insteadmount -o compress=lzo,subvol=subvol /dev/sdd /mnt/subvol
btrfs filesystem defragment file
or btrfs filesystem defrag directory
to apply compression to existing data. Mounting the subvol without compression option, data is still accessible (NOT sure if mv
cp
or edit will change the compression state though, comment if you know).yum-plugin-fs-snapshot
plugin does this, Ubuntu and OpenSUSE do the same in a similar way). It eats up your disk space if you don’t keep an eye and don’t give a shit;-)cp --reflink
mount -t btrfs -o subvol=subvol_name device /mnt/subvol
mount -t btrfs -o subvol=snapshot-id device /mnt/snapshot
mount -o space_cache
to speed up boot and gain slight performance improvementspace_cache
option, Btrfs is able to store the free space cache on the disk to make the caching of a block group much quicker. Without this support, Btrfs has to scan the entire tree each time looking for space that can be allocated.BTW: Where the fuck is btrfsck
?
NOTE: I don’t think we’ll touch btrfsck on a regular basis, probably never (does it make sense to fsck a 3TB HDD?). Similar to ZFS, Btrfs is capable of self-healing and relies on snapshot backups to recover when shit happens. If a Btrfs file system is at the point where it is unable to heal itself and roll back to a good snapshot backup, it means game over => it is basically unrepairable.
The instructions on Funtoo wiki is out-of-date (upon finishing the article). Chris Mason has changed the branch name from donteveruse
to dangerdonteveruse
shit!
So the instructions:
# git clone git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git # cd btrfs-progs/ # git checkout dangerdonteveruse Switched to branch 'dangerdonteveruse' # make
NOTE: I updated the Funto wiki page and it should be approved pretty soon.
NOTE: Chris Mason decided to release btrfs-progs
at the same pace as the Linux kernel since Linux 3.12. btrfsck
is NOW a part of the btrfs-progs package. NO need to build from source.
Recommended reading: How I Use The Advanced Capabilities of Btrfs