ZFS vs BtrFS
This guide is not a discussion on which is better: ZFS or BtrFS (While many may argue that the fundamental design of BtrFS is superior, it is an unavoidable fact that ZFS is far older and thus more mature in terms of features, stability, and usability). Rather, it is meant to be used as a practical administrative reference containing instructions for performing some basic tasks in BtrFS, targeted at administrators who may be more familiar with ZFS concepts.
Note 1: This table was generated using Btrfs v0.19, included in the 2.6.33 kernel shipped with Fedora 13.
Note 2: The btrfs command aggregates the functionality of several legacy commands: btrfsctl, btrfs-show, and btrfs-vol. Each of the tasks below can be accomplished with these legacy commands as an alternative.
| ZFS Task | ZFS Command | Notes | BtrFS Command | BtrFS Equivalent Task |
|---|---|---|---|---|
| Create a mirrored pool and mount it | # zpool create mirror c0t0d0 c0t1d0 pool1 | ZFS top-level filesystem is automatically mounted at /<poolname>
Multi-device BtrFS top-level filesystem can be mounted using any device in the “pool.” |
# mkfs.btrfs -L pool1 -d raid1 -m raid1 /dev/sda /dev/sdb
# mkdir /pool1 # mount /dev/sda /pool1 |
Create a mirrored filesystem and mount it |
| Find and Import an existing zpool | # zpool import
# zpool import pool1 |
# btrfs device scan # mount /dev/sda /pool1 |
Find and Mount an existing BtrFS filesystem | |
| Expand a pool (dynamic restriping) | # zpool add pool1 c0t2d0
or # zpool add pool1 mirror c0t2d0 c0t3d0 |
ZFS: possible to convert from RAID1 to RAID10 using this method
BtrFS: metadata must be balanced to the new device after adding |
# btrfs device add -a /dev/sdc /pool1 # btrfs device balance /pool1 |
Expand a filesystem (dynamic restriping) |
| Convert to mirror | # zpool attach pool1 c0t0d0 c0t1d0 | Note yet possible in BtrFS |
N/A
|
Convert to mirror |
| Shrink a pool | N/A | Not yet possible in ZFS |
# btrfs device delete /dev/sdc /pool1
|
Shrink a filesystem |
| Replace failed or missing device | # zpool replace pool1 c0t1d0
or # zpool replace pool1 c0t1d0 c0t4d0 |
ZFS: if disk has already been physically replaced, bring the replacement into the pool, otherwise swap bad disk with a good one in another location
BtrFS: Remove the disk if its superblock can still be read, otherwise remount the fs in degraded mode and remove the “missing” device. Can be done live: unknown |
# btrfs device delete /dev/sdc /pool1 or # mount -o degraded /dev/sdb /pool1 # btrfs-vol -r missing /pool1 # btrfs device add /dev/sdb /pool1 # btrfs device balance /pool1 |
Remove failed or failing disk, then add its replacement and balance the metadata |
| List pool devices | # zpool status | # btrfs filesystem show | List filesystem devices | |
| Create a child filesystem (dataset) | # zfs create pool1/dset1 | A ZFS dataset refers to a ZFS object of type filesystem, snapshot, clone, or (block) volume.
A BtrFS subvolume is analogous to a ZFS child filesystem dataset |
# btrfs subvolume create /pool1/svol1 | Create a subvolume |
| Change the mountpoint of a child filesystem | # zfs unmount pool1/dset1 (optional)
# zfs set mountpoint=/apps pool1/dset1 # zfs mount pool1/dset1 |
ZFS:
-Do not mv a ZFS dataset mountpoint directory while the FS is mounted -zfs mount/unmount takes either the dataset name or the mountpoint as an argument |
# mkdir /apps
# mount -o subvol=svol1 /dev/sdb /apps |
Mount a subvolume at an alternate location |
| Rename a dataset | # zfs rename pool1/dset1 pool1/dsetA | # mv /pool1/svol1 /pool1/svolA | Rename a subvolume | |
| Create a read-only snapshot | # zfs snapshot pool1/dset1@snap1 | In BtrFS, a snapshot is just a subvolume that has initial data | unknown | Create a read-only snapshot (subvolume) |
| Create a writable snapshot (clone) | # zfs snapshot pool1/dset1@snap1
# zfs clone pool1/dset1@snap1 pool1/dset1_clone |
In BtrFS, a snapshot is just a subvolume that has initial data | # btrfs subvolume snapshot /pool1/svol1 /pool1/snap1 | Create a writable snapshot (subvolume) |
| Rollback a snapshot | # zfs rollback pool1/dset@snap1 | # btrfs subvolume delete /pool1/svol1
# mv /pool1/snap1 /pool1/svol1 |
Rollback a snapshot | |
| Delete a snapshot | # zfs destroy pool1/dset1@snap1 | # btrfs subvolume delete /pool1/snap1 | Delete a snapshot subvolume | |
| Delete a dataset | # zfs destroy pool1/dset1 | ZFS: clones depend on snapshots which depend on base datasets. These must be destroyed from the “outside in,” but one can promote a clone to become a base dataset, such that what was the base becomes a dependent clone (see below) | # btrfs subvolume delete /pool1/svol1 | Delete a subvolume |
| Promote a clone | # zfs promote pool1/dset1_clone | Rotates dependency of base ← snapshot ← clone, such that what was the clone is now a base and the static snapshot represents an old image of this base dataset. What once was the base is now the clone in the dependency line. | N/A | N/A |
| Limit the size of a dataset | # zfs set quota=10G pool1/dest1 | # btrfs filesystem resize 10g /pool1/svol1 | Limit the size of a subvolume | |
| Restore full size of a dataset | # zfs set quota=off pool1/dset1 | # btrfs filesystem resize max /pool1/svol1 | Restore full size of a subvolumeq | |
| Create a virtual block device | # zfs create -V 10G pool1/zvol1 | Not yet possible in BtrFS | N/A | Create a virtual block device |
| List all child datasets | # zfs list
OR # zfs list -o name,used,avail,mountpoint,mounted |
# btrfs subvolume list /pool1 OR # mount -o subvol=. /dev/sda /mnt # ls /mnt |
List all subvolumes | |
| Enable compression | # zfs set compression=on pool1/dset1 | ZFS: can be done live, applies only to newly written files | # mount -o subvol=svol1 -o compress /dev/sda /apps | Enable compression |
| Convert from legacy FS | Solaris Live Upgrade or just cp | ZFS: no direct conversion, must copy data to pool
BtrFS: Creates BtrFS with ext3/4 data accessible as a snapshot/subvolume |
https://btrfs.wiki.kernel.org/index.php/Conversion_from_Ext3 | Convert from legacy FS |
| Snapshot OS (root filesystem) | Solaris 10:
# lucreate;luactivate (preferred) OR # zfs snapshot -r rpool/ROOT@`date` (repeat for zones) OpenSolaris: beadm create; beadm activate (preferred) OR # zfs snapshot -r rpool/ROOT@`date` (repeat for zones) |
# btrfs subvolume snapshot / /root_snap1
Then edit boot loader/initrd to mount root fs with -o subvol=root_snap1 |
Snapshot OS | |
| Upgrade OS leveraging snapshots | Solaris 10: lucreate;luupgrade;luactivate
OpenSolaris: pkg image-update |
# yum install yum-plugin-fs-snapshot
# yum update |
Update Packages leveraging snapshots | |
| Check and repair corruption (scrub) | # zpool scrub pool1 | BtrFS: currently, btrfsck can only identify errors, not correct them. Similarly, checksum inconsistencies are flagged, but not repairable. Rebalancing may help in some cases | # btrfsck /dev/sda
# btrfs device balance /dev/sda/ |
Check for corruption (fsck) |
| Defragment | N/A | ZFS: Feature coming with block pointer rewrite implementation | # btrfs filesystem defragment /pool1 | Defragment |
| Identify space usage | # zfs list | BtrFS: output will be (somewhat) less confusing in 2.6.34. See https://btrfs.wiki.kernel.org/index.php/Gotchas | # btrfs filesystem df /pool1 | Identify space usage |
List of things ZFS can do that BtrFS can’t (yet):
Disks/RAID/Integrity
Convert to a mirror
Split mirror (leaving pool identity on secondary disk intact)
Convert from RAID1 to RAID10
Replace disk live
Deduplication
RAIDZ/RAIDZ2/RAIDZ3
Block pointer rewrite: convert RAID types, expand RAIDZ
Automatic checksum healing
Recover uberblock
Space management
Clearly report space usage
User/group space accounting
Set reservation/refreservation/refquota
Enable compression live
Administrative options
COMSTAR integration
Solaris Zones integration
Solaris Live Upgrade integration
Delegated administration
Integrated exporting (CIFS/NFS/iSCSI)
NFSv4 ACLs/inheritence properties
Mixed case sensitivity
ZFS Send/Receive
Performance tuning
Separate ZIL
Tunable ARC cache
Cache devices
ABOUT US
Seeds of Genius, Inc. offers a full range of IT solutions including hardware and software products in addition to consulting, installation and support services. For more information, please visit our main web site at http://www.seedsofgenius.com or contact our Technical Sales department at (410) 312-9806.