How to move VirtualBox machines to another hard drive
Recently I needed to free up some space on my Mac’s internal hard drive and decided to move my Virtualbox virtual machine disk images to an external drive.
At first I thought it was going to be as easy as just copying the .vdi files to the other drive and then pointing each Virtualbox machine to the new location of its corresponding .vdi file. Turned out it isn’t quite that easy.
For future reference, here’s what I did:
- Shut down the machine
- Use clonehd to create a clone. Open a Terminal window and enter vboxmanage clonehd [original] [clone], replacing [original] with the full paths to the .vdi file you want to clone and [clone] with the location where you want the clone, i.e. vboxmanage clonehd /VM/ubuntu10.10.vdi /Volumes/ExternalDisk/VM/ubuntu10.10.vdi.
- Open VirtualBox and go to Settings - Storage for the machine.
- Remove the disk in the Storage Tree.
- Add the cloned disk instead.
- Start the machine to verify that it works.
The Cloning disk images section of the VirtualBox manual notes that there may be problems with drive IDs and newer Linux distributions. I did not notice any such problems, but YMMV.