Once in a while you will want to setup clusters with shared disks to test and play around with various clusters. while this is easy to do in kvm/xen/etc its not so easy with virtualbox.
There is a way via command line tools to create disks and attaching it so that it is shared.
For me I have windows 7 64bit and I am running virtualbox 64bit 4.xxxxx. It is most likely easier if you include the path for “c:Program FilesOracleVirtualBox” however if you do not its ok.
We will need to run the command VBoxManage or “c:Program FilesOracleVirtualBoxVBoxManage.exe” if you do not have it in the path.
Also very important to exit out of all virtualbox processes before continuing.
First create the disks to be shared. the shared disks will have to be fixed disks and not dynamic. to create issue the following
VBoxManage createhd --filename ssdisk1 --size 1024 --variant Fixed
The size is in MB and it will automatically append .vdi to the name of the file. The above command will create a file called ssdisk1.vdi onto the directory you are currently in that is 1024MB FIXED.
You can create multiple disks to be shared.
Second attaching the disk to the virtual machines.
Lets say that I have 3 virtual machines named node1, node2, and node3 and they each have the SATA controller named SATA on SATA Port 0. this can be easily seen from the summary of the virtual machine window.
To attach the disk(s) to the vm’s we will again use the VBoxManage.exe command
VBoxManage storageattach "node1" --storagectl "SATA" --port 1 --device 0 --type hdd --medium ssdisk1.vdi --mtype shareable
you can change the port # and the medium name and the device number according to how many disks you have attached to the vm and which sata controller it is on. you will need to do this for all 3 nodes.
Once this is complete you can launch virtualbox and look on the summary for the vm’s and see that there is another disk attached and it will state that it is shareable.