Skip to Content

How to Install ZFS on Ubuntu 16.04 and Create a Storage Pool

This tutorial will show you how to install ZFS on Ubuntu 16.04 and you’ll learn how to configure a ZFS storage pool.

Installing ZFS

In 2005 ZFS was made open source as part of OpenSolaris and has since been ported to many Unix-like operating systems, including Ubuntu Linux.

Unlike FreeBSD, ZFS is not part of the Linux base installation due to licensing issues, which is a shame because it would be nice to install Ubuntu on a ZFS pool.

In any case, we can still run ZFS on Linux by installing it with the following command.

sudo apt-get install -y zfsutils-linux

You can check to see if ZFS was installed by running.

sudo zpool status

The output will say “no pools available”.

Creating ZFS Storage Pool on Ubuntu 16.04

In the following example, we will create a RAIDZ-2 Storage Pool using 4 hard disks. In ZFS RAIDZ-2 is like hardware RAID 6 in that two hard disks can fail before the data on the volume is lost.

Step 1: Find out the names of the hard disks by running the following command.

sysadmin@uss01:~$ ls -l /dev/sd*
brw-rw---- 1 root disk 8,  0 Oct 17 18:07 /dev/sda
brw-rw---- 1 root disk 8,  1 Oct 17 18:07 /dev/sda1
brw-rw---- 1 root disk 8,  2 Oct 17 18:07 /dev/sda2
brw-rw---- 1 root disk 8,  5 Oct 17 18:07 /dev/sda5
brw-rw---- 1 root disk 8, 16 Oct 17 18:07 /dev/sdb
brw-rw---- 1 root disk 8, 17 Oct 17 18:07 /dev/sdb1
brw-rw---- 1 root disk 8, 18 Oct 17 18:07 /dev/sdb2
brw-rw---- 1 root disk 8, 21 Oct 17 18:07 /dev/sdb5
brw-rw---- 1 root disk 8, 32 Oct 17 18:07 /dev/sdc
brw-rw---- 1 root disk 8, 48 Oct 17 18:07 /dev/sdd
brw-rw---- 1 root disk 8, 64 Oct 17 18:07 /dev/sde
brw-rw---- 1 root disk 8, 80 Oct 17 18:07 /dev/sdf

Notice /dev/sdc, /dev/sdd, /dev/sde and /dev/sdf don’t have any partitions. These are the 4 blank hard disks that will be used.

Step 2: Add a GPT label to each virtual disk so that ZFS does not complain about the disks having an_invalid vdev specification_ when running the zpool create command in the next step.Advertisements

root@uss01:~# parted /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
(parted) q

root@uss01:~# parted /dev/sdd
GNU Parted 3.2
Using /dev/sdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
(parted) q

root@uss01:~# parted /dev/sde
GNU Parted 3.2
Using /dev/sde
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
(parted) q

root@uss01:~# parted /dev/sdf
GNU Parted 3.2
Using /dev/sdf
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
(parted) q

Step 3: Create the RAIDZ-2 Storage Pool and view the status.

root@uss01:~# sudo zpool create tank raidz2 sdc sdd sde sdf
root@uss01:~# zpool status
  pool: tank
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        tank        ONLINE       0     0     0
          raidz2-0  ONLINE       0     0     0
            sdc     ONLINE       0     0     0
            sdd     ONLINE       0     0     0
            sde     ONLINE       0     0     0
            sdf     ONLINE       0     0     0

errors: No known data errors

Step 4: Check to see if the pool has been mounted and that we can write data to it.

root@uss01:/# echo "Hello World" > /tank/test.txt
root@uss01:/tank# cat /tank/test.txt
Hello World

That’s it. ZFS on Ubuntu Server 16.04.

ZFS is easy to get running on Linux, especially Ubuntu 16.04 as it’s part of the official repositories.