====== ZFS ======
* [[Filesystems]]
* [[FreeBSD]]
* [[http://zfsonlinux.org/|ZFS On Linux]]
* [[https://pthree.org/2012/04/17/install-zfs-on-debian-gnulinux/|ZFS Administration]] - the definitive guide to ZFS on Linux
* [[http://www.freebsd.org/doc/handbook/filesystems-zfs.html|FreeBSD Handbook: ZFS]]
* [[http://blog.thefrog.net/2008/04/zfs-on-freebsd.html|ZFS on FreeBSD]]
* [[http://www.solarisinternals.com/wiki/index.php/ZFS_Evil_Tuning_Guide|ZFS Evil Tuning Guide]]
==== 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 ====
* [[https://pthree.org/2012/12/18/zfs-administration-part-xi-compression-and-deduplication/|Compression and Deduplication]]
Disable compression:
zfs set compression=off tank/dataset
==== ZFS Snapshots ====
* [[https://pthree.org/2012/12/19/zfs-administration-part-xii-snapshots-and-clones/|Snapshots and Clones]]
* [[http://docs.oracle.com/cd/E19253-01/819-5461/gbiqe/index.html|Displaying and Accessing 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"