Using ZFS Volume on Solaris host from a VirtualBox guest

In addition to using large image files on a real hard disk as virtual disk images, VirtualBox can also present either entire physical hard disks or selected partitions thereof as virtual disks to virtual machines.

Citing from official VirtualBox documentation:

With VirtualBox, this type of access is called "raw hard disk access"; it allows a guest operating system to access its virtual hard disk without going through the host OS file system. The actual performance difference for image files vs. raw disk varies greatly depending on the overhead of the host file system, whether dynamically growing images are used, and on host OS caching strategies. The caching indirectly also affects other aspects such as failure behavior, i.e. whether the virtual disk contains all data written before a host OS crash.

Virtual disk using ZFS Volume on Solaris

This is how I created virtual disk for VirtualBox using ZFS Volume on Solaris (11 update 2).

List ZFS datasets and find out name of ZFS pool:

# zfs list

Create a 30GB ZFS Volume that will be used as a storage for VirtualBox:

# zfs create -V30G rpool/zvol_vbox1

Verify that the volume has been created:

# zfs list
rpool/zvol_vbox1           30.9G   281G  3.70G  -

Change ownership of the device so it can be accessed by the user's VirtualBox:

# chown martink:sys "$(readlink -f /dev/zvol/rdsk/rpool/zvol_vbox1)"
# chown martink:sys "$(readlink -f /dev/zvol/dsk/rpool/zvol_vbox1)"

Create the VMDK (Virtual Machine Disk) container that will be used by VirtualBox:

$ VBoxManage internalcommands createrawvmdk -filename ~/dataset_virtualbox/FreeBSD/FreeBSD.vmdk -rawdisk /dev/zvol/rdsk/rpool/zvol_vbox1

Be carefull to use raw device in the /dev/zvol/rdsk directory instead of the device in the /dev/zvol/dsk directory:

$ VBoxManage internalcommands createrawvmdk -filename ~/dataset_virtualbox/FreeBSD/FreeBSD.vmdk -rawdisk /dev/zvol/dsk/rpool/zvol_vbox1
VBoxManage: error: Cannot get the size of the raw disk '/dev/zvol/dsk/rpool/zvol_vbox1': VERR_INVALID_FUNCTION
VBoxManage: error: The raw disk vmdk file was not created

The virtual disk is now ready to be used by VirtualBox.

See official documentation for more details:


Subscribe to Comments for "Using ZFS Volume on Solaris host from a VirtualBox guest"