Tuesday, September 03, 2013

Moving virtual hard disks in VirtualBox

Under Linux, VirtualBox likes to put it's virtual disks in a relatively inconvenient directory. Newer versions are more obnoxious, and have removed the ability to easily manage your virtual disks. As most of the information I find online is old and does not apply to VirtualBox 4 or 4.2 (the specific version I have, shipped with Ubuntu 13.04), or may work but just seems too hard, here's a nice little recipe:

To move a virtual disk from point A to point B:

  1. Ensure the virtual machine(s) owning the disk are powered off.
  2. Open the settings for the virtual machine(s) owning the disk.
  3. Go to "Storage", select the disk, and click the Remove icon. Then click OK.
    • Repeat for each associated VM as necessary
  4. From the main VirtualBox panel, select File->Virtual Media Manager
  5. Click on the Virtual Disk image, verify the Location, and that it is not attached to any VMs.
  6. Click the Remove icon along the top *
  7. Click Close.
  8. Now, from the commandline or file manager, move the newly-freed VirtualImage.* files from point A to point B.
  9. Finally, back in VirtualBox, select the virtual machine configuration and select "Settings".
  10. Go to "Storage" and select the Controller where the virtual disk used to be.
  11. Click on the Add Attachment icon and select Add Hard Disk.
  12. Select Choose existing disk, navigate to point B, and select your virtual disk.
If you try to skip steps 4-7 VirtualBox will complain about adding a disk image with an already existing UUID, so that image has to be removed from the Virtual Media Manager first. If you have multiple VMs attached to the same disk this can get tedious, but it's better then the other suggestions I've read, including cloning the disk or VM, or even removing the virtual machine itself (including all your settings!)

This also has the nice benefit that *you're never going to be prompted to delete the files from disk. (And if I'm misremembering that and you are prompted, but sure to select NO.) You may be able to select "Detach" from the Virtual Media Manager instead of going through each configuration, but I'd recommend doing it the hard way so you can be sure to take notes and verify what you're doing as you do it.

No comments:

Post a Comment

Some HTML tags are accepted, SomeLink, bold and italic seem to be it.