Turn existing VMDK into ZFS VOL and use ISCSI to access it from different system

I have several servers running Solaris 10u9 with VirtualBox server installed. Each of those hosts can manage several guest. Currently I use VirtualBox multiattach image types to clone guests from master images. This doesn't require me to use clonehd on the master images, which is a very time consuming process.

The new guest immediately creates a snapshot and writes its changes as a differential image instead:

serverA> v showhdinfo 6fad07e6-10c0-4aef-ae24-b45b024aad23
UUID:                 6fad07e6-10c0-4aef-ae24-b45b024aad23
Accessible:           yes
Logical size:         5000 MBytes
Current size on disk: 205 MBytes
Type:                 normal (differencing)
Storage format:       VDI
Format variant:       differencing default
In use by VMs:        bullhead07 (UUID: f8edbc59-660f-4384-b8f3-8e73e884bc5a)
Location:             /VMs/bullhead07/Snapshots/{6fad07e6-10c0-4aef-ae24-b45b024aad23}.vdi
Auto-Reset:           off

This works great but still requires a copy of the master image on every host server.

Since VirtualBox supports iSCSI targets natively, and my host is Solaris supporting iSCSI with ZFS, I decided to convert my existing master VMDK into a ZFS vol and make it an iSCSI target to be used from other servers.

First I created a ZVOL

serverA> zfs create -o shareiscsi=on -V 20G kahoona/masterImage

Now turn the existing master VMDK into the ZVOL (v is an alias for VBoxManage)

serverA> v internalcommands converttoraw /VMs/masterImage.vdi /VMs/masterImage.img
Converting image "/VMs/masterImage.vdi" with size 52428800000 bytes (50000MB) to raw...
serverA> dd if=/VMs/masterImage.img of=/dev/zvol/rdsk/kahoona/masterImage

Next I determined the iSCSI name for my new disk

serverA> iscsitadm list target
Target: kahoona/masterImage
    iSCSI Name: iqn.1986-03.com.sun:02:004a92c5-6c33-69b8-d1d9-b65c3b44f179
    Connections: 1

Last but not least I attached this new disk to an existing VM on another server

serverB> v storageattach bullhead08 --storagectl IDE --device 0 --port 0 --type hdd --medium iscsi  --server --target iqn.1986-03.com.sun:02:004a92c5-6c33-69b8-d1d9-b65c3b44f179

Now I can use ZFS clones to generate new copies of the master image and make those accessible via iSCSI

Your rating: None Average: 4.8 (11 votes)