Page 1 of 1

Again about copying virtual machine [SOLVED]

Posted: 5. Jul 2010, 10:09
by gaga
Hi all,
I've read some posts about moving virtual machine from one host to another and found out that there are several ways, the easiest is to use import/export. However, I have a different situation: I'm a new VirtualBox user, that's why I was expecting it to behave like VmWare, which apparently is wrong. So, I created and configured virtual machine at home, did some job and then copied its folder and .vdi image to USB stick and wanted to get it work at my job. I tried to edit VitualBox.xml at job computer and to create new virtual machine and use copied image from virtual drives manager. In both cases I got error:

Code: Select all

VDI: invalid pre-header in 'f:\VM\VBox\hdd\lubuntu10.04.vdi' (VERR_VD_VDI_INVALI
D_HEADER).
VD: error VERR_VD_VDI_INVALID_HEADER opening image file 'f:\VM\VBox\hdd\lubuntu1
0.04.vdi' (VERR_VD_VDI_INVALID_HEADER)
so I'm unable to register copied .vdi image.
Is there a way to use copied image on new host?
PS1 I was stupid enough to copy image while virtual machine was paused, not switched off.
PS2 No need to mention that my home PC has crashed yesterday and doesn't boot now =)

Re: Again about copying virtual machine

Posted: 5. Jul 2010, 14:25
by mpack
1. Restore the edited VirtualBox.xml file to its previous state - do not edit these files manually unless you really know what you are doing.

2. Once VirtualBox.xml has been restored, copy your VDI file to any convenient folder on the host PC. Run VirtualBox GUI, select File | Virtual Media Manager and select 'Add' to add a new hard disk, pointing VBox at the new location of your VDI.

3. Create a new VM with the same settings as it had on the old host. In particular make sure that the hard disk controller, IO APIC setting and and MAC address is the same. When you get to the hard disk creation step select "Use existing" and select your VDI from the list.

Re: Again about copying virtual machine

Posted: 5. Jul 2010, 23:49
by gaga
Thank u, mpack, but that was the first thing I've tried, I've forgotten to write about it. I'm getting the same described error when opening .vdi from manager.

Re: Again about copying virtual machine

Posted: 6. Jul 2010, 03:53
by athanazio
gaga,
in my experience, I'm able to copy vdi files from one host to another, but allways with the machine off.

and usually I dont copy the xml it self, just create the machine again using the copied vdi file.

Re: Again about copying virtual machine

Posted: 6. Jul 2010, 09:22
by gaga
So, the problem is that I copied .vdi image from paused machine? Otherwise simple copying .vdi file should be OK?
By the way, I've installed 3.2.6 version on my job computer(windows) and error message became slightly different:

Code: Select all

f:\VM\VBox\hdd>vboxmanage showhdinfo lubuntu10.04.vdi
Oracle VM VirtualBox Command Line Management Interface Version 3.2.6
(C) 2005-2010 Oracle Corporation
All rights reserved.

ERROR: Could not get the storage format of the medium 'C:\Documents and Settings\asauta.NIS-5374\.VirtualBox\HardDisks\lubuntu10.04.vdi' (VERR_NOT_SUPPORTED) 
Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component Medium, interface IMedium, callee IUnknown

Context: "OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())" at line 1172 of file VBoxManageDisk.cpp

Re: Again about copying virtual machine

Posted: 6. Jul 2010, 11:04
by mpack
gaga wrote:So, the problem is that I copied .vdi image from paused machine? Otherwise simple copying .vdi file should be OK?
No, the problem is not that you copied a VDI from a paused machine (though as you already know that is something you should never do), because the worst case with that is that the guest OS cached the disk, meaning you may corrupt any files which were open for writing. This would be very unlikely to stop Windows booting though.

However the error message you are seeing is not coming from Windows, it's coming from VirtualBox - and VirtualBox wouldn't care if every file on the drive was corrupted (it doesn't care about content), so it must be complaining about something else. Now if you had used an old copy of VBox on the source PC then the VDI format might simply be obsolete, but if you only recently came to VBox then that seems unlikely. The only remaining possibility I can think of is that you somehow managed to corrupt the VDI: either while copying it onto a USB stick (FAT32 4GB limit not noticed, cached drive not stopped before unplugging), or on the target PC (accidentally edited with eg. notepad?).

If you still can't boot your home PC (coincidence, or did you do something really catastrophic?) then one possibility is to mount it's hard disk in an external USB housing.

If for some strange reason you did use an obsolete VBox version on your home PC then you should be able to convert the VDI to latest format using CloneVDI, but I wouldn't hold out much hope: the most likely scenario is that this tool will also reject your VDI because it is corrupted, not just outdated.

Re: Again about copying virtual machine

Posted: 6. Jul 2010, 14:17
by gaga
mpack, thanks for detailed answer. Now, since I know that generally it's correct to copy .vdi images, I presume that image is corrupted or obsolete(which is unlikely, I use VBox 3.0 from Ubuntu Karmic repos). I'll try to fix my home PC or boot on other PC with my home hard drive and see what's happening with VBox there.
No, I didn't do anything catastrophic, I wasn't even home at this weekend when it shut down;) My PC is about 8 years old, so maybe just its time has come)

Re: Again about copying virtual machine

Posted: 6. Jul 2010, 14:33
by mpack
I've just noticed that Windows is your host, not your guest. Never mind, my answer is the same except replace "Windows" with "Ubuntu" or whatever.

How did you create this guest VM? I.e. you've indicated that you were previously a VMWare user. Did you somehow convert a VMDK to VDI, did you install this guest from scratch? Download a readymade VDI from a site?

Re: Again about copying virtual machine

Posted: 7. Jul 2010, 10:57
by gaga
mpack,
I've created this VM from scratch.
But you were absolutely right, the image is corrupted. I understood this by comparing this image with the one I've created on job PC and which is working fine. The last one contains <<< Sun VirtualBox Disk Image >>> starting from first byte, while the former has some junk before it. This seems to be tar error, which I used to compress image in conjunction with gzip. I even noticed tar unpacking errors, which I missed before because of unpacking in background. So, that seems to be the problem.

Re: Again about copying virtual machine

Posted: 9. Jul 2010, 12:25
by gaga
OK, the problem was not related to VBox, image was corrupted. I can't figure out why, but I couldn't correctly decompress VDI from tar archive at my job. I fixed my home PC and everything was ok there, so it's maybe windows tar implementation problem. Now virtual machine is working fine. Thank you everyone for your help.