Migrating Windows VMs from VMWare Fusion to VirtualBox
VMWare fusion no longer runs on Yosemite (Mac OS X), but VirtualBox does. Since it saves the applications, settings, and so on of the virtual machine, it is convenient to migrate a VMWare Windows machine to one that works with VirtualBox. The following describes one way to move between the two virtual platforms.
For concreteness, the examples centre on importing a Windows 7 64-bit virtual machine from VMWare into VirtualBox. The VM is referred to hereafter as "Win7_x64".
Remove VMWare Tools
This step requires launching the Windows VM using VMWare itself. This works if you have a version of OS X that still runs VMWare Fusion, e.g., Mavericks. If you do, choose the "Remove VMWare Tools" menu item from the "Virtual Machine" menu.
The documentation for VMWare states that there is a separate OS X application for removing the tools, and command line tools for other OSes, but I could not locate these, and cannot confirm if they work: Uninstalling VMware Tools
Export the VM using VMWare's OVF command line tool
The tool is available for download from VMWare's website: OVF Tool Documentation
However, you need to log into the VMWare site in order to download the tool. If you do not remember your login credentials, I have a copy of the download, a Mac .dmg file.
Open the .dmg and launch the installer, VMware OVF Tool.pkg. It puts the command line tool into "/Applications/VMware OVF Tool/ovftool".
Run the ovf tool (it runs on Yosemite). The first argument is the VMWare VM to migrate, a .vmx file. The second is the name of the output .ovf file. Assuming the current directory is the standard folder that VMWare uses for its virtual machines, namely, "~/Documents/Virtual Machines", an example of the command is:
$ ovftool Win7_x64.vmwarevm/Win7_x64.vmx Win7_x64.ovf
Note: if the shell complains that it cannot find "ovftool", enter the full path: "/Applications/VMware OVF Tool/ovftool"
It will take a while to process the .vmx file but the tool provides progess in terms of percentage complete. When finished, three files are created:
- Win7_x64-disk1.vmdk: A large data file containing the VM's disk image.
- Win7_x64.ovf: an XML file describing the virtual machine.
- Win7_x64.mf: a text file containing SHA1 checksums for the above two files.
Import into VirtualBox
Launch VirtualBox. Choose "Import Appliance..." from the File menu. Use the file chooser dialog to navigate to the directory containing the .vmdk, .ovf, and .mf files, and choose the .ovf file. Virtualbox responds with a dialog that shows the configuration of the appliance it is going to import, and allows you to change some of the names. I didn't since those can be changed from VirtualBox's main window after the virtual machine is fully imported.
You will likely run into an error during the import, namely, a failure to find the SCSI controller. In that case, you need to doctor the .ovf file and the .mf files.
Remove the SCSI controller from the .ovf file
The .ovf file associates the main disk with a SCSI controller, but it's neccessary to associate it with the IDE controller. The next procedure fixes that by removing the declaration of the SCSI controller completely, and making the disk an IDE device.
- open the .ovf file in a text editor.
- find the item for the SCSI controller. It looks like this:
<Item> <rasd:Address>0</rasd:Address> <rasd:Description>SCSI Controller</rasd:Description> <rasd:ElementName>scsiController0</rasd:ElementName> <rasd:InstanceID>4</rasd:InstanceID> <rasd:ResourceSubType>lsilogicsas</rasd:ResourceSubType> <rasd:ResourceType>6</rasd:ResourceType> </Item>
Note the value of the <rasd:InstanceID>. Here it is "4". Remember that number, and remove the entire <Item>.
- find the item for the IDE controller, but do not change it. It looks like:
<Item> <rasd:Address>1</rasd:Address> <rasd:Description>IDE Controller</rasd:Description> <rasd:ElementName>ideController1</rasd:ElementName> <rasd:InstanceID>5</rasd:InstanceID> <rasd:ResourceType>5</rasd:ResourceType> </Item>
Note the value of the <rasd:InstanceID>; here "5". Remember that number. Otherwise, leave the IDE <Item> as is.
- find the item whose <rasd:ElementName> is "disk0":
<Item> <rasd:AddressOnParent>0</rasd:AddressOnParent> <rasd:ElementName>disk0</rasd:ElementName> <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource> <rasd:InstanceID>8</rasd:InstanceID> <rasd:Parent>4</rasd:Parent> <rasd:ResourceType>17</rasd:ResourceType> </Item>
Note that its <rasd:Parent> is "4", which matches the SCSI controller just removed. Replace the "4" with the value of the IDE controller -- "5" in the example above.
- save the .ovf file.
Unfortunately, changing the contents of the .ovf file changes its SHA1 checksum value, and it's necessary to recalculate it. You can do that using the following command:
$ shasum Win7_x64.ovf
- open the .mf file, and find the line stating the SHA1 checksum for the .ovf file. It looks like:
- replace the value, the number after the = sign, with the new one calcluted above using the "shasum" command line tool.
- save the .mf file.
Back in VirtualBox, once again choose "Import Appliance..." from the File menu. This time it should import with no errors.
Note: it's not clear if you need to import the appliance twice. That is, it may be possible to fix the SCSI controller problem before the first import. If you want to try that, and it works, please let me know.
Install the VirtualBox Guest Additions
Launch the Windows virtual machine. A new application will start, and appear in the Dock named "VirtualBox VM". Once the Windows virtual machine is running, and there is a Windows desktop in the VM's window, choose "Insert Guest Additions CD image..." from the "Devices" menu of the "VirtualBox VM" application. This should result in dialog within the Windows machine asking what to do with the just mounted CD. Choose the "Run VBoxWindowsAdditions.exe" option.
When that process is finished, restart the virtual machine, and you should be done.
Addendum: Converting Disk from .vmdk to .vdi Format
VirtualBox's documentation states that its native virtual disk format, .vdi, is more efficient than the open format, .vmdk, output by the ovftool. The following describes how to create a .vdi version of the virtual disk using the VIrtualBox application.
- Make sure the virtual machine is off.
- Choose "Virtual Media Manager" from the "File Manager" menu.
- Choose "Copy ..." from the "Actions" menu.
- Click the "Expert Mode" button.
- Find and select the .vmdk disk to convert from the "Hard disk to copyp" popup menu; e.g., "Win7_x64-disk1.vmdk".
- Enter a name for the new disk file (leave off the .vdi extension) in the "New hard disk to create" text field, and choose where to put the file. Note that the default location is the same folder as the .vmdk file you are converting.
- Select the "VDI (VirtualBox Disk Image)" radio button in the "Hard disk file type" radio group.
- Select the "Dynamically allocated" radio button in the "Storage on physical hard disk" radio group.
- Click the "Copy" button.
After the copy is complete you can reset the "Storage" settings of the VM to use the new .vdi disk instead of the .vmdk. It's best to test using the .vdi disk before deleting the .vmdk file.