How to install ZFS on Ubuntu Linux 16.04 LTS

Posted on in Categories , last updated August 2, 2016

How do I install the Z File System (ZFS) on Ubuntu Linux 16.04 LTS server and create RAID-1 (mirror)?

The Z File System (ZFS) was originally designed at Sun Microsystem. It is an advanced file system and logical volume manager. It works on Solaris, FreeBSD, Linux and many other operating systems. The features of ZFS include protection against data corruption, compression, volume management, snapshots, data integrity, Software RAID, cache and much more.

Installing ZFS on Ubuntu 16.04

Native OpenZFS management utilities for Linux are located in zfsutils-linux package. You can also use meta package called zfs. Simply type the following command:
$ sudo apt update
$ sudo apt install zfs

OR
$ sudo apt install zfsutils-linux
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'zfsutils-linux' instead of 'zfs'
The following additional packages will be installed:
  libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-doc zfs-zed
Suggested packages:
  default-mta | mail-transport-agent samba-common-bin nfs-kernel-server zfs-initramfs
The following NEW packages will be installed:
  libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-doc zfs-zed zfsutils-linux
0 upgraded, 7 newly installed, 0 to remove and 19 not upgraded.
Need to get 884 kB of archives.
After this operation, 2,822 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 zfs-doc all 0.6.5.6-0ubuntu10 [49.4 kB]
Get:2 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libuutil1linux amd64 0.6.5.6-0ubuntu10 [27.4 kB]
Get:3 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libnvpair1linux amd64 0.6.5.6-0ubuntu10 [23.5 kB]
Get:4 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libzpool2linux amd64 0.6.5.6-0ubuntu10 [385 kB]
Get:5 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 libzfs2linux amd64 0.6.5.6-0ubuntu10 [106 kB]
Get:6 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 zfsutils-linux amd64 0.6.5.6-0ubuntu10 [263 kB]
Get:7 http://mirrors.service.networklayer.com/ubuntu xenial-updates/main amd64 zfs-zed amd64 0.6.5.6-0ubuntu10 [29.8 kB]
Fetched 884 kB in 1s (651 kB/s)    
Selecting previously unselected package zfs-doc.
(Reading database ... 91925 files and directories currently installed.)
Preparing to unpack .../zfs-doc_0.6.5.6-0ubuntu10_all.deb ...
Unpacking zfs-doc (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package libuutil1linux.
Preparing to unpack .../libuutil1linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking libuutil1linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package libnvpair1linux.
Preparing to unpack .../libnvpair1linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking libnvpair1linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package libzpool2linux.
Preparing to unpack .../libzpool2linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking libzpool2linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package libzfs2linux.
Preparing to unpack .../libzfs2linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking libzfs2linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package zfsutils-linux.
Preparing to unpack .../zfsutils-linux_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking zfsutils-linux (0.6.5.6-0ubuntu10) ...
Selecting previously unselected package zfs-zed.
Preparing to unpack .../zfs-zed_0.6.5.6-0ubuntu10_amd64.deb ...
Unpacking zfs-zed (0.6.5.6-0ubuntu10) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for initramfs-tools (0.122ubuntu8.1) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-28-generic
Processing triggers for systemd (229-4ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up zfs-doc (0.6.5.6-0ubuntu10) ...
Setting up libuutil1linux (0.6.5.6-0ubuntu10) ...
Setting up libnvpair1linux (0.6.5.6-0ubuntu10) ...
Setting up libzpool2linux (0.6.5.6-0ubuntu10) ...
Setting up libzfs2linux (0.6.5.6-0ubuntu10) ...
Setting up zfsutils-linux (0.6.5.6-0ubuntu10) ...
zfs-import-cache.service is a disabled or a static unit, not starting it.
zfs-import-scan.service is a disabled or a static unit, not starting it.
zfs-mount.service is a disabled or a static unit, not starting it.
Processing triggers for initramfs-tools (0.122ubuntu8.1) ...
update-initramfs: Generating /boot/initrd.img-4.4.0-28-generic
Setting up zfs-zed (0.6.5.6-0ubuntu10) ...
zed.service is a disabled or a static unit, not starting it.
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for systemd (229-4ubuntu6) ...
Processing triggers for ureadahead (0.100.0-19) ...

What is a ZFS Virtual Devices (ZFS VDEVs)?

A VDEV is nothing but a collection of a physical disk, file image, or ZFS software raid device, hot spare for ZFS raid. Examples are:

  1. /dev/sdb – a physical disk
  2. /images/200G.img – a file image
  3. /dev/sdc1 – A partition

What is a ZFS pools (zpool)?

A zpool is nothing but a storage made of VDEVS (a collect of VDEVS). You can combine two or more physical disks or files or combination of both.

How do I create a standard RAID1 mirror (zfs mirror)?

Use the following syntax
zpool create NAME mirror VDEV1 VDEV2
To create ZPool mirror group called nixcraft, enter:
$ sudo zpool create nixcraft mirror /dev/sdb /dev/sdc

See the status of your ZPoll

Simply type the following command to see the current health status for ZPools:
$ zpool status
Sample outputs:

Fig.01: ZPool mirror in action
Fig.01: ZPool mirror in action

How do I check the size and usage of zpools?

Type the following command:
$ zpool list
$ df

How do I find out I/O statistics for ZPools?

Type the following command:
$ zpool iostat
Sample outputs:

               capacity     operations    bandwidth
pool        alloc   free   read  write   read  write
----------  -----  -----  -----  -----  -----  -----
nixcraft    2.64M   888G      0      2      0  6.38K

You can now start copying data or store data in /nixcraft:
$ cd /nixcraft
$ ls
$ cp /foo/ .

However, ZFS allows you to create file system. For example data or containers file systems in the pool called nixcraft:
$ sudo zfs create nixcraft/data
$ sudo zfs create nixcraft/containers
$ zfs list

Sample outputs:

NAME                  USED  AVAIL  REFER  MOUNTPOINT
nixcraft             2.67M   860G  2.59M  /nixcraft
nixcraft/containers    19K   860G    19K  /nixcraft/containers
nixcraft/data          19K   860G    19K  /nixcraft/data

How do I delete a zpool and all data stored in the pool called nixcraft?

$ sudo zpool destroy zpoolNameHere
$ sudo zpool destroy nixcraft
$ zpool status

See also
  1. man pages zpool
  2. Recommended book: FreeBSD Mastery – ZFS (our review)

2 comment

  1. ZFS was originally called The Zettabyte Filesytem (ZFS) but over time became just ZFS.

    “But zettabyte wasn’t perfect, actually. We (we were a team by now) found that when you call it the zettabyte filesystem, you have to explain what a zettabyte is, and by then the elevator has reached the top floor and all people know is that you’re doing large capacity. Which is true, but it’s not the main point.

    So we finally decided to unpimp the name back to ZFS, which doesn’t stand for anything. It’s just a pseudo-acronym that vaguely suggests a way to store files that gets you a lot of points in Scrabble…” Jeff Bonwick – ZFS developer
    ref: https://blogs.oracle.com/bonwick/en_US/entry/you_say_zeta_i_say

  2. Been using ZFS via the PPA for a couple of years now on my home media server (Plex). Love it. By far the easiest RAID system I have ever dealt with. Nice to see ZFS just built in now.

Leave a Comment