[Invalid] data loss due to clonehd ?!

Discussions related to using VirtualBox on Windows hosts.
Post Reply
benni
Posts: 11
Joined: 19. Dec 2015, 22:24

[Invalid] data loss due to clonehd ?!

Post by benni »

VBox version: 5.0.20 R106931
Host OS: Win7 x64
Guest OS: WinXP x86

hi folks,

something weird happened. I cloned my virtual hd and changed the hd of my vm to the clone. now, the system is almost 600 days old (probably an old snapshot). when i switch back to the original hd, the system is ~300 days old (my "newest" snapshot :/ ).
why would vboxmanage (vboxmanage clonehd "orig" "new") clone a snapshot instead of my actual state? and can i get back my original system somehow??

maybe -and just maybe- this info helps... originally, i cloned the hd because i couldn't resize the hd. the resize command worked and it was also shown in the virtual media manager. but the gparted boot cd saw the hd (not the partition) with the old size and nothing more. when i cloned the hd, the clone worked fine with gparted and i could resize my partition easily. maybe, my original virtual hd was defective in some way??

but the most important part is to restore my system somehow.

cheers,
benni
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: data loss due to clonehd ?!

Post by mpack »

It cloned the base VDI because you told it to clone the base VDI.

It's all covered in the FAQ: How to resize a Virtual Drive.
benni
Posts: 11
Joined: 19. Dec 2015, 22:24

Re: data loss due to clonehd ?!

Post by benni »

thanks mpack for the fast reply.
If a snapshot chain is involved then <infilename> should be the name of the latest snapshot VDI in the "Snapshots" subfolder. Do not make the rookie mistake of cloning the base VDI.
that explains a lot :mrgreen:

ok.. is there a way to restore my original system?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: data loss due to clonehd ?!

Post by scottgus1 »

Mpack has a magic wand and a pound of pixie dust in his CloneVDI utility that will probably help. See the Release Notes with the utility, the "Cloning Snapshots" section.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: data loss due to clonehd ?!

Post by mpack »

If all you did was resize the base VDI in place then the original VM should be unaffected. Ideally you could even restore just the base VDI from that backup you made just before you tried something as risky as an in-place edit to your system drive.

Frankly I would not recommend that anyone but an expert attempt to clone a VM which uses snapshots. Like the FAQ says, I would first clone the current state only to a new VM, then I'd resize the new VM.

If the original VM has been hosed for other reasons then CloneVDI may be able to recover it, as Scottgus mentions.
benni
Posts: 11
Joined: 19. Dec 2015, 22:24

Re: data loss due to clonehd ?!

Post by benni »

thanks for your replys.

well.. i made a snapshot -i think with the cloned vdi- before i realized that is was an outdated state.

so the sequence (most likely) was:
- resized vdi1
- cloned vdi1 to vdi2
- booted from vdi2
- took a snapshot from vdi2
- booted vdi1 again

and yes: after reading the faq, it makes sense to read it first. frankly, i couldn't even think of a way why cloning a drive (and keeping the old one) could be dangerous in any way.

is there a how-to on fixing a messed up vdi with cloneVDI somewhere ?? ;)
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: data loss due to clonehd ?!

Post by mpack »

That still doesn't destroy the VM. Snapshots don't work the way you seem to think they do.

Snapshots are patch files. They contain instructions on how to patch the previous element of the chain in order to produce a complete image. When you create a VM you have the base file only - no patch files. When you create your first snapshot the base VDI is frozen (no more writes allowed) and a first patch file (what you think of as a snapshot file) is created. When you create a second snapshot then this first patch file is frozen and second patch file is created, which patches the image created by the first patch file. I.e. snapshots are a chain of patch files.

Note that it's the disk image which is being patched, not the VDI containers themselves (i.e. headers don't get patched). If you were to corrupt an early disk image then this corruption can be propagated along the entire chain. However a resize is merely a header manipulation and hence does not affect the disk image and hence will not directly corrupt a snapshot chain.

Since the resize step has no ill effects then of course creating a new snapshot will also work and have no ill effects.



I think that instead of giving us your conclusions you should concentrate on giving the reasons for thinking the VM is not working, including any destructive steps you might have taken but not mentioned so far (in particular - if you cloned the standalone base VDI and added it back to the VM then say so).
benni
Posts: 11
Joined: 19. Dec 2015, 22:24

Re: data loss due to clonehd ?!

Post by benni »

thanks for your help so far..
(in particular - if you cloned the standalone base VDI and added it back to the VM then say so).
yes, that's exactly what i meant with "booted from vdi2".

so, is it (still) possible to try out the VDIs in the snapshot folder until one of them is the correct state?
i would have tried that already but how can i do a backup of the state right now without destroying even more? because i've already put work into the messed up vm...
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: data loss due to clonehd ?!

Post by mpack »

If you overwrote the snapshot structure in a VM with a non-snapshot VDI then that VM is toast. There is no official way to recover it without a backup.

Unofficially - and with zero guarantees - you can put all VDIs (base and all snapshots) in a folder, then clone the NEWEST snapshot image using CloneVDI (not counting any snapshots created after you toasted the VM).

You must build a new VM around the clone VDI. Make sure the VDI ends up inside the VM folder.

I also suggest that you stop using snapshots, and start making real backups.
benni
Posts: 11
Joined: 19. Dec 2015, 22:24

Re: data loss due to clonehd ?!

Post by benni »

hi mpack,

i was gone for a few days, but now i could try the recovery.... and it WORKED :)
thank you so much for your help and your awesome tool cloneVDI.

cheers,
benni
Post Reply