monday, 5 january 2015

after using ZFS for some time, a recent move from Debian Sid to Arch Linux prompted a look at btrfs. While not as mature or robust as ZFS, along with a different approach to RAID implementation, btrfs is availble in the Linux kernel which allows easy installation of a btrfs /root and eliminates the need to rebuild the ZFS module for every Linux kernel release.

Snapshots should facilitate recovery from a system update gone awry – though, its “experimental” status means you are still living on the edge. But that is why I’m on Arch at the moment!

I prefer to create my file systems (and references in the /etc/fstab) using the disk LABELs, as system reboots can reassign the /dev/sd? device names if hard disks or external devices like USB flash drives are attached or removed between boot cycles.

simple volume

single volume..

mkfs.btrfs -f -L <label> <device> mkfs.btrfs -f -L Downloads /dev/disk/by-id/ata-Samsung_SSD_840_EVO_120GB_S1D5NSADA26536P

with subvolumes

striped boot volume with subvolumes and snapshot directory (see fstab)..

mkfs.btrfs -f -L <label> -d raid0 <device> <device>.. btrfs subvolume create <path> mkfs.btrfs -f -L Archlinux -d raid0 /dev/sda2 /dev/sdb mkdir -pv /mnt/btrfs-root/__snapshot mkdir -pv /mnt/btrfs-root/__current btrfs subvolume create /mnt/btrfs-root/__current/ROOT btrfs subvolume create /mnt/btrfs-root/__current/home btrfs subvolume create /mnt/btrfs-root/__current/opt btrfs subvolume create /mnt/btrfs-root/__current/srv btrfs subvolume create /mnt/btrfs-root/__current/var

In this setup, two SSD’s, a 128GB Samsung EVO Pro and a 120GB Samsung EVO are used. An 8GB swap is allocated in /dev/sda1, hence, striping /dev/sda2 and /dev/sdb. As quick as SSD’s are singly, striping two yields even greater performance!

multi-disk pool

use full space of all volumes with raid1 mirrored metadata..

mkfs.btrfs -f -L <label> -m raid1 -d single <device> <device>.. mkfs.btrfs -f -L Archive -m raid1 -d single /dev/disk/by-id/ata-WD_My_Book_1105_WU2Q10098319 /dev/disk/by-id/ata-WDC_WD10EARX-00N0YB0_WD-WCC0T0755003


mirror of data and metadata..

mkfs.btrfs -f -L <label> -d raid1 <device> <device>.. mkfs.btrfs -f -L Media -d raid1 /dev/disk/by-id/ata-WDC_WD30EFRX-68EUZN0_WD-WMC4N0820795 /dev/disk/by-id/ata-WDC_WD30EFRX-68AX9N0_WD-WMC1T2857955


striped data with raid1 mirrored metadata..

mkfs.btrfs -f -L <label> -m raid1 -d raid0 <device> <device>.. mkfs.btrfs -f -L Photos -m raid1 -d raid0 /dev/disk/by-id/ata-SAMSUNG_HD103SJ_S246JDWZ105420 /dev/disk/by-id/ata-ST1000DM005_HD103SJ_S246J9EC314043 /dev/disk/by-id/ata-SAMSUNG_HD103SJ_S246JDWZ105419


with /var/lib binding onto /ROOT subvolume to include /var/lib/pacman for snapshots..

LABEL=Archlinux / btrfs rw,nodev,noatime,ssd,compress=lzo,space_cache,autodefrag,inode_cache,discard,subvol=__current/ROOT 0 0 LABEL=Archlinux /home btrfs rw,nodev,noatime,ssd,compress=lzo,space_cache,autodefrag,inode_cache,discard,subvol=__current/home 0 0 LABEL=Archlinux /opt btrfs rw,nodev,noatime,ssd,compress=lzo,space_cache,autodefrag,inode_cache,discard,subvol=__current/opt 0 0 LABEL=Archlinux /srv btrfs rw,nodev,noatime,ssd,compress=lzo,space_cache,autodefrag,inode_cache,discard,subvol=__current/srv 0 0 LABEL=Archlinux /var btrfs rw,nodev,noexec,noatime,ssd,compress=lzo,space_cache,autodefrag,inode_cache,discard,subvol=__current/var 0 0 LABEL=Archlinux /run/btrfs-root btrfs rw,nodev,nosuid,noexec,noatime,ssd,compress=lzo,space_cache,autodefrag,inode_cache,discard 0 0 # bind /var/lib onto the ROOT subvolume so snapshots of ROOT include /var/lib/pacman /run/btrfs-root/__current/ROOT/var/lib /var/lib none bind 0 0 LABEL=Downloads /net/downloads btrfs rw,nodev,noexec,autodefrag,noatime,space_cache0 0 LABEL=Media /net/media btrfs rw,nodev,noexec,autodefrag,noatime,space_cache0 0 LABEL=Photos /net/photos btrfs rw,nodev,noexec,autodefrag,noatime,space_cache0 0 LABEL=Archive /net/archive btrfs rw,nodev,noexec,autodefrag,noatime,space_cache0 0


filesystem LABELs and UUIDs assigned during mkfs.btrfs can be listed with..

btrfs filesystem show --all-devices

Whole volumes can be used by btrfs without the need to partition the drives, after which, subvolumes (akin to logical volumes of LVM) can be defined, creating additional (and optional) mount points. There is much more to btrfs with data compression, defragmentation, quotas, etc.

Butter FS. What’s not to like? Yum!

»»  nginx proxy

comment ?