Useful commands for ZFS on Linux. Less “Getting Started,” more “How Did I Get it Started Before?”

Tested on Linux Mint 18.3. This guide is not yet complete.

All commands are expected to be run as root. Use sudo in front of these commands if you are not root user.

Checking on Things

ZPool Status

See what pools are online, last scrub time, and if they have any errors.

zpool status

ZFS List

Check every pool and file system that is currently active

zfs list

ZFS Import

Can’t find a pool? Look for it here.

zfs import

ZFS Get

zfs get compressratio pool/dataset

Amount of effective compression in a dataset as a ratio.

Make a Pool

Don’t format your disks or anything. ZFS does that for you.

zpool create -f pool /dev/DRIVE1 /dev/DRIVE2 ...

pool is whatever you want your zpool to be called. This is like a hostname, pick a good one, it’s a pain to change.

/dev/DRIVEx just enter the names of your drives you want in the zpool

There is no confirmation, whatever disks you tell it to mess with will be used and that’s final. Be careful!

Add Pool To Cache

Allegedly automatic, but may fail, resulting in your pool not importing on boot.

zpool set cachefile=/etc/zfs/zpool.cache pool

Make a Dataset (ZFS Filesystem)

zfs create pool/dataset

Datasets are required for snapshots and bookmarks, as well as file stuff such as quota and compression for directories.

Quota

zfs set quota=5G pool/dataset

5G quota size.

pool/dataset

Compression

zfs set compression=lz4 pool/dataset

lz4 is the recommended compression format based on speed vs compression ratio

You may not immediately notice tangible benefits from compression as most already compressed files such as video (mp4, mov, …), photos (jpg), and music (mp3, flac, …) actually become larger when compressed. ZFS is very smart about not compressing files that won’t get smaller. This is a good thing.

Tested on the MacPro 1,1 running Linux Mint 18.3 Xfce 64-bit

The pool used in the real world testing of this reference was composed of 4 Western Digital 1TB Green Drives attached via a SFF-8088 External SAS to 4x SATA cable connected to an LSI HBA.

References:

https://www.howtogeek.com/175159/an-introduction-to-the-z-file-system-zfs-for-linux/
https://www.howtogeek.com/272220/how-to-install-and-use-zfs-on-ubuntu-and-why-youd-want-to/
https://www.servethehome.com/the-case-for-using-zfs-compression/
https://www.thegeekstuff.com/2015/11/zfs-filesystem-compression/comment-page-1/
https://wiki.archlinux.org/index.php/ZFS
https://github.com/zfsonlinux/zfs/wiki/faq#generating-a-new-etczfszpoolcache-file
https://www.reddit.com/r/zfs/comments/62k6lo/zol_debian_stretch_gzip9_compression_not_working/
https://serverfault.com/questions/906285/zfs-does-not-compress-files-and-all-settings-look-correct