Provisioning KVM virtual machines on iSCSI with QNAP + virt-manager (Part 1 of 2)

Posted: May 4th, 2010 | Author: | Filed under: libvirt, Virt Tools | Tags: , | 10 Comments »

I recently got a rather nice QNAP NAS to replace my crufty, cobbled together home fileserver. Unpack the NAS, insert 4 SATA disks and turn it on. The first time it starts up, it prompts to set up RAID5 across the disks by default (overridable to any other RAID config or no RAID) and after a few minutes formatting the disks, it is up and running ready todo work. It exposes storage shares via all commonly used protocols such as SAMBA, NFS, FTP, SSH/SCP, WebDAV, Web UI, and most interestingly to this post, iSCSI. The QNAP marketing material is strongly pushing iSCSI as a solution for use in combination with VMWare but here in Fedora & the open source virt world it is KVM we’re interested in. libvirt has a fairly generic set of APIs for managing storage which allows impls for many different types of storage, including iSCSI. The virt-manager app provides a UI for nearly all of the libvirt storage capabilities, again including iSCSI. This blog posting will graphically illustrate how to deploy a new guest on Fedora 12 using virt-manager and the QNAP iSCSI service.

iSCSI Service Enablement

In the QNAP administration UI, navigate to the “Disk Management -> iSCSI” panel. Ensure the iSCSI Target Service is enabled and running on the default TCP port 3260. libvirt currently has no need for iSNS, so that can be left disabled unless you have other reasons for requiring its use.

iSCSI Service Enablement

iSCSI Service Enablement

iSCSI Targets

An iSCSI target is simply a means to group a set of LUNs (storage volumes). There are many ways to organize your targets + LUNs, but to keep things simple I’m going to keep all my KVM guest storage volumes in a single target and enable this target on all my virtualization hosts. Some people like the other extreme of one target per guest, and only enabling the guest’s target on the host currently running the guest. In this screengrab I’ve already got one iSCSI target for other experimentation and intend to use the ‘Quick Configuration Wizard’ to add a new one for my KVM guests.

iSCSI target list

iSCSI target list

iSCSI Target + LUN creation

Since this is my first guest, I need to create both he iSCSI target and a LUN. For future guests I can create the iSCSI LUN only and associate it with the previously created target.

iSCSI target/LUN creation wizard

iSCSI target/LUN creation wizard

Setting the iSCSI target name

Every iSCSI target needs a unique identifier, known as the IQN. For reasons I don’t want to understand, the typical IQN format is a rather unpleasant looking string, but fortuitously the QNAP admin UI only expects you to enter a short name, which it then uses to form the full IQN. In this example I’m giving my new iSCSI target the name “kvmguests” which results in the adorable IQN ““. Remember this IQN, you’ll need it later in virt-manager.

iSCSI target naming

iSCSI Target naming

iSCSI target authentication

iSCSI includes support for an authentication scheme known as CHAP. Unfortunately libvirt does not yet support configuration of iSCSI storage using CHAP, so this has to be left disabled. This sucks if you’re using a shared/untrusted local network between your virt hosts & iSCSI server, but if you’ve got a separate network or VLAN dedicated to storage traffic this isn’t so much of a problem. I also don’t care for home usage.

iSCSI target authentication

iSCSI target authentication

iSCSI LUN allocation

Now the iSCSI target is configured, it is time to allocate storage for the LUN. This is what will provide the guest’s virtual disk. Each LUN configured via the QNAP admin UI ends up being backed by a plain file on the NAS’ (ext4) filesystem. If you choose the “Thin Provisioning” option at this stage, the LUN’s backing file will be a sparse file with no storage allocated upfront. It will grow on demand as data is written to it. This allows you to over-commit allocation of storage on the NAS, with the expectation that should you actually reach the limit on the NAS some time later, you can simply swap in larger disks to the RAID array or attach some extra external SATA devices. “Instant allocation” meanwhile, fully allocates the LUN at time of creation so there is never a problem of running out of disk space at runtime. The LUN name is just an aid-memoir for the admin. I name my LUNs to match the KVM guest name, so this one is called “rhel6x86_64”. The size of 10 GB will be more than enough for the basic RHEL6 install I plan.

iSCSI LUN allocation

iSCSI LUN allocation

iSCSI setup confirmation

Before actually creating the iSCSI target and LUN, the QNAP wizard allows a chance to review the configuration choices just made.

iSCSI target + LUN creation summary

iSCSI target + LUN creation summary

iSCSI target list (updated)

After completing the wizard, the browser returns to the list of iSCSI targets. The newly created target is visible, with one LUN beneath it. The status of ‘Processing’ just means that storage for the LUN is still being allocated & goes away pretty much immediately for LUNs using ‘Thin provisioning’ since there’s no data to allocate upfront. In theory full allocation should be pretty much instantaneous on ext4 too, if QNAP is using posix_fallocate, but I’ve not had time to check that yet.

iSCSI target list (updated)

iSCSI target list (updated)

With the iSCSI target and LUN created, it is now time to provision a new KVM guest using this storage. This is the topic of Part II


[…] Part I of this posting, walked through the steps to create a iSCSI target and LUN on a QNAP server. Part II now considers provisioning guests using iSCSI storage from virt-manager. […]

[…] previous articles showed how to provision a guest on iSCSI the nice & easy way using a QNAP NAS and […]

Peter said at 5:47 pm on August 8th, 2010:

Hey. Is it possible to resize a LUN on your QNAP? Does it depend on what’s inside the LUN? Fx. LVM, EXT3, BTRFS?

Daniel Berrange said at 1:14 am on August 9th, 2010:

The QNAP doesn’t care what data is inside a LUN – it just provides the raw block device. So resizing is a multi-step process. Resize the LUN on the QNAP, and then resize any filesystem that’s inside it on your client / guest OS.

jason said at 11:42 pm on August 10th, 2010:

hello, i have a 419P set to raid 5 and a 410 set as raid 1. i have set the 419p to use the 410 for extra storage via iscsi. My question is, do i need the raid 1 on the 410 or does the 419p incorporate the 410 disc into its raid. ie if i set the 410 to raid 0 will the discs on the 410 be protected by the raid on the 419p.
many thanks

Daniel Berrange said at 2:21 am on August 11th, 2010:

@jason I’m afraid I don’t know enough about the way the QNAP does the NAS expansion over iSCSI to say how those RAID levels interact. Probably best to ask this question on the QNAP forums.

DR said at 12:37 pm on February 20th, 2011:

what model of qnap do you use? does all support iscsi target?

Daniel Berrange said at 4:40 pm on February 21st, 2011:

According to their website, all their storage arrays support iSCSI:

However, IIRC, in the QNAP forums it was said that the Intel based QNaps perform much better than the Arm based ones. The Intel ones also seem to get more frequent firmware updates.

Windows 10, kvm and iSCSI | Michiel's 0s & 1s said at 8:26 am on March 23rd, 2015:

[…] found a really good tutorial on setting up iSCSI on a QNAP NAS, which got me most of the way there. But then I had to install Windows. I spent some time fiddling […]

pakal98 said at 9:33 am on May 6th, 2018:

Nice tutorial !

Just for the update, Open-iSCSI configuration now supports CHAP authentification.

Follow QNAP link for instructions :


Leave a Reply

Spam protection: Sum of f0ur plus 3ight ?: