How many times have you been in a situation where the drive housing your VirtualBox virtual machines ran out of space? Or maybe you were simply migrating from one server or drive to another? When that happened, you may have discovered that VirtualBox doesn't have a built-in tool to help you move those VMs. It is, however, possible...albeit a bit convoluted.
Let's walk through the process of migrating a VirtualBox VM from one drive to another. It's not that challenging, but it can be a bit confusing, so pay close attention.
Detaching the vdi file
The first thing you must do is remove the attached vdi for the virtual machine. Make sure the VM is powered off (not in a saved state—otherwise, you will not be able to move it) and then right-click the VM (in the left panel of the VirtualBox main window) and select Settings. In the Settings window, go to Storage and then select the .vdi listing under Controller (Figure A).
Once selected, click the Remove Attachment button (red "-" symbol) and then click OK. Back at the VirtualBox main window, click File | Virtual Media Manager. In the manager window (Figure B), select the vdi you are moving and then click Remove.
In the resulting popup window, click Remove. In the next window—and this is crucial—click the Keep button (otherwise the vdi file will be permanently deleted). Click Close.
Moving and reattaching the vdi file
Now that the vdi has detached, it is safe to move it. Locate the vdi file in your desktop file manager or from the command line, and relocate it to the new disk. Go back to the VirtualBox main window, select the virtual machine (in the case of my example, CentOS), and click Settings. Click Storage, select the Controller: SATA (this may vary, depending upon your setup), click the Add Hard Disk button to the right of the Controller listing (Figure C), and then finalize it by clicking OK.
When prompted, select Choose Existing Disk and then navigate to the new location of the vdi file. Select the vdi file from your file manager and click OK. Your virtual machine is ready to boot again.
Done and done
That's it. You've successfully moved your VirtualBox virtual machine from one drive to another. Now that you understand how this is done, your VMs should always have the space they need, a safe drive to exist within, or a reliable system to work on.
- Is IT witnessing the death of the storage administrator? (TechRepublic)
- 5 signs that we are in a post-virtualization world (TechRepublic)
- How to enable WebDAV on your Ubuntu server (TechRepublic)
- SUSE's SES 3: Get scalable storage at a budget-friendly price (TechRepublic)
- How to assess the effectiveness of virtual technology investments (Tech Pro Research)
- Building the Software Defined Data Center (ZDNet/TechRepublic special feature)
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.