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.

SEE: 5 reasons why VirtualBox has a place in the data center

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).

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.

Figure B

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.

Figure C

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.

Subscribe to the Data Insider Newsletter

Learn the latest news and best practices about data science, big data analytics, artificial intelligence, data security, and more. Delivered Mondays and Thursdays

Subscribe to the Data Insider Newsletter

Learn the latest news and best practices about data science, big data analytics, artificial intelligence, data security, and more. Delivered Mondays and Thursdays