neuhalfen.name

A random collection of posts

Converting an OpenSolaris Xvm HVM-domU to VMware Fusion

Permalink

The problem

My development machine is a virtualized machine running Linux in an OpenSolaris xvm domU. I do all my work via NX. This is not a problem, when I work locally but sometimes/someplace latency is too bad for comfortable working. For that reason I wanted to clone my virtual machine as a VM for VMware Fusion.

The process itself is really painless, just run vdiskadm on Solaris, edit the .vmdk file and import it into VMware.

Converting zvol to vmdk

The virtual machines data is stored in zfs volumes (ZVOL). I use vdiskadm to extract the data from a current snapshot of the disks. The vmdk disk-format ( fixed) might catch your attention as these files are really huge. A sparse file would need significant less storage on disk, but creating many small files (compiling) badly fragments the not only the virtual disk internally but also the ever expanding file on the host system.

# this is where my vm lives
$ pfexec virsh dumpxml devel|grep disk
<disk type='block' device='disk'>
<source dev='/dev/zvol/dsk/storage/xen/guests/devel/disk0'/>
</disk>
<disk type='block' device='disk'>
<source dev='/dev/zvol/dsk/storage/xen/guests/devel/disk1_home'/>
</disk>
<disk type='file' device='cdrom'>
</disk>
# superflous fact #1) zfs compression does work
$ pfexec zfs get compressratio storage/xen/guests/devel
NAME PROPERTY VALUE SOURCE
storage/xen/guests/devel compressratio 1.59x -
# superflous fact #2) and so does zfs deduplication
$ zpool list storage
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
storage 1.81T 1.14T 691G 62% 2.88x ONLINE -
# take a snapshot
$ pfexec zfs snapshot -r storage/xen/guests/devel@2010-03-05_shutdown
$ pfexec zfs list -r -t snapshot storage/xen/guests/devel|grep shut
storage/xen/guests/devel@2010-03-05_shutdown 0 - 21K -
storage/xen/guests/devel/disk0@2010-03-05_shutdown 0 - 3.47G -
storage/xen/guests/devel/disk1_home@2010-03-05_shutdown 0 - 5.49G -
# inititate the vmdk conversion
$ mkdir disk0 disk1
$ cd disk0
$ vdiskadm import -d /dev/zvol/dsk/storage/xen/guests/devel/disk0@2010-03-05_shutdown -t vmdk:fixed disk0.vmdk
$ cd disk1
$ vdiskadm import -d /dev/zvol/dsk/storage/xen/guests/devel/disk1_home@2010-03-05_shutdown -t vmdk:fixed disk1.vmdk

Fixing up the files

If you try to import these disks in VMware Fusion you will get errors/Fusion will refuse to use the disks. I had to massage the .vmdk descriptor with my favorite editor :

$ diff vdisk_from_osol.vmdk vdisk.vmdk
3c3
< CID=124d2fb0
---
> CID=32915588
4a5
> isNativeSnapshot="no"
8c9
< RW 31457280 FLAT "vdisk-flat.vmdk"
---
> RW 31457280 FLAT "vdisk-flat.vmdk" 0
10c11
< # The disk Data Base
---
> # The Disk Data Base
12a14,17
> ddb.longContentID = "bf6b48fdb78cbb0003bda96b32915588"
> ddb.encoding = "UTF-8"
> ddb.uuid.image = "d5e0e326-9105-4eca-bdf1-987e83ea918e"
> ddb.adapterType = "ide"
14,19d18
< ddb.adapterType="ide"
< ddb.uuid.image="d5e0e326-9105-4eca-bdf1-987e83ea918e"
< ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
< ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
< ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
< ddb.comment=""

The whole file looks like this:

# Disk DescriptorFile
version=1
CID=32915588
parentCID=ffffffff
isNativeSnapshot="no"
createType="monolithicFlat"
# Extent description
RW 31457280 FLAT "vdisk-flat.vmdk" 0
# The Disk Data Base
#DDB
ddb.longContentID = "bf6b48fdb78cbb0003bda96b32915588"
ddb.encoding = "UTF-8"
ddb.uuid.image = "d5e0e326-9105-4eca-bdf1-987e83ea918e"
ddb.adapterType = "ide"
ddb.virtualHWVersion = "4"

After that I was able to import the disks and could continue to hack.

Comments