How to Install ZFS and Present a ZVOL through iSCSI in Ubuntu 14.04

How to Install ZFS and Present ZVOL through iSCSI


1 – Create a new VM in Hyper-V

We will perform this lab in Microsoft Hyper-V. So the first step is to create a new VM with Network connection. Next, we will add 10 disks to the VM (in addition to the main disk created during the VM creation process). I will demonstrate the creation of 10 disks using PowerShell.

In E:\Script, I have the script to add drives. I call it CreateAndAttachDisks.ps1.

The script content is as follows:

$i = 0
    New-VHD -SizeBytes 1GB -Path E:\VDisks\MyVHD$i.vhdx
    Add-VMHardDiskDrive -VMName ZFS -Path E:\VDisks\MyVHD$i.vhdx -ControllerType SCSI -ControllerNumber 0 -ControllerLocation $i
while ($i -lt $MAX_NUMBER_OF_VDISKS)

Execute this script by changing your working directory to E:\Scripts, then typing:


The VM will have 10 extra virtual disks attached to its SCSI Controller.

2 – Install Ubuntu 14.04

Insert the Ubuntu DVD (or an ISO) and install the OS using the normal default process. At the end you might want to enable OpenSSH server to be installed.

Choose the language as English.

Choose Install Ubuntu Server.

Language is English

Country is Canada

Don’t detect keyboard layout.

Setup keyboard as English.

Keyboard layout is English.

Host name is zfs

Full name for the user

User account


Verify password

Do not encrypt home directory

Tme Zone is Eastern

Use entire disk

Choose the first disk (sda)

Allow make changes to disk

Leave HTTP Proxy blank

No automatic updates

Install OpenSSH server.

Install the GRUB boot loader

Installation is finish, press Continue.

The server will be restarted automatically. Once it is up, login.

Type sudo su to elevate the account. The prompt changes from $ to #.

To get the IP address of the ZFS server, type ifconfig. In my case, it is


Make sure you are able to ping a host on the Internet. If you are not able to ping a host on the Internet, check DNS settings. In the case below, I cannot ping external hosts by DNS name but I could piong it by IP address.

Make sure the file resolve.conf has correct nameserver settings.

After updating the nameservers we should be able to ping a host on the Internet by its DNS name.

Now perform updates:

apt-get update

Then perform upgrade, use the following command. (When prompted to continue, confirm with a ‘Y’).

apt-get upgrade

Restart the system with the following command.

shutdown –r –time 0


3 – Installing ZFS

A – Add ZFS repository

Apt-get install software-properties-common

apt-add-repository ppa:zfs-native/stable

B – Update Repository

apt-get update


C – Install ZFS for Ubuntu

apt-get install ubuntu-zfs


In the Hyper-V preparation, we have prepared ten virtual disks and attached them to the VM. We can list these disks by using the parted command.


print devices


Create Pool and Dataset

zpool create myPool mirror –f /dev/sdb /dev/sdc

zfs list

zpool status

zfs create –s –V 500gb myPool/iscsivol

Check the ZFS Pool and dataset

zfs list

zpool status

Let’s create a RAIDZ1 (1 disk is allowed to fail without losing data) out of disks sdd, sde, and sdf

And let’s create a RAIDZ2 (2 disks are allowed to fail without losing data) out of disks sdg, sdh, sdi, sdj, and sdk.

Check the pool status.

So far, we have create three storage pools. The first one is a mirror pool. Out of this mirror pool, we created a dataset called myPool/iscsidata so that later we will present it through the iscsi channel. The second pool is a Raidz1 pool which contains three disks. The last pool we created was a Raidz2 pool which contains five disks. The second and third pools are created because we wanted to practice creating ZFS storage pools. The first pool alone is sufficient for completing the remaining of this lab.

Install iSCSI Target.

aptitude install iscsitarget iscsitarget-source iscsitarget-dkms

vi /etc/default/iscsitarget

check that


vi /etc/iet/ietd.conf


Target iqn.2015-08.myPool:storage.iscsivol

Lun 0 Path=/dev/zd0,Type=fileio

Restart iscsitarget service

service iscsitarget restart



On a Windows 7, 8. 8.1, or 10 box, we can use iSCSI Initiator to connect to the target and use diskmgmt.msc to access the drive.

To do that, I will demonstrate this using Windows 7. Click the Start Orb. Type iscsi and click to launch iSCSI Initiator. You will be asked to start the iSCSI service. Click Yes to do so.

After the iSCSI service has been started, you will see the iSCSI Initiator Properties box show up.

Click the Discovery tab, click Discover Portal…

Type in the IP address of the ZFS server and click OK.

Click the Target tab and you will see the target showing up but in an Inactive state. Click Connect.

Click OK.

The status changes to Connected. Click OK.

Click the Start Orb (in Windows 7), type:


Press Enter. A new disk is discovered and you are prompted to initialize that disk. Click OK to do so.

The disk will show up with capacity of 1GB.

At this point, we can just right-click on the disk to create a partition, format it with an NTFS file system to use it like any normal disk.