Creating Shared Drives in Oracle VM VirtualBox

If you would like to experiment with Oracle RAC and ASM/ACFS in your Oracle VirtualBox environments you will need to create drives that can be read and written to by multiple VMs concurrently. VirtualBox 4.0 supports the creation of shared drives.

The steps in this document were performed on a Windows host using Oracle VirtualBox 4.0.10 r7249 with an Oracle Enterprise Linux 5 update 5 guest VM. While it is possible to create virtual disks via the VM Settings in VirtualBox Manager, some of the options we will need to set are not exposed through the UI so this example will use VBoxManage on the command line.

Create a Hard Drive
The createhd command is used to create a new virtual hard disk image. Below is the syntax of the command.

C:\ejenkinson>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" createhd
Usage:

VBoxManage createhd         --filename <filename>
                            --size <megabytes>|--sizebyte <bytes>
                            [--format VDI|VMDK|VHD] (default: VDI)
                            [--variant Standard,Fixed,Split2G,Stream,ESX]


C:\ejenkinson>

We will create five virtual drives at 100MB a piece. The default format will be VDI and since these are intended to be shared they will need to be fixed size drives.

C:\Documents and Settings\ejenkinson>mkdir VirtualBoxStorage

C:\Documents and Settings\ejenkinson>cd VirtualBoxStorage

C:\Documents and Settings\ejenkinson\VirtualBoxStorage>mkdir sharedStorage

C:\Documents and Settings\ejenkinson\VirtualBoxStorage>cd sharedStorage

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage createhd --filename ssdisk1 --size 100 --variant Fixed
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: c29a8507-6186-471f-ad8a-5be789120ad9

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage createhd --filename ssdisk2 --size 100 --variant Fixed
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: 70df6f52-1026-4b2b-93be-185167229525

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage createhd --filename ssdisk3 --size 100 --variant Fixed
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: c2ad102e-1226-4a90-8544-5f809c99f547

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage createhd --filename ssdisk4 --size 100 --variant Fixed
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: 3f878d19-fafc-4f7f-93f2-701067d52106

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage createhd --filename ssdisk5 --size 100 --variant Fixed
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Disk image created. UUID: 853624dc-e0dc-4363-a33d-8253b15c23ae

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>

If you would like more detailed information on the createhd command see the documentation for createhd.

Attach the Hard Drives
To storageattach command is used to attach a virtual disk image to a virtual machine. Below is the syntax of the command.

C:\ejenkinson>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" storageattach
Usage:

VBoxManage storageattach    <uuid|vmname>
                            --storagectl <name>
                            --port <number>
                            --device <number>
                            [--type dvddrive|hdd|fdd]
                            [--medium none|emptydrive|
                                      <uuid>|<filename>|host:<drive>|iscsi]
                            [--mtype normal|writethrough|immutable|shareable|
                                     readonly|multiattach]
                            [--comment <text>]
                            [--passthrough on|off]
                            [--bandwidthgroup <name>]
                            [--forceunmount]
                            [--server <name>|<ip>]
                            [--target <target>]
                            [--port <port>]
                            [--lun <lun>]
                            [--encodedlun <lun>]
                            [--username <username>]
                            [--password <password>]
                            [--intnet]


C:\ejenkinson>

In this example we are going to attach the virtual devices created above as SATA devices. The VM already has a SATA controller and one virtual drive attached to port 0. How do we know this information?

The VirtualBox Manager dialog shows the Storage configuration for the virtual machine. The VM has both and IDE and a SATA controller. The SATA controller’s name is SATA Controller and the Port 0 is already being used.

For our five ASM drives we will use ports 1 through 5 on device 0. The type will be hdd and the mtype will be shareable. All drives will be attached to the VM “ON NewHost” on the “SATA Controller”. Below are the five storageattach commands to attach the drives to the VM.

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage storageattach "OD NewHost" --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium ssdisk1.vdi --mtype shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage storageattach "OD NewHost" --storagectl "SATA Controller" --port 2 --device 0 --type hdd --medium ssdisk2.vdi --mtype shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage storageattach "OD NewHost" --storagectl "SATA Controller" --port 3 --device 0 --type hdd --medium ssdisk3.vdi --mtype shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage storageattach "OD NewHost" --storagectl "SATA Controller" --port 4 --device 0 --type hdd --medium ssdisk4.vdi --mtype shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage storageattach "OD NewHost" --storagectl "SATA Controller" --port 5 --device 0 --type hdd --medium ssdisk5.vdi --mtype shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>

Notice that as soon as each attach is completed the Storage section on the VirtualBox Manager dialog reflects the change. The last step is to modify the virtual drive as shareable.

For more information on the storageattach command see the documentation for storageattach.

Modify a Hard Drive
The modifyhd command allows you to change the type of image along with resizing the image. For this example, type is the only parameter we are going to use. When we created the disk earlier the disk type defaulted to normal. The type of the disk details how the disk deals with write operations and snapshot options from a Virtual Machine. The type we wanting to use for our drives is shareable. Below is the complete syntax of the command.

C:\ejenkinson>"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd
Usage:

VBoxManage modifyhd         <uuid>|<filename>
                            [--type normal|writethrough|immutable|shareable|
                                    readonly|multiattach]
                            [--autoreset on|off]
                            [--compact]
                            [--resize <megabytes>|--resizebyte <bytes>]


C:\ejenkinson>

Below we change each drive from normal to shareable.

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage modifyhd ssdisk1.vdi --type shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage modifyhd ssdisk2.vdi --type shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage modifyhd ssdisk3.vdi --type shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage modifyhd ssdisk4.vdi --type shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>VBoxManage modifyhd ssdisk5.vdi --type shareable

C:\Documents and Settings\ejenkinson\VirtualBoxStorage\sharedStorage>

For more information on the modifyhd command see the documentation for modifyhd. For more information on the write modes supported in VirtualBox see documentation under Special Image Write Modes
Now that we have our shared drives created and attached to the VM we are ready to explore ASM, ACFS and RAC.

4 thoughts on “Creating Shared Drives in Oracle VM VirtualBox”

  1. can you please help me in WHAT ARE THE STEPS TO ENABLE DISK SHARING FOR THE FIVE SCSI CHANNEL ..
    HOST:WINDOWS 7
    GUEST:CENTOS
    VirtualBox-4.1.8-75467
    note:
    i am trying to set RAC environment in my laptop

  2. how to delete the share disk in oracle virtualbox..
    actually i created disk before shutdown the guest..

Leave a Reply

Your email address will not be published. Required fields are marked *