The COMSTAR way of creating Solaris iSCSI targets

If you’re used to the streamlined, straightforward method of creating iSCSI targets with Solaris you may have been a little perplexed to see an error something like this:

# cannot set property for ‘tank/iscsi/vol001′: invalid property ‘shareiscsi’

This is because the mechanism for creating and manipulating iSCSI has changed significantly in recent versions of Solaris.  I’m not sure why the original syntax wasn’t retained, but nevertheless, you can still achieve the same result with the following sequence:

  • Install the new COMSTAR package:
# pkg install pkg:/storage-server
  • Create your zfs volume as usual
# zfs create -V 200G tank/iscsi/vol001

This will create a 200Gb volume in the “tank” pool of type ‘volume’ (not ‘filesystem’)

  • Using the new sbdadm(1M) command, create a new logical unit based on the volume you just created:
# sbdadm create-lu /dev/zvol/rdsk/tank/iscsi/v001
Created the following LU:

GUID                              DATA SIZE            SOURCE
--------------------------------  -------------------  ----------------
600144f01cfe070000004e3df8200001  214748364800         /dev/zvol/rdsk/tank/iscsi/v001
  • Using the new stmfadm(1M) command, verify that you now have a logical unit available:
# stmfadm list-lu -v 600144F01CFE070000004E3DF8200001
LU Name: 600144F01CFE070000004E3DF8200001
    Operational Status: Online
    Provider Name     : sbd
    Alias             : /dev/zvol/rdsk/tank/iscsi/v001
    View Entry Count  : 1
    Data File         : /dev/zvol/rdsk/tank/iscsi/v001
    Meta File         : not set
    Size              : 214748364800
    Block Size        : 512
    Management URL    : not set
    Vendor ID         : OI
    Product ID        : COMSTAR
    Serial Num        : not set
    Write Protect     : Disabled
    Writeback Cache   : Enabled
    Access State      : Active
  • Add a view to the newly created object, otherwise we won’t be able to do anything with it :)
# stmfadm add-view 600144F01CFE070000004E3DF8200001
  • Turn on the required service, if you haven’t already.
svcadm enable -r svc:/network/iscsi/target:default
  • FINALLY you can now create the iSCSI target:
# itadm  create-target
Target iqn.1986-03.com.sun:02:1cfef154-fa27-4f03-de2d-946adda9eea4 successfully created

So there you go. Nowhere near as simple as setting a property on a ZFS filesystem, but you can eventually achieve the same result.

Summary:

  • Create volume
  • Create a scsi block device, using the newly-created volume as a backing store.
  • Create a logical unit using the previously created block device
  • Add a ‘view’ to the logical unit (think of this as making it visible to outsiders – giving them a ‘view’)
  • Create an iSCSI target

Simple, eh? :/

Virtualbox, iSCSI targets and teleport

Here’s a quick rundown on how to get Virtualbox running with iSCSI targets.

But first the why: why would you want to configure Virtualbox to use an iscsi target instead of a native disk image?

The answer is teleport.  Sure, you can use an NFS or CIFS share just as easily with teleport, but using iSCSI targets is just that little bit more fun.

If you’re just setting up a standalone virtualbox, stick with disk images on local filesystems.  The only reason to put your disk images on shared storage is so that teleport works.

For the uninitiated, teleporting is somewhat similar to VMWare’s “vMotion”.  It’s the term given to the process of moving the processing and networking of a virtual machine to a different physical host without any (much) interruption to the virtual host.

Unlike VMWare though, Virtualbox lets you teleport your VM to different types of machines.  That means you can teleport your VM from your linux machine to your Macbook Pro, over to your Opensolaris server and even to your Windows machine.  The only limitation seems to be that they must have the same processor family (Intel to AMD processors doesn’t appear to work… yet.)

In this example I’m using an Opensolaris server to serve iSCSI targets from my ZFS pool.  This gives me neat stuff like dedup and compression, as well as thin provisioning if I would like it.  It doesn’t matter if you’re using FreeBSD or indeed any other way of presenting iSCSI targets.

On the Opensolaris server:

  • Create a zfs volume to be your iSCSI target.  Here I have a zpool named “xpool”.# zfs create -V 20G xpool/targetThis will create a 20Gb volume.  To use thin provisioning, use the -s flag to the zfs create command)
  • Install the following packages if you haven’t already:
    SUNWiscsitu
    SUNWiscsitr
    SUNWiscsidmu
    SUNWiscsidmr
    SUNWstmf
    SUNWstmfu
  • Share the target:
    # zfs set shareiscsi=on xpool/target
    (Note: if you have more recent version of Solaris, this command may fail with “invalid property ‘shareiscsi’ “.  In that case, see this post for instructions)
  • Make note of the device’s ID:
    # iscsitadm list target
    Target: xpool/target
    iSCSI Name: iqn.1986-03.com.sun:02:74cedff0-250c-eacc-b509-bc930dc897d6
    Connections: 0

Now you can create your Virtualbox virtual machine.  I’m using the command line here.  You can repeat these steps quickly on any machine where you’d like to teleport the machine to.  Besides, who needs one of them fancy-pants GUIs, anyhow?

First – register the iSCSI target as a virtualbox disk:

# VBoxManage addiscsidisk –server 1.1.1.1 –target iqn.1986-03.com.sun:02:74cedff0-250c-eacc-b509-bc930dc897d6

Check that it worked…

# VBoxManage list hdds
Sun VirtualBox Command Line Management Interface Version 3.1.4
(C) 2005-2010 Sun Microsystems, Inc.
All rights reserved.

UUID:       dfab4e6a-4ad6-44fa-96e0-76d5504b92aa
Format:     ISCSI
Location:   1.1.1.1|iqn.1986-03.com.sun:02:74cedff0-250c-eacc-b509-bc930dc897d6
Accessible: yes
Type:       normal

Now we can go ahead and create our VM.  You can see what types of VMs your server will support with the command:

# VBoxManage list ostypes

It’s probably best to make sure that the type of server you’re going to build is supported on all the hosts you plan on teleporting it to.  It might save a bit of pain and anguish later..

This is a simple VM with an IDE controller and a single hard disk.  We attach an ISO image to the IDE controller as the second device in order to install our OS.  Later we can attach the Virtualbox additions ISO here, too.

# VBoxManage createvm –name testvm –ostype WindowsXP –basefolder /vbox –register
Sun VirtualBox Command Line Management Interface Version 3.1.4
(C) 2005-2010 Sun Microsystems, Inc.
All rights reserved.

Virtual machine ‘testvm’ is created and registered.
UUID: c8a5b6a3-6fb3-4b50-beb2-9a08e656392a
Settings file: ‘/vbox/testvm/testvm.xml’

Now we can add memory limits, disk controllers and disk devices:

# VBoxManage modifyvm testvm  –memory 1024 –cpus 4
# VBoxManage storagectl testvm –name “IDE Controller” –add ide –controller PIIX4
# VBoxManage storageattach testvm –storagectl “IDE Controller” –port 0 –device 0 –type hdd –medium dfab4e6a-4ad6-44fa-96e0-76d5504b92aa

# VBoxManage storageattach testvm –storagectl “IDE Controller” –port 0 –device 1 –type dvddrive –medium /vbox/XP.iso
# VBoxManage modifyvm testvm –nictype1 82545EM –nic1 bridged –bridgeadapter1 nge0
## !!! Adjust “nge0″ to suit your network interface name !!! ##
# VBoxManage modifyvm testvm –vrdp on

Once that’s done, boot it and connect via RDP to your host to install your operating system.

# VBoxManage startvm testvm –type vrdp

While the operating system is installing, repeat the steps on another machine, but don’t power it on.  Remember to change the “bridgeadapter” to the appropriate interface name.  (Note: You don’t need to use a NIC at all in our VM and this will still work, but what use is a VM without network access?)

Teleporting virtualbox vms

Once you’re set up, you can move VMs around like this:

1. On the host machine that you want to move the virtual machine to:  (In  this example we’ll assume our destination has IP address 1.1.1.20 and our source has IP address 1.1.1.10)

# VBoxManage modifyvm testvm –teleporter on –teleporteraddress 1.1.1.20 –teleporterport 54321

2. On the host machine, you can now power it on, and it should sit idle waiting for a teleport request to arrive from 1.1.1.10.

# VBoxManage startvm testvm –type vrdp

3. On the host machine that has the running virtual machine:

# VBoxManage controlvm testvm teleport –host 1.1.1.10 –port 54321

Once the progress bar hits 100%, you’re done!


 

Technorati Tags: , , , , ,