May 19, 2013

Moving VirtualBox's VM files to a different location

Disclaimer: I use Oracle VirtualBox v4.12.2 (updated recently) on Windows 7 64bit.  This instruction may not apply to other version of VirtualBox.

I recently had to move my VM files to a different drive as I'm running out of space on my C: drive.  When I google'd on moving VM files to different location, I only found methods for older version of VirtualBox, involving XML file, which doesn't apply to the version I have.  After playing around with it a bit, I figured out how.

Change the default location of VM files

VirtualBox's default configuration is to create VM files in C: drive -- and this may not be the desirable location.  If no VM has been created yet, the default location can be changed by going to: File -> Preferences (Ctrl-G), and VIrtualBox-Settings dialog box will pop up.  Change the "Default Machine Folder" setting.



Move existing VM files to different location

If a VM is already created -- one caveat is the drive file(s) can be moved, but log files and setting files will still be located where they are created (with this method).  This method doesn't modify any registry or XML files but just using the VirtualBox Manager UI.

  1. Shutdown the guest VM.
  2. Copy the VM folder to a different drive or directory.  E.g. I copied the whole directory "C:\Users\kkim\VirtualBox VMs\CentOS-1" to "G:\VirtualBox VMs\CentOS-1". 
  3. From the VM Virtual Manger go to File -> Virtual Media Manager.   (a) Right click on the drive of the VM you want to move, and select "Release".  The entry should be still there.  (b) Right mouse click on it again, and select "remove".  Since the files were already copied, it is safe to delete the file, but it's not necessary.

  4. From Virtual Manager GUI, right mouse click on the VM, select "settings."  Then Click on General, and "Advanced" tab.  And change the Snapshot folder location to a different VM file location:
  5. Click on Storage and click on "Add Hard Disk" icon next to "Controller: SATA", click on "Choose existing disk":
  6. Select the VM disk file you moved, and start the VM. 


Pretty simple.

No comments: