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
  • 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: virtualbox, iscsi, opensolaris, zfs, howto, guide

BPD and Martial Art Therapy

If there’s not a word for this in English, there should be. It’s definition would read:
“n: A short period of time during which a number of small, unusual, random events occur; all inexplicably linked together by a common theme.

When this happens, the only conclusion you can usually draw is that someone, somewhere REALLY wants you to pay attention to this thing, whatever it is, right now.

This week the common theme was Borderline Personality Disorder.

I’ve blogged about it before. There was a long piece about it in the local newspaper magazine this weekend.  Pretty standard fare about the disorder, some nice personal histories.

The thing that got me, though, was the last few paragraphs: Treatment.

Apparently the standard fare of medication is, more often than not, ineffectual. Promising results though, have apparently been found with Dialectic Behavioural Therapy, and to a lesser extend Cognitive Behavioural Therapy.

Short-cutting the discussion linking BPD to trauma and/or some type of hereditary predisposition to “emotional rawness” here, I’ll jump right to the “well, duh!” moment.

Medication? Usually innefective.

Meditation, mindfulness, learning to reframe experiences as positive? Much more effective.

Kind of what we do with our Martial Art Therapy program.  And pretty much common sense to me.

But more to the point, why on earth isn’t this emotional regulation, mindfulness and much, much more “reslilience” taught as a core subject in our schools?