Less known Solaris Features: iSCSI - Part 4: Alternative backing stores
Albeit it´s very easy to use iSCSI in conjunction with ZFS emulated volumes it doesn´t have to be this way. You can use different kinds of backing store for iSCSI
File based iSCSI target
One way to provide for storage for an iSCSI target. You can use files for this task. Okay, we have to login as root on theoden:
At first we´ve created an directory to keep the files, then we tell the target daemon to use this for storing the target.After this we ca create the target:
Now we can check for the iSCSI Target.
Now we switch to the server we use as an initiator. Let´s scan for new devices on gandalf. As we´ve activated the discovery of targets before, we´ve just have to scan for new devices.
Et voila, an additional LUN is available on our initiator.
Thin-provisioned target backing store
One nice thing about ZFS is it´s ability to provide thin provisioned emulated zfs volumes (zvol). You can configure a volume of an larger size than the physical storage you have available. This is useful, when you want to have an volume in it´s final size (because resizing would be a pain in the a…) but don´t want do spend the money for the disks because you know that much less storage would be needed at first.
It´s really easy to create such a kind of a zvol:
That´s all. The difference is the small -s. It tells ZFS to create an sparse (aka thin) provisioned volume.
Well, I won´t enable iSCSI for this by shareiscsi=on itself. I will configure this manually. As normal volumes zvols are available within the /dev tree of your filesystem:
Okay, we can use this devices as a backing store for an iSCSI target as well. We´ve created a zvol bigvolume within the zpool testpool. Thus the device is /dev/zvol/dsk/testpool/bigvolume:
Okay, i´m swiching to my root shell on the initiator. Again we scan for devices:
Let´s create an zpool:
Do you remember, that we used four 128 MB files as the devices for our zpool on our target. Well, you have an 1.98G filesytem running on this files. You can add more storage to the zpool on the target and you have nothing to do on the initiator. Not a real kicker for ZFS, but imagine the same for other filesystem that can´t be grown so easy like a zpool.