With many people having gone through the migration from ESX 3.5 to vSphere, there is a wealth of great information on the best practices for doing this, from the very comprehensive upgrade guide from VMware, to various blogs such as Scott Lowe‘s guide to upgrading individual VM’s. This post look at a slightly different problem, that of migrating VM’s from a Fusion box to vSphere. One method of doing this is to use the VMware Converter tool, but sometimes this isn’t possible or desired (for example when the Fusion and vSphere boxes are seperate by a firewall and it doesn’t have the correct ports open to function). In this case the solution is to open a terminal session and get your hands dirty in the command line.
VMware fusion comes with a command line tool called “vDisk Manager” which can be used for all sorts of disk operations from creating or deleting disks, shrinking/expanding disks and also can be usde for copying disks to other locations which is what we are interested in today. When copying a disk (VMDK file) there are several options that are available depending on where the disk is to be created. When moving to vSphere, it is interesting to know that we can use this tool to create the new disk as a thinly-provisioned disk…thus taking advantage of this space-saving feature. The full list of options for disk type are shown below:
0 : single growable virtual disk
1 : growable virtual disk split in 2GB files
2 : preallocated virtual disk
3 : preallocated virtual disk split in 2GB files
4 : preallocated ESX-type virtual disk
5 : compressed disk optimized for streaming
6 : thin provisioned virtual disk – ESX 3.x and above
Ok, so on with the process. First of all take a careful note of the existing settings for the VM. This should include the number of CPU’s, amount of RAM, and the network settings. Once this is done, create a custom VM on vSphere using these settings, but don’t add any disks yet. This creates the folder we will copy the VMDK files to, and gives us the shell of the VM already. Now, get terminal access to the Fusion machine using SSH or Telnet. Once connected you will need to go to the folder containing the VMDK files themselves. By default VMware Fusion stores these here:
<home>/Documents/Virtual Machines.localized/<virtual machine>/folder where
<home> is your home folder, and
<virtual machine> is the name of the virtual machine.
Now we need to create a password file containing the password for an administrative account you will use to access vSphere. This can be created as follows:
ECHO mysecretpassword > passwordfile
Then you are ready to run the following command to start the copy:
/Library/Application\ Support/VMware\ Fusion/vmware-vdiskmanager -r SOURCEVM.vmdk -t 6 -h xxx.xxx.xxx.xxx -u root -f passwordfile "[STORAGEVOLUME]/NEWVM/NEWVM.vmdk"
Changing the text in capitals to the relevant names, and the “xxx” to the IP address of the vSphere host. We are using disk option type “6″ which will convert the disk into a thin provisioned disk on our vSphere server. Depending on the size of the disk this could take some time, but there is a percentage counter displayed to give you some idea of the time involved.
Once this is complete we log back into the vSphere client and complete the VM by adding the new disk(s) to the VM, and powering it up. Just time to run a few checks to make sure the networking is good and the disks are properly recognised and we are done…hard drives from VMware Fusion successfully migrated to vSphere without using the VMware Converter tool. The final step…delete the password file you made on the Fusion box and when you are ready, remove the old VM from Fusion entirely.