Official support for the ZFS file system is one of Ubuntu 16.04’s big features. It’s not installed and enabled by default, but it’s officially supported and offered in Ubuntu’s software repositories.
When You Might Want to Use ZFS
ZFS is an advanced file system originally created by Sun Microsystems for the Solaris operating system. While ZFS is open source, it’s sadly been absent from most Linux distributions for licensing reasons. It’s a matter of debate whether code licensed under ZFS’s CDDL license is compatible with the Linux kernel’s GPL license. Either way, it’s available for download at zfsonlinux.org for other Linux distributions that don’t choose to include it.
This file system is often used by organizations for larger servers rather than desktop PCs. It’s designed to preserve data integrity by preventing against data corruption. Every file has a checksum that is used to validate the file and ensure it hasn’t been corrupted. It’s also capable of managing zettabytes of data, so you can have very large storage devices–that’s where the “Z” in the name originally came from. ZFS also allows you to easily pool multiple drives into a larger single pool of storage and can work with multiple disks using a software RAID, so it needs no special hardware to do advanced things with standard disks.
While you may not want to bother with this on your desktop computer, ZFS could be useful for a home server or network attached storage (NAS) device. If you have multiple drives and are especially concerned with data integrity on a server, ZFS may be the file system for you. Even on a workstation, you could use ZFS to pool your disks into a single large pool of storage rather than keep them separate or rely on LVM.
How to Install ZFS on Ubuntu 16.04
While ZFS isn’t installed by default, it’s trivial to install. It’s officially supported by Ubuntu so it should work properly and without any problems. However, it’s only officially supported on the 64-bit version of Ubuntu–not the 32-bit version.
To install ZFS, head to a terminal and run the following command:
sudo apt install zfs
Just like any other app, it should install immediately.
How to Create a ZFS Pool
ZFS uses the concept of “pools”. A ZFS pool can be created from one or more physical storage devices. For example, let’s say you have three physical hard drives. You can combine them into a single ZFS storage pool with one of the following commands.
The below command creates a RAID 0 configuration where the data is stored across all three disks with no redundant storage. If any of the physical disks fails, your file system will become damaged. (As such, this is rarely recommended–if you do use it, make sure you keep regular backups of the pool.)
sudo zpool create pool-name /dev/sdb /dev/sdc /dev/sdd
The next command creates a RAID 1 configuration where a complete copy of the data is stored on each disk. You’d still be able to access all your data, even if two of the three disks fail.
sudo zpool create pool-name mirror /dev/sdb /dev/sdc /dev/sdd
Whichever command you choose, replace
pool-name with whatever you want to name the storage pool. Replace
/dev/sdb /dev/sdc /dev/sdd with the list of disk names you want to combine into the pool.
You can find the device names using the
sudo fdisk -l command, which will list your installed storage devices.
Once you’ve created one or more pools, you can use the following command to check the status of your ZFS pools:
sudo zpool status
The pool will be mounted under the root directory by default. So, if you created a pool named
pool-name , you’d access it at
To add another disk to a zpool, you’d use the following command, providing the path to the device.
sudo zpool add pool-name /dev/sdx
And, if you wanted to destroy the pool, you’d use the following command:
sudo zpool destroy pool-name
This is just getting started with ZFS. From here, you should understand what’s going on enough to dig through the more advanced documentation and command line options. For more detailed information, consult larger command references like Ubuntu’s own ZFS reference and the ZFS on Linux project documentation.