Too Many VirtualBox VM Images

Here’s the punchline:

Create a NTFS junction to the location where you created the VM image copy:

mklink /J “Kuntuntu 12.04 MAIN” “F:\Saved-VMBox-Linux-VMs\Kubuntu 12.04”

The detail:

I’ve got Windows 7 64-bit installed as host OS on my Core i7 2700K box with Oracle’s free VirtualBox VM manager installed for my OS virtualization needs. Today I maxed the SATA drive that hosts VirtualBox’s cache of saved VM’s. I noticed this when a push to GitHub froze and the Linux VM I was working in at the time became severely pre-occupied with matters other than me.

No problem at all.

What we want is to unblock the VM and allow the git commit to complete normally. But the guest Linux OS is locked in storage hell and the VirtualBox machine manager can’t help us here either because Windows won’t give it disk. Eventually, I figure the VM is going to crash so time is of the essence: need to get the executing VM image offline quickly.

Flip out to Windows and go to maxed D: drive. Find some shit I don’t care about and SHIFT-DELETE it out of the way in Explorer.exe. It takes about 30s to free a couple GB of space which is all we need to get the VM saved.

Now flip to running VirtualBox machine instance and select Close | Save Machine State… from the Machine menu. Now that you’ve got a little space, VirtualBox suspends the VM, and gets a state snapshot written back to disk.

Now that the VM is offline, copy the folder containing the VirtualBox VM image to another drive. (We copy in case something goes wrong and we need to fall back on the original VM image).

Close the VirtualBox machine manager.

Create a NTFS junction to the location where you created the VM image copy:

mklink /J “Kuntuntu 12.04 MAIN” “F:\Saved-VMBox-Linux-VMs\Kubuntu 12.04”

My main VirtualBox VM image store folder, I’ve got two subdirectories:

<JUNCTION> Kubuntu 12.04 Clone #4 Feb 2013 [F:\Saved-VMBox-Linux-VMs\Kubuntu 12.04 Clone #4 Feb 2013]
<DIR> Kubuntu 12.04 Clone #4 Feb 2013 - decomissioned

Note: it’s important that make the junction name the same name as the original and actual folder name. VirtualBox does not seem to derive the list of available VM’s from a directory enumeration, so if you rename the VM image folder, or any file in the image you’re toast. Check VM settings where you can rename the image once its remounted via the junction.

Restart the VirtualBox machine manager and select the new junction. Start that VM image and ensure everything is okay. If yes, delete the original VM image to free up the disk space.

Repeat this process for as many VM images as you need to move around to balance disk allocation.

This whole process took about ten minutes (mostly waiting on the VM image copy) and once I resumed my suspended Linux session, the clock updated, my git commit completed, and we’re back in business.


About Chris Russell
This entry was posted in Compute, Software and tagged , , , , , , , , . Bookmark the permalink.

Comment on this article

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s