Butter Filesystem. Hold the toast.
I've started experimenting with BtrFS which aims to provide an "advanced and modern filesystem" (heavily compared to ZFS) on Linux. With my new workstation I've started using BtrFS for my home directories (/home
) and my build directories (/mnt/slackbuilds
) to gain exposure to the filesystem and compare it to ZFS and EXT4 on LVM (all of my other data, including my root disk is on EXT4 on LVM).
I have used ZFS heavily in the past, and using BtrFS is significantly different as many of the fundamental concepts are different. BtrFS has no concept of "pools" or "volume groups" -- instead there are "volumes." BtrFS has no concept of "datasets" or "logical volumes" -- instead there are "subvolumes".
Here's a comparison between ZFS, BtrFS, and EXT4 on LVM:
Comparison
ZFS | BtrFS | EXT4 and LVM | |
---|---|---|---|
Commands Involved | zpool, zfs | mkfs.btrfs, btrfs | pvcreate, vgcreate, lvcreate, mkfs.ext4 |
Pool of disks | "zpool" | "volume" | "volume group" |
Mountable unit | "dataset" | "volume" and "subvolume" | "logical volume" |
License | CDDL | GPL | GPL |
Can be Boot filesystem | Yes | Yes (grub 2.00) | No |
Can be Root filesystem | Yes | Yes | Yes |
Can provide swapspace | Yes (zvols) | No | Yes (lvm) |
OSes with Implementations | Solaris, OpenSolaris, Nexenta, FreeBSD, Mac OS X, Linux | Linux | Linux |
Stability | Stable | Stable | Stable |
CLI-System Integration [1] | Strong | Weak | Mild |
Grow Online | Yes | Yes | Only when there are no snapshots |
Shrink Pool | No | Online | Online |
Shrink Filesystem | Online (reduce quota) | Online | Offline |
Replace Disk (without parity) | Yes (must be compatible size disk) | Yes | Yes (copies space allocated on disk) |
Filesystem Level Storage Pooling | Yes | Yes | No |
Re-balance | No | Yes | Can be done manually (pvmove) |
Checksumming | Yes | Yes | No |
Autocorrect Checksum Errors | Yes | ??? | No |
Compression | Yes | Yes | No |
De-duplication | Yes (only synchronous) | Yes (only asynchronous) | No |
Ditto Blocks | Yes | ??? | No |
Tiered Caching | Yes | No | No |
Writable Snapshots | Yes (clone) | Yes | Yes |
Copy-on-Write | Fast, space-efficient | Fast, space-efficient | Slow, requires pre-allocating an LV |
Redundancy | Mirroring and Parity (x1, x2, x3) | Mirroring | Mirroring, though the PVs can be RAID devices |
Maximum Volume Size | 16 Exabytes | 16 Exabytes | 1 Exabyte |
Maximum File Size | 16 Exabytes | 16 Exabytes | 16 Terabytes |
Maximum Number of Snapshots | Unlimited | Unlimited | Effectively 32 |
[1] For lack of a better term -- how well the command line interface integrates with the system as a whole, this might be subjective.
For a more complete, but less focused comparison see Wikipedia's Comparison of Filesystems
The Rosetta Stone
-
Task: Create a pool of storage from disks
/dev/A
,/dev/B
, and/dev/C
(striped or linear concat)- Using ZFS:
# zpool create TESTPOOL A B C
- Using BtrFS:
# mkfs.btrfs -d raid0 /dev/A /dev/B /dev/C
- Using EXT4 on LVM:
# pvcreate /dev/A /dev/B /dev/C
# vgcreate TESTPOOL /dev/A /dev/B /dev/C
- Using ZFS:
-
Task: Make storage from pool available to system
- Using ZFS:
# zfs set mountpoint=/data TESTPOOL
- Using BtrFS:
# mkdir /data
# mount -t btrfs /dev/A /data
- Update
/etc/fstab
- Using EXT4 on LVM:
# mkdir /data
# lvcreate -L _SizeOfVolume_ -n DATA TESTPOOL
# mkfs -t ext4 /dev/TESTPOOL/DATA
# mount /dev/TESTPOOL/DATA /data
- Update
/etc/fstab
- Using ZFS:
-
Task: Add an additional disk to the pool
- Using ZFS:
# zfs add TESTPOOL D
- Using BtrFS:
# btrfs device add /dev/D /data
# btrfs filesystem balance /data
- Using EXT4 on LVM:
# pvcreate /dev/D
# vgextend TESTPOOL /dev/D
- Using ZFS:
-
Task: Add additional space to a filesystem
- Using ZFS:
- No action needed
- Using BtrFS:
- No action needed
- Using EXT4 on LVM:
# lvextend -L _SizeToIncreaseTo_ /dev/TESTPOOL/DATA
# resize2fs /dev/TESTPOOL/DATA
- Using ZFS:
-
Task: Remove a disk from the pool
- Using ZFS: N/A
- Using BtrFS:
# btrfs device delete /dev/A /data
# btrfs filesystem balance /data
- Using EXT4 on LVM:
# pvmove /dev/A
# vgreduce TESTPOOL /dev/A
-
Task: Replace operational disk
- Using ZFS:
# zfs replace TESTPOOL A D
- Using BtrFS:
# btrfs device add /dev/D /data
# btrfs device delete /dev/A /data
# btrfs filesystem balance /data
- Using EXT4 on LVM:
# pvcreate /dev/D
# vgextend TESTPOOl /dev/D
# pvmove TESTPOOL /dev/A /dev/D
# vgreduce TESTPOOL /dev/A
- Using ZFS:
-
Task: Take a snapshot of a filesystem
- Using ZFS:
# zfs snapshot TESTPOOL@snapshot1
- Using BtrFS:
# btrfs subvolume snapshot /data /data/snapshot1
- Using EXT4 on LVM:
# lvcreate -s /dev/TESTPOOL/DATA -L _SizeToAllocate_ -n snapshot1
- Using ZFS:
-
Task: Rollback a snapshot
- Using ZFS:
# zfs rollback TESTPOOL@snapshot1
- Using BtrFS:
- Not sure...
- Using EXT4 on LVM:
# lvconvert --merge /dev/TESTPOOL/snapshot1
- Using ZFS:
-
Task: Delete a snapshot
- Using ZFS:
# zfs destroy TESTPOOL@snapshot1
- Using BtrFS:
# btrfs subvolume delete /data/snapshot1
- Using EXT4 on LVM:
# lvremove /dev/TESTPOOL/snapshot1
- Using ZFS:
Top comments (4)
For Task 8: Rollback a snapshot, you say "not sure" for btrfs. The answer is that snapshots are completely equivalent to subvolumes, so you just start using (and mounting, if appropriate) the snapshot instead of the "original" subvolume (and delete that one if you want).
Oh, and you can put a swapfile on a btrfs filesystem nowadays, as well as any kind of other file that is meant to serve as storage for a block device (such as VM images, etc.). The key is to set the NoCOW attribute on the subvolume or directory those files live in; that done, today's btrfs is no worse for this usecase than any other filesystem.
I'm really curious what you mean by CLI integration... the footnote doesn't help. Please explain your "subjective" understanding of this.
GRUB2 has been able to boot to LVM for a long time.