ZFS

BIG FAT WARNING

Do NOT use fuse with ZFS. If there is the slightest hiccup, the filesystem will crash and you will lose all your data.

Examples

Create a new ZFS filesystem

Use fdisk to edit the partition, and then set the type to bf or Solaris.

Create a new pool named tank using zpool, for example, using /dev/sdb

zpool create tank /dev/sdb
Create a ZFS RAID1
zpool create tank mirror /dev/sdb /dev/sdc
Create a dataset
zfs create tank/dataset
zfs create tank/dataset/child
Destroy a dataset
zfs destroy tank/dataset
Export / import a dataset

Useful for upgrading ZFS, moving things around, etc.

zpool export tank
zpool import tank

ZFS Compression

Disable compression:

zfs set compression=off tank/dataset

ZFS Snapshots

ZFS allows you to create incremental snapshots easily enough, using zfs snapshot.

Once a snapshot is created, ZFS will start using new space after data is modified.

Create a snapshot:

zfs snapshot tank/data@snapshot-name

List snapshots:

zfs list -t snapshot

Destroy an old snapshot:

zfs destroy tank/data@snapshot-name

You can access data directly from old snapshots by browsing the .zfs directory in the zfs tree. The directory is hidden by default, and does not need to be toggled as visible to browse. Simply accessing the directory is sufficient.

ls /tank/data/.zfs/snapshot/snapshot-name/

Note: There may be a simpler way to get this using native ZFS tools. Optionally, the .zfs directory can be toggled as visible so that it will show up using ls:

zfs set snapdir=visible tank/data
ls /tank/data/.zfs/snapshot/snapshot-name/
zfs set snapdir=hidden tank/data

FreeBSD

On FreeBSD, once you create a zpool or a dataset, it will automatically mount it. It will also mount it at boot.

Add this line to /etc/rc.conf:

zfs_enable="YES"