SEARCH

How-To Geek

How To Backup and Move VirtualBox Machines

Need to move a virtual machine, only to find that copying and pasting doesn’t work?  Perhaps you just want to know what to backup?  Take a look at this quick guide on the process to get a better understanding of VirtualBox

First things first: be sure that your virtual machine is shut down and powered off.  Next, make sure you get rid of any snapshots you have.  There isn’t a fool-proof and safe way to do this without getting rid of them, unfortunately.  Select your virtual machine and click on the “Snapshots” tab.

delete snapshots

Select your snapshot and click the delete button.  Be prepared to wait a while as VirtualBox merges differences with your machine’s current state.  The machine’s state won’t actually change, though, so don’t worry.  Now that the prep stuff is out of the way, we can start the moving process.

Once that’s done, go to File > Virtual Media Manager.  You’ll see a list of media that you’ve used or have attached to your machines.

release media

Select which virtual machine you want to move, then click on the “Release” icon above.  In my case, I’ll be moving W7.vdi from my home directory to another hard drive.

Once you have it released, close VirtualBox go to its default settings directory, /home/user/.VirtualBox/

virtualbox_dir

You can copy your .vdi file from inside the HardDisks directory if you want to just back it up, or you can move it.  Be patient, as this can take a while depending on your configuration.

Meanwhile, let’s edit the VirtualBox.xml file to our liking.  This is the step most people don’t really know much about, but it’s pretty vital in making sure things work smoothly.  Open it up in gedit.

gedit xml

Scroll down a bit and you’ll get to the parts we need to edit.

If you’re changing the location of your virtual machines, find the xml tags for “MachineEntry” and change the source path.  If you’re changing the location of your virtual disk images, find the xml tags for “HardDisk” and change the location there.  As you can see, each machine is tied to a disk image by its UUID, which should not be changed.  If you’re moving virtual machines to a new computer, be sure to copy these this file over and replace the previous configuration file.

In my particular case, I just wanted to move the disk image to a more spacious drive, so I left the other things intact.

gedit vbox version  

If you’re changing hosts between Windows and Linux, be sure to change the version declaration at the top of the file to say “windows” instead of “linux” as well.

Once you’ve moved the .vdi file, fire up VirtualBox and go to File > Virtual Media Manager.

vbox Media Manager

Click on the old .vdi file and click remove.  Now, click “Add,” navigate to its new location, and click “Open.”  Click “OK.”

Now that the new .vdi is added to VirtualBox’s list, we have to attach it to your virtual machine.  At the main screen select it, go to “Settings,” and click on the “Storage” panel.

add hd

Under the appropriate IDE controller, click the “Add Attachment” button.  You’ll see a hard disk get added automatically, but it probably won’t be the correct one.

Click it and on right side, under “Hard Disk,” choose the correct .vdi file.  Click “OK.”

change vdi

If you followed all the steps and you edited the VirtualBox.xml correctly you should be able to start up the machine without any problems!  There are a few hairy areas, so if things aren’t working, be sure you’re using the correct paths and you’ve edited only the relevant areas of VirtualBox.xml.

The overall process is a bit more intricate than just copying and pasting, but it’s still relatively quick and painless.  Share your backup stories about VirtualBox in the comments!

Yatri Trivedi is a monk-like geek. When he's not overdosing on meditation and geek news of all kinds, he's hacking and tweaking something, often while mumbling in 4 or 5 other languages.

  • Published 12/1/10

Comments (8)

  1. Cambo

    Can I ask why you wouldn’t just click on “File->Export Virtual Appliance”?

  2. VMTime

    Does anyone know if VirtualBox has fixed the problem with recognizing USB devices (i know it happens with a Win7 x64 host)

  3. Camilo Martin

    What most surprises me is that your monitor’s LCD is that backwards BGR kind whose ClearType text looks blurry when seen from a screenshot with a straight, untwisted RGB display. I never saw one of those personally.

  4. Camilo Martin

    (by the way, with cleartype I meant the subpixel rendering, but I know the name (and degree of font hinting) is different outside Windows)

  5. Camilo Martin

    Oh, and sorry for the triple post, but I thought the easy way to backup was to use an appliance, it’s terribly easy.

  6. jasray

    Hmmm . . . I’ve never had any problem with simply taking the .vdi file and moving it to another machine or another place. When the .vdi file is where I want it, I create a new VM using previous settings or different and attach the .vdi file. One can do this with VeeDee .vdi pre-made machines: http://virtualboximages.com/

  7. Jon

    I always store my VDI files on a separate hard drive so I can use them between operating systems. The settings are negligible as I always use the same settings on each one. It takes two seconds to set them up.

  8. trm96

    I like that theme what GTK theme is it?

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!