How to install and Use ZFS on Ubuntu 16.04

How to install and Use ZFS on Ubuntu 16.04


Use the following commands to install ZFS:

sudo su
apt update
apt install zfsutils-linux -y
modprobe zfs

To verify whether you have a successful installation, type this at the prompt:


You should see the following message showing ZFS command line usage.

We will create a ZPOOL based using spare files. This is a great way to test ZFS in virtual environments such as VMWare or Virtual Box.  Create three disk image files as follows:

Now create a ZPOOL called mypool with the three disks:

Once done, check the status of the pool:

To check the status of the ZPOOL, use the following command:

The above POOL is based on stripe disks.

To delete your datasets and pool, use the following commands:

Note that there is no redundancy to the ZPOOL we created earlier. In order to add redundancy, we should use mirror or raidz options to create the POOL. Let’s create a mirrored ZPOOL:

Note that the ZPOOL mypool is now indicated with mirror-0 configuration and the total capacity is only 12G. This means that all three disks are now participating in the mirror.

In summary, we can use the following configurations when appropriate:

Single disk: the disk failure will cause data lost.
raid0: Striping across disks, any drive failure will cause data lost.
raidz: This is RAID 5.  Use three drives and you can lose one drive before losing data.
raidz2: This is like raidz but you can lose two drives before losing your data.  At minimum you have to use 3 drives.
raidz3:  At minimum you have to use 4 drives and you can lose three drives before losing your data.
RAID 1: This is a mirror of two disks.
RAID 10: This is a stripe of two mirrored sets.  The command is:
zpool create mypool mirror disk1 disk 2 mirror disk3 disk4

Summary: In this lab, I have shown you how to install ZFS package on Ubuntu 16.04. From there we created two sample ZFS pools, one of which is a striped pool, and the other is a mirrored once for redundancy. We also used some accessory commands for checking into the pool for its status as well as listing all the available pools. Finally, we destroyed the pool when not in used.