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? :/

Mac OS X running as Virtualbox guest – inside Opensolaris container.

With the release of Virtualbox 3.2 beta Mac OS X “guests” are now supported. 

The following guide will show you how to get OS X running inside virtualbox using the command line interface.  It applies to any host operating system, but in this case we’re adding an additional virtualization layer on top of opensolaris.

Officially, so as not to run afoul of the Apple EULA, if you want to run OS X as a Virtualbox Guest you need to be running Virtualbox on Apple hardware.

So, let’s imagine that instead of a nice, 64 core Intel nehalem server I actually have a Mac Pro on which I am – for the sake of argument and somewhat inexplicably – running Opensolaris.

Today we’re not only going to show you how to get Mac OS X running in Virtualbox, but also how to run it on Virtualbox running inside an Opensolaris container, or zone.  Just in case you had, for example, a need to add resource controls, or clone multiple versions of your resulting OS X virtual machine, teleport running VMs to another server…

You will need a copy of a modified version of the OS X install DVD.  If you search around you might locate something called “iDeneb_v1.6_1058_Lite_Edition.iso” which is what I used for this example.

If you don’t care about the Opensolaris container (or indeed the opernsolaris host OS) part of this tutorial, you can use the same sequence to run Mac OSX as a Virtualbox guest on any OS, provided you’ve installed the 3.2 beta version (or later).  You just need to ensure that whatever machine you’re using has a CPU that supports VMX.  Otherwise the OS X Install CD won’t load the Operating system properly.  (Other guests will be fine)

[Grab the beta here]

Click here to skip to the Mac OS X guest configuration section.

Step 1:  Create the opensolaris container

At the time of writing, I was using Opensolaris b133.  The bits I typed are in bold.

1.a.  Define a new zone.

root@nehalem:/# zonecfg -z vbox
vbox: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:vbox> create
zonecfg:vbox> set autoboot=true

1.b.  Deciide where it will live.  In this case I chose /zones/vbox.

zonecfg:vbox> set zonepath=/zones/vbox

1.c Add some networking so that you can talk to the world. In this case I have ipmp set up for redundancy. Change to suit your actual network interface. Here, mine is ipmp0, and I’ve given it the address 1.2.3.4.

zonecfg:vbox> add net
zonecfg:vbox:net> set physical=ipmp0
zonecfg:vbox:net> set address=1.2.3.4
zonecfg:vbox:net> end

1.d.  This is the important part.  Add the two virtualbox drivers from the global zone. You can’t install devices in a container, so you need to make sure that the ones that the global zone uses are available to your container.

zonecfg:vbox> add device
zonecfg:vbox:device> set match=/dev/vboxdrv
zonecfg:vbox:device> end
zonecfg:vbox> add device
zonecfg:vbox:device> set match=/dev/vboxusbmon
zonecfg:vbox:device> end

Then all you need to do is create the zone.  This will take a few minutes.

zonecfg:vbox> commit
zonecfg:vbox> exit
root@nehalem:/# zoneadm -z vbox install
A ZFS file system has been created for this zone.
 Publisher: Using opensolaris.org (http://pkg.opensolaris.org/dev/ ).
 Publisher: Using contrib.opensolaris.org (http://pkg.opensolaris.org/contrib/).
 Image: Preparing at /zones/vbox/root.
[...]

Step 2:  Install the Virtualbox package.

This needs to be done in the global zone as well as your newly-created container.  So while our new container is installing, go ahead and grab the latest beta, and install it in the global zone:

root@nehalem:/var/tmp# pkgadd -d VirtualBox-3.2.0_BETA1-SunOS-r60785.pkg
The following packages are available:
 1  SUNWvbox     Oracle VM VirtualBox
 (i386) 3.2.0_BETA1,REV=2010.04.27.22.46.60785
Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:

Once that’s done and your new container is ready, boot it and you’ll need to install the exact same Virtualbox package in the container, as well as some other packages.

inside the new container:

root@vbox:/# pkg install SUNWuiu8 SUNWgccruntime
[.. output omitted ..]
root@nehalem:/var/tmp# pkgadd -d VirtualBox-3.2.0_BETA1-SunOS-r60785.pkg

At this point, we’re ready to create our Guest.  We’re going to do this using the command line interface, so this will work on any operating system.  It isn’t Solaris specific.

If you’re following along from the top, make sure you’ve logged into the Opensolaris container (use “zlogin <container>”).

You don’t need to be root.  Cut and paste the following lines, being sure to change the green parts as appropriate for your system.

[Note: Since this post was written creating a Snow Leopard capable VM is now a lot simpler.  If you have compatible hardware, you might be interested to check out this post instead. ]

VBoxManage createvm -name OSX -ostype MacOS_64 -basefolder /vbox -register
VBoxManage createhd ---filename /vbox/OSX/OSX.vmdk --size 10240
VBoxManage modifyvm OSX --cpus 8
VBoxManage modifyvm OSX --memory 8192
VBoxManage modifyvm OSX --usb on --usbehci on
VBoxManage modifyvm OSX --acpi on --ioapic on
VBoxManage storagectl OSX --name "SATA Controller" --add sata \
  --controller IntelAHCI
VBoxManage storageattach OSX --storagectl "SATA Controller" \
  --type hdd --port 0 --device 0 --medium /vbox/OSX/OSX.vmdk
VBoxManage storagectl OSX --name "IDE Controller" --add ide \
  --controller PIIX4
VBoxManage storageattach OSX --storagectl "IDE Controller" --port 0 \
 --device 1 --type dvddrive --medium /misc/iDeneb_v1.6_1058_Lite_Edition.iso

Now a well-known issue with earlier versions of Virtualbox was that if you managed to install OS X you might have the guest os complaining that no keyboard was connected.  Indeed, this is what happened to me.  In order to get a Mac OS X guest to run with a keyboard and mouse inside Virtualbox, you need to add the following lines to your configuration:

VBoxManage modifyvm OSX --mouse usb
VBoxManage modifyvm OSX --keyboard usb

Now you can go ahead and boot it up, and install Mac OS X.  You don’t need to change any package selections for the iDeneb CD.  Once you’re done just, reboot and voila!

VBoxManage startvm OSX --type vrdp

To access your OSX console, use VRDP.  Point your RDP client at the IP address you gave your container (or whatever IP address is running Virtualbox as the host if you skipped the Opensolaris part).

[ One thing worth noting - sometimes Mac OS X struggles if you give it more than 1 virtual CPU.  If this happens, set the number of CPUs to 1, and reboot and it should be fine.]