On 7/19/24 05:02, Alberto Garcia wrote:
On Thu, Jul 18, 2024 at 07:33:14PM +0200, Jakob Bohm via wrote:
I accidentally delete the backing file. It was a very old
200GB file from 2018. The snapshot is 1 TB and I can't use it.
[...]
Is there something I can do to recover the files in the snapshot?
Well, you deleted all the virtual disk sectors that were
unchanged since the backing file.
To get back all disk sectors changed since the backing file,
just repoint the qcow2 image to an all zero backing file .
Interesting, it's an idea I suggested on IRC (where Leonel came
first), but someone mentioned it would not work.
Will snapshot apply the diff "blindly", without checking src block
(in backing file) was the one expected?
I believe qcow2 itself has no information about the expected sector
contents, but the file system and applications in the virtual
machine might.
A qcow2 file is a collection of data clusters of the same size (you
can see the size with 'qemu-img info').
Each cluster can be allocated (it contains the actual data) or
unallocated (the data is read from the backing file, or is zero if
there is no backing file). There are no checksums or any kind of
information about the expected contents, you can actually replace one
backing file with a different one and QEMU won't notice (your virtual
machine will, of course).
If you deleted the backing file then the clusters that were
unallocated in the active file are now zeroes. That's the data that
you lost.
You can see the affected clusters with 'qemu-img map' but there is no
way to recover that information at the QEMU / qcow2 level.
Berto
Thanks for the information.
Let's hope Leonel can retrieve some files using a blank base image.