What is ZFS and Why Should I Use it?
Endless scalability
Well, it’s not technically endless, but it’s a 128-bit file system that’s capable of managing zettabytes (one billion terabytes) of data. No matter how much hard drive space you have, ZFS will be suitable for managing it.
Snapshots and Clones
One of the other powerful features of ZFS is the ability to take snapshots, which allow you to preserve "point in time" versions of the filesystem.
Here's an example of a snapshot using the recursive (-r) flag...it will also create a snapshot of each sub-dataset using the same snapshot name.
----------
#
...
zfs
...
snapshot
...
-r
...
mypool/usr/ports@firstsnapshot
...
#
...
zfs
...
list
...
-t
...
all
...
-o
...
name,used,refer,written
...
NAME
...
USED
...
REFER
...
WRITTEN
...
mypool
...
10.5M
...
44.9K
...
44.9K
...
mypool/usr
...
10.1M
...
44.9K
...
44.9K
...
mypool/usr/ports
...
10.1M
...
10.0M
...
0
...
mypool/usr/ports@firstsnapshot
...
0
...
10.0M
...
10.0M
...
mypool/usr/ports/distfiles
...
43.4K
...
43.4K
...
0
...
mypool/usr/ports/distfiles@firstsnapshot
...
0
...
43.4K
...
43.4K
As
--------
...
you
...
can
...
see,
...
the
...
snapshots
...
initially
...
take
...
no
...
additional
...
space,
...
as
...
they
...
only
...
contain
...
the
...
data
...
that
...
already
...
exists
...
in
...
the
...
dataset
...
the
...
snapshot
...
belongs
...
to.
ZFS
...
snapshots
...
are
...
read-only,
...
but
...
they
...
can
...
be
...
accessed
...
via
...
a
...
hidden
...
".zfs"
...
directory.
...
This
...
allows
...
you
...
to
...
easily
...
restore
...
a
...
single
...
file
...
that
...
was
...
accidentally
...
modified
...
or
...
deleted:
--------
# ls -lh /mypool/usr/ports/.zfs/snapshot/firstsnapshot/ total 10247 -rw-r--r-- 1 root wheel 10M Nov 29 15:01 somefile
---------
...
ZFS has the "rollback" operation, which reverts all changes written since the snapshot:
Sending and Receiving Snapshots
ZFS lets you send snapshots of your pool or dataset and output it to a file. You can also pipe it to other commands. This can be used to send datasets over the internet, using SSH, and receive them on a remote host.
...
# zfs send -i mypool/myfiles@backup mypool/myfiles@laterbackup |
\ ssh you@remoteserver zfs receive -v otherpool/myfiles
Data Integrity
One of the major selling features of ZFS is the safety it provides. All data and metadata written are checksummed to ensure that the data has not become corrupted over time. Every time data is read from a ZFS pool, the checksum is calculated and compared to the checksum that was calculated when the data was originally written. If they do not match, it means the data has become corrupted on the storage. If you have a redundant ZFS pool, the corruption will be automatically repaired and noted in the status screen.
...
# zpool status mypool --------------------- pool: mypool state: ONLINE scan: resilvered 3.45M in 0h0m with 0 errors on Fri Nov 29 15:38:46 2013 config: NAME STATE READ WRITE CKSUM mypool ONLINE 0 0 0 raidz1-0 ONLINE 0 0 0 /tutorial/file1 ONLINE 0 0 0 /tutorial/file2 ONLINE 0 0 0 /tutorial/file3 ONLINE 0 0 0 /tutorial/file4 ONLINE 0 0 0 errors: No known data errors
---------------------
Drive pooling
The creators of ZFS want you to think of it as being similar to the way your computer uses RAM. When you need more memory in your computer, you put in another stick and you’re done. Similarly with ZFS, when you need more hard drive space, you put in another hard drive and you’re done. No need to spend time partitioning, formatting, initializing, or doing anything else to your disks – when you need a bigger storage “pool,” just add disks.
RAID
ZFS is capable of many different RAID levels, all while delivering performance that’s comparable to that of hardware RAID controllers. This allows you to save money, make setup easier, and have access to superior RAID levels that ZFS has improved upon.