VMWare’s native disk format is VMDK, which is only partially understood by free tools like qemu-img. qemu-img breaks quite badly on the newer variant that ESX 4 uses. Then there’s the issue of how you get the VMDK file from VMWare’s storage. Use their proprietary storage APIs?
Well it turned out both problems could be solved easily. VMWare ESX servers make the storage available over https connections, so you can use a URL like
https://root:password@esxserver/folder/ to browse available storage on the server. And VMWare also makes the raw (“flat”) disk images available in the same way.
libvirt has supported ESX management for a while (thanks again to Matthias Bolte), so you can do:
$ sudo virsh -c esx://192.168.2.121/?no_verify=1 list --all Enter username for 192.168.2.121 [root]: Enter root password for 192.168.2.121: Id Name State ---------------------------------- - TestLinux shut off - TestWin shut off
(Note that the domains must be shut off before VMWare will allow you to access the flat disk images).
Then we can get the storage URL:
$ sudo virsh -c esx://192.168.2.121/?no_verify=1 dumpxml TestLinux > /tmp/xml $ grep '<source file' /tmp/xml <source file='[Storage1] TestLinux/TestLinux.vmdk'/>
And from that storage URL you can grab the disk image directly:
$ wget --no-check-certificate 'https://root:email@example.com/folder/TestLinux/TestLinux-flat.vmdk?dcPath=ha-datacenter&dsName=Storage1'
The large flat file downloaded is a straight raw disk image that can be examined directly in programs like guestfish and virt-inspector:
$ virt-list-filesystems -al TestLinux-flat.vmdk /dev/sda1 ext4 /dev/vg_testlinux/lv_root ext4 /dev/vg_testlinux/lv_swap swap $ guestfish --ro -a TestLinux-flat.vmdk -m /dev/vg_testlinux/lv_root Welcome to guestfish, the libguestfs filesystem interactive shell for editing virtual machine filesystems. Type: 'help' for help with commands 'quit' to quit the shell ><fs> ll / total 116 dr-xr-xr-x. 23 root root 4096 Dec 30 06:27 . dr-xr-xr-x 29 root root 0 Dec 21 07:59 .. -rw-r--r--. 1 root root 0 Dec 30 06:27 .autofsck drwx------. 3 root root 4096 Dec 17 11:58 .dbus -rw-r--r--. 1 root root 0 Dec 17 12:50 .readahead_collect dr-xr-xr-x. 2 root root 4096 Dec 17 12:11 bin [etc]
It’s probably also possible to avoid the download step, since libguestfs is built on qemu which should support http(s) connections directly, but I didn’t try this yet.