Page 1 of 1

Virtual machine inaccessible [solved]

Posted: 26. Jan 2010, 14:04
by ian_ball
Hi all,

I've seen several posts with this topic however following the suggestions I have found there have not worked for me.

I am using Ubuntu 9.10 on AMD64 with VirtualBox 3.1.2 and have two Windows XP VM's. One today became inaccessible after saving its state and rebooting the host system. I found that the xml configuration file is empty with a file size of 0 (/home/ian/.VirtualBox/Machines/Windows_XP-Bettina/Windows_XP-Bettina.xml)

I have tried recreating a new VM using an existing hard disk, however the hard disk that Virtualbox finds is from a snapshot done shortly after install, which is unacceptable as there are numerous software packages which were not installed and large amounts of user data which has been imported, modified and created in that time. In the HardDisks directory, the vdi file is from 6 weeks ago, and since then there have been two snapshots.

In the Snapshots directory, the vdi file (/home/ian/.VirtualBox/Machines/Windows_XP-Bettina/Snapshots/{cdd7dcc4-071b-491f-8fdc-d90a3c49454f}.vdi) is from the last shutdown. The .sav file which I assume is associated with this VM and has the same timestamp as the vdi file and is empty.

-rw------- 1 ian ian 328M 2009-12-25 20:24 {31d7c455-0c40-4928-8070-5806a66991c2}.sav
-rw------- 1 ian ian 195M 2009-12-18 08:03 {57a1639e-69ca-4a85-9e88-dbd622af183d}.sav
-rw------- 1 ian ian 1.1G 2009-12-25 20:23 {74248b9e-c312-402c-819a-174a7e26230b}.vdi
-rw------- 1 ian ian 0 2010-01-26 11:26 {91a49bc9-0cf7-462b-ba12-32051c1c7bcc}.sav
-rw------- 1 ian ian 16G 2009-12-18 08:03 {97202f05-3151-4aa0-8fb5-849328ba689a}.vdi
-rw------- 1 ian ian 14G 2010-01-26 11:26 {cdd7dcc4-071b-491f-8fdc-d90a3c49454f}.vdi

The hard disk entries in the VirtualBox xml config file is as follows (other data is about net, usb and so on and is not relevant):
<MachineRegistry>
<MachineEntry uuid="{fe16a78e-2cec-4b82-a557-45e647780877}" src="Machines/WinXP-SP3-Ian/WinXP-SP3-Ian.xml"/>
<MachineEntry uuid="{91a49bc9-0cf7-462b-ba12-32051c1c7bcc}" src="Machines/Windows_XP-Bettina/Windows_XP-Bettina.xml"/>
<MachineEntry uuid="{5b1d893b-55ef-4c5f-b3c1-4b8ed97df026}" src="Machines/WindowsXP-Bettina/WindowsXP-Bettina.xml"/>
</MachineRegistry>
<MediaRegistry>
<HardDisks>
<HardDisk uuid="{19714cd0-4561-4eb4-8717-6c6c96097942}" location="HardDisks/WindowsXP-SP2.vdi" format="VDI" type="Normal"/>
<HardDisk uuid="{940d7993-b56d-490d-821e-782c455f17d9}" location="HardDisks/XP-SP3-60Gb.vdi" format="VDI" type="Normal">
<HardDisk uuid="{8fdfafa6-aba8-49dd-bbd3-d7ebe5fd3f3c}" location="Machines/WinXP-SP3-Ian/Snapshots/{8fdfafa6-aba8-49dd-bbd3-d7ebe5fd3f3c}.vdi" format="VDI">
<HardDisk uuid="{ab9276ef-2751-4cac-a551-40da56e949a8}" location="Machines/WinXP-SP3-Ian/Snapshots/{ab9276ef-2751-4cac-a551-40da56e949a8}.vdi" format="VDI"/>
</HardDisk>
</HardDisk>
<HardDisk uuid="{bf69d81b-8d16-4d4f-a3bf-c692072493e0}" location="HardDisks/Windows_XP-Bettina.vdi" format="VDI" type="Normal">
<HardDisk uuid="{97202f05-3151-4aa0-8fb5-849328ba689a}" location="/home/ian/.VirtualBox/Machines/Windows_XP-Bettina/Snapshots/{97202f05-3151-4aa0-8fb5-849328ba689a}.vdi" format="VDI">
<HardDisk uuid="{74248b9e-c312-402c-819a-174a7e26230b}" location="/root/.VirtualBox/Machines/Windows_XP-Bettina/Snapshots/{74248b9e-c312-402c-819a-174a7e26230b}.vdi" format="VDI">
<HardDisk uuid="{cdd7dcc4-071b-491f-8fdc-d90a3c49454f}" location="/root/.VirtualBox/Machines/Windows_XP-Bettina/Snapshots/{cdd7dcc4-071b-491f-8fdc-d90a3c49454f}.vdi" format="VDI"/>
</HardDisk>
</HardDisk>
<HardDisk uuid="{2f54ee40-283d-4e57-99f3-903e204a8fd6}" location="/root/.VirtualBox/Machines/WindowsXP-Bettina/Snapshots/{2f54ee40-283d-4e57-99f3-903e204a8fd6}.vdi" format="VDI"/>
</HardDisk>
</HardDisks>


I need to restore this image, otherwise my girlfriend is going to kill me!!! She has critical data in that VM related to the contracts she gets. Also, now I will be going away with her for the next three days, and I have no idea how I will tell her that everything she has done might be gone.

I will appreciate any help anyone can give me!

Re: Virtual machine inaccessible

Posted: 28. Jan 2010, 11:00
by MarkCranness
There is a good chance to recover that VM.

First, make sure you have ample free space on that partition (VirtualBox didn't error because of no free space did it?)

Short term to get quick access:
In the new recreated VM, when you attach a virtual hard disk, enable the 'Differencing Disks' checkbox, then select {cdd7dcc4-071b-491f-8fdc-d90a3c49454f}.vdi from the dropdown list.

This should get you the old VM as it was (but crashed/powered off).

Longer term:
  • Take backups before it gets any worse!
  • Do you have any other xml files in /home/ian/.VirtualBox/Machines/Windows_XP-Bettina/, perhaps a backup that VirtualBox might have taken when it was last upgraded? It might have a name like: Windows_XP-Bettina-1.7-linux.xml or similar. If you do, then try copying that to Windows_XP-Bettina.xml and boot.
  • If you end up running with the recreated VM and {cdd7dcc4-071b-491f-8fdc-d90a3c49454f}.vdi, then you will want to get rid of the snapshots and create a flattened copy of the virtual hard disk and use that instead: See here: Cloning a VM with multiple snapshots

Re: Virtual machine inaccessible

Posted: 29. Jan 2010, 21:52
by ian_ball
Thanks for the suggestion.

The VM didn't run out of space, there is still 212Gb free on that partition. It is a raid-1 partition on two 750Gb disks. There are no errors recorded in smart, and no reallocated sectors on the disks.

Unfortunately choosing the cdd7dcc4-071b-491f-8fdc-d90a3c49454f disk didn't work. I chose that by when choosing the hard disk, to the right of the drop down list is a small icon that looks like a folder symbol with an arrow point up in it. From there I opened up the list until the desired disk was visible and chose that. That window closes, however the next button in the hard disk selection requester is then greyed out and is not clickable.

If I choose first the Windows_XP-Bettina virtual disk, then open the dialog where I can choose the cdd7dcc4-071b-491f-8fdc-d90a3c49454f disk, the next button is selectable, however the system then boots into a 6 week old state.

There are no backup files in the directory:
# l /home/ian/.VirtualBox/Machines/Windows_XP-Bettina/
total 16
drwxr-xr-x 4 ian ian 4096 2010-01-26 11:52 .
drwxr-xr-x 6 ian ian 4096 2010-01-29 19:51 ..
drwxr-xr-x 2 ian ian 4096 2010-01-25 21:30 Logs
drwxr-xr-x 2 ian ian 4096 2010-01-26 11:26 Snapshots
-rw------- 1 ian ian 0 2010-01-26 11:26 Windows_XP-Bettina.xml


I'm wondering now if I can recreate the xml config file by hand to get the vm running again. To me, this seems like the most viable option I have at the moment. I have made a tar file of the directory, so if I mess something up now, I can extract the tar file and try again.

Re: Virtual machine inaccessible

Posted: 30. Jan 2010, 01:43
by MarkCranness
I see what you mean when you create a brand new VM: The Next button is disabled.
Instead: create a new VM and turn off the 'Boot Hard Disk (Primary Master)' checkbox so that NO hard disk is initially attached, and choose 'Continue' when asked.
Then Settings>Storage>Add Attachment (+ icon)>Add Hard Disk>select the created disk in the tree>turn on 'Differencing Disks' checkbox and select {cdd7dcc4-071b-491f-8fdc-d90a3c49454f} from the dropdown.
{cdd7dcc4-071b-491f-8fdc-d90a3c49454f}.vdi is dated 2010-01-26 and must be the correct disk!
If that fails, please 'Upload attachment' the xml file for the newly created VM.

Re: Virtual machine inaccessible

Posted: 30. Jan 2010, 12:46
by ian_ball
Thank you, that worked! It just booted up now, and everything looks ok. I will, as you suggested, create a flattened copy of the disk image asap, only after I have taken a tar of the entire .VirtualBox directory ;)

Last night before I saw your post, I stared a grep across the entire partition of each mirror to see what remnants of configuration files it could find. That was quite successful too, finding 18 different versions, including one from 25.01.2010. The way I did that was:
# grep -a -A 400 Windows_XP-Bettina /dev/sda3 > search.sda &
# grep -a -A 400 Windows_XP-Bettina /dev/sdb3 > search.sdb &
It never ceases amaze me seeing just how much gets left lying around on a hard drive. I would guess that taking the most recent version of the file should work in this case, however given the importance of the data I have, I'm not going to test it out just yet.... but maybe that will be useful suggestion to someone else who really gets stuck.

So Mark, if you ever come to Vienna, Austria, send me a mail so I can thank you personally and invite you to dinner at my favourite restaurant!

Ian

Re: Virtual machine inaccessible [solved]

Posted: 1. Feb 2010, 01:35
by coolnezz
cool! this solution worked for me also.
was having the same problem, VM was inaccessible, .xml file is empty, 0 bytes.
followed the directions and my XP guest OS booted with everything intact.
thank you!

-dennis-

Re: Virtual machine inaccessible [solved]

Posted: 15. Feb 2010, 11:39
by soerenporsgaard
Hello,

It sounds like this solution works. However, I am quite new to VirtualBox, so I don't really get how you solved it.
I would appreciate if somebody will write a more detailed guide.

Thanks

Re: Virtual machine inaccessible [solved]

Posted: 16. Feb 2010, 02:41
by MarkCranness
The solution requires knowing how snapshots and differencing hard disks work, and then examining any evidence left after the crash to identify which differencing disk belonged to the 'Current State'.

If you didn't have ANY snapshots at all, then you can just create a new VM and attach the base VDI file.

Snapshots and differencing hard disks are described here: Tutorial: All about VDIs, and in section 5.5 of the user manual.

Creating a snaphot freezes the virtual hard disk files at that point in time (the base virtual disk and any existing differencing disks) and creates a new child differencing disk to record any disk changes made to the virtual disk after the parent snapshot was taken.
As each snapshot is taken, a tree is built up of differencing disks. You can see this tree if you use VirtualBox menu: File>Virtual Media Manager... and expand tree under the base virtual disk. At the bottom of the tree is the 'Current State' differencing disk.

If you do NOT have branching snapshots, then the tree will be a single linear branch with the 'Current State' differencing disk at the very end/bottom. You can then either attach that 'Current State' differencing disk (instructions above in my 30. Jan 2010, 12:43 post), or make a flattened copy of that 'Current State' differencing disk (instructions above in my 28. Jan 2010, 22:00 post).

If you DO have branching snapshots, then the last-modified date/time on the differencing disk files (in the snapshot folder) can be used to help decide which differencing disk belongs to the 'Current State'.

If you need guidance, 'Upload attachment' your VirtualBox.xml file, a directory listing (including filesizes and date/times) of the .VirtualBox directory, and see if you have any backup machine xml files anywhere (see ian_ball's 30. Jan 2010, 23:46 post).

(PS: If you end up creating a new VM, it will be given a different MAC (Network card address) than the original VM, which may cause Windows to need re-activating. You can minimise this probability by using the same MAC address in the new VM as the old VM had, assuming you know what the old MAC was - from looking at any old machine xml that can be found.)