How to copy and transfer or backup a Virtualbox Virtual Machine .vdi |
|
|
| Written by axel | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If you are reading this guide most probably you will know what Virtualbox is. But just in case let me tell a few words about it. VirtualBox is a cross platform application that allows you to create Virtual Machines. In other words VirtualBox runs on Windows, Linux, Macintosh and OpenSolaris hosts and supports a large number of guest operating systems such as Windows, Linux and OpenBSD. This means that you can run an Operating System through another at the same time. This is a very good way for experimenting and avoiding dual, triple or multiboot systems. I have already published two VirtualBox guides. The first one is How to install Ubuntu Linux on Windows using VirtualBox . The second one is How to resize a VirtualBox disk partition . In this tutorial I will explain how to copy a Virtual Machine's .vdi file so that you can backup it or transfer it to another system. With the same way you can also duplicate hard disk image file on the same host and quickly have a second Virtual Machine with the same setup.The first thing that comes to ones mind is to simply copy the .vdi file of his virtual machine and then paste it in another system. However this might not work properly since VirtualBox assigns a unique identity number (UUID) to each disk image. Instead we are going to use the clonehd utility that comes with VirtulBox. This utility duplicates a virtual hard disk image to a new image file with a new UUID. Cannot register the hard disk '/mnt/data/virtualmachines/VDI/Ubuntu 8.10.vdi' with UUID {a1ffe5a6-0d37-4e7e-97df-5bb5a331f411} because a hard disk '/mnt/data/virtualmachines/VDI/Ubuntu 8.10.vdi' with UUID {a1ffe5a6-0d37-4e7e-97df-5bb5a331f411} already exists in the media registry ('/home/axel/.VirtualBox/VirtualBox.xml'). Result Code: NS_ERROR_INVALID_ARG (0x80070057) Component: VirtualBox Interface: IVirtualBox {339abca2-f47a-4302-87f5-7bc324e6bbde} First make sure that the Virtual Machine you want to copy is powered off. ![]()
In File > Virtualdiskmanager, select the virtual machine disk image you would like to copy (1), press the Release button (2) and in the pop up window press again Release (3).
![]() Now you should see that the image is Not Attached. ![]() Linux usersIf you are using VirtualBox in Linux open a terminal window and type:
VBoxManage clonevdi /location/your_virtualmachine.vdi /destination/your_virtualmachine_backup.vdiOf course you should replace location and destination as long as the vdi names with what you have in your system. clonevdi has replace the clonehd command, which however is still working since it is linked to the new one. Take a look at Location in the above screenshot to see where I had the virtualdisk image I wanted to copy. Depending on the size of your virtual hard disk this might take a while.
![]() Windows users
If you are using VirtualBox in Windows go to Start -> All Programs -> Accessories -> Command Prompt. Here cd to where you have installed VirtualBox and then copy your oringinal .vdi to a new one:
cd "C:\Program Files\Sun\xVM VirtualBox" VBoxManage.exe clonevdi "C:\Documents and Settings\your_username\.VirtualBox\your_virtualmachine.vdi" "C:\your_virtualmachine_backup.vdi" ![]()
Next we have to undo the Release we did before so that we can continue using our Virtual Machine. In VirtualBox main Window select the Virtual Machine (1) and press the Settings button (2). Go to Hard Disks (3) and press the Add button (4). Here select your initial .vdi file (5) and your Virtual Machine will be ok.
![]()
Now let's see how to import our backup .vdi. In the main window press the New button (1). Start creating a new Virtual Machine just like your previous one. In the Virtual Hard Disk window press the Existing button (2).
![]() Next in the Virtual Disk Manager press the Add button and browse to where you have cloned your .vdi. Press Open to add it. ![]() And then select it from the Hard Disks and press the Select button to attach it in your Virtual Machine. ![]() Continue with the rest of the process. Once you are done you 'll see the VM you have transfered. ![]()
Before you boot into your VM you must change its settings. Unfortunately there is no way to backup your original settings so you will have to do this manually. Enjoy!
Did you enjoy this article? Please share it!
Set as favorite
Share This
Email This
Hits: 16373 Trackback(0)
Comments (31)
![]()
Dave from Texas
said:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Well, it worked once. :^> Now I'll try it again. Thanks for the help. Wonder why VB couldn't make it a simpler process????? Would sure make it easier. | |
|
report abuse
vote down
vote up
|
Markos
said:
|
> Wonder why VB couldn't make it a simpler process????? Would sure make it easier. They're working on it. What happened is that VBox added support for native VmWare VM files but this makes them regress in some of the features they used to support like shrinking VM files. Eventually these features will come back. |
|
|
report abuse
vote down
vote up
|
Stephan Wehner
said:
|
Is there a command to perform the release / undo release, instead of going through point and click sequences ? Stephan |
|
|
report abuse
vote down
vote up
|
Ege
said:
| Great guide. Nice and simple to follow. Keep up the good work! | |
|
report abuse
vote down
vote up
|
PC Rescue
said:
Was trying to figure out how to transfer my machines onto a new PC with fresh installation. Problem now solved, thanks to you! |
|
|
report abuse
vote down
vote up
|
Ben
said:
| Hey Axel - thanks for the guide, really helped. One point is that when you're using clonevdi you can't use relative paths for the .vdi files, you seem to need to put the full path. | |
|
report abuse
vote down
vote up
|
brian
said:
| I have an image that has several snapshots associated with it. my OS got screwed up and I had to reinstall. I have the VB hard disk and the machine with all of the snap shots, but I cannot figure out how to reattach it. I tried by creating a new machine and attached the vdi file from the hard disk folder, but it was the original snapshot of the system. Is there a way to just reattach my machine XML and have it come back to life? | |
|
report abuse
vote down
vote up
|
Jazz
said:
| Not sure if this is a stupid question, but will cloning an XP virtual machine in this matter cause any licensing issues? In other words, will Windows XP on the clone still think it's on the exact same machine? | |
|
report abuse
vote down
vote up
|
Jazz
said:
|
I see! Firstly, thank you for your prompt response! I'm interested in backing up my virtual machine (which has a legitimately activated Windows XP install). Would straight up copying the .vdi suffice to this end if I either attached the backed-up .vdi (with the identical UUID) to the old guest machine, or deleted the old VM and made a new one with exact the exact same configuration? My concern is that I must use certain Windows apps with a lot of my school work. Even being pointed in the right direction would be a huge help! |
|
|
report abuse
vote down
vote up
|
Jazz
said:
| Okay, I'm back to bother you again! Do you think exporting a virtual machine through the "Export Appliance" option would be a good way to back up a machine? | |
|
report abuse
vote down
vote up
|
Jazz
said:
Hey man don't worry about it. You've been very helpful and I definitely appreciate it! |
|
|
report abuse
vote down
vote up
|
dramirez
said:
|
#!/bin/bash # hardwired script - master image is "Venus" want to clone it to "Neptune" echo "Release HDD from Venus" VBoxManage --nologo modifyvm "Venus" -hda none sleep 1 echo "Unregister HDD from Venus" VBoxManage --nologo closemedium disk /home/vmadmin/.VirtualBox/HardDisks/Venus.vdi sleep 1 echo "CLONING OF HDD STARTING..." VBoxManage --nologo clonehd /home/vmadmin/.VirtualBox/HardDisks/Venus.vdi /home/vmadmin/.VirtualBox/HardDisks/Neptune.vdi sleep 1 echo "Cloning finished... re-register HDD to Venus" VBoxManage --nologo openmedium disk /home/vmadmin/.VirtualBox/HardDisks/Venus.vdi sleep 1 echo "Re-attach HDD to Venus" VBoxManage --nologo modifyvm "Venus" -hda /home/vmadmin/.VirtualBox/HardDisks/Venus.vdi sleep 1 echo "Now the new machine (HARDWIRED TO Neptune)" echo "Create the new VM" VBoxManage --nologo createvm -name "Neptune" -register sleep 1 echo "Parametrize new VM" VBoxManage --nologo modifyvm "Neptune" -memory "256MB" -acpi on -boot1 disk -nic1 nat sleep 1 VBoxManage --nologo openmedium disk /home/vmadmin/.VirtualBox/HardDisks/Neptune.vdi echo "Attach recent clone copy of Venus, now named Neptune.vdi to new VM" VBoxManage --nologo modifyvm "Neptune" -hda /home/vmadmin/.VirtualBox/HardDisks/Neptune.vdi echo " You are set !! " NOTE: Run this as vmadmin user belonging to group vboxusers. |
|
|
report abuse
vote down
vote up
|
Luigi
said:
|
Thanks for great help! 1. with regards to DRAMIREZ script, any hopes to have similar for Windows? 2. Just created XP-Pro SP3 legitimate VM. If I continue building it with Office 2003, Studio10, Adobe Premier, etc., how can I create a final image to install in my PC if it dies, as the "real" OS, not as a VM? Thanks again for your great insight. This e-mail address is being protected from spam bots, you need JavaScript enabled to view it |
|
|
report abuse
vote down
vote up
|
Scott R.
said:
|
Thanks a bunch! That would have taken me days to figure out! Thank you! Scott |
|
|
report abuse
vote down
vote up
|
Thomas
said:
| since a VM can have multiple drives attached, has settings and a history of snapshots. A VDI is only a virtual disk image. So this guide does less than half of the job. | |
|
report abuse
vote down
vote up
|
Write comment
You must be logged in to a comment. Please register if you do not have an account yet.
| Next > |
|---|






If you are reading this guide most probably you will know what Virtualbox is. But just in case let me tell a few words about it. VirtualBox is a cross platform application that allows you to create Virtual Machines. In other words VirtualBox runs on Windows, Linux, Macintosh and OpenSolaris hosts and supports a large number of guest operating systems such as Windows, Linux and OpenBSD. This means that you can run an Operating System through another at the same time. This is a very good way for experimenting and avoiding dual, triple or multiboot systems. I have already published two VirtualBox guides. The first one is 










