We have an openstack platform with KVM as hypervisor. Due to some reason we lost VMs due to hardware issue with the physical disks. But we have the VM's disk files still present. But we lost the 'base' backing files. We want to restore the data present in those disk files. How is it possible?
Asked
Active
Viewed 375 times
2
-
How about creating new VMs with the same disk format and size, and then simply replace the files in them before you start them? It is the simplest way for a beginner. If you only want to save the files, without creating new VMs, you can first convert them to raw, then use the tool kpartx to get access to their partitions, fsck their partitions and then mount them and copy where you want to. – peterh Jan 05 '21 at 11:39
-
If your disk vmdk files are damaged, you need also recover them. While the vmdk format is public, quick googling did not result a free & opensource recovery tool for me. But Vmware has [developed](https://kb.vmware.com/s/article/1007243) a not free, not opensource but downloadable one. – peterh Jan 05 '21 at 11:40
1 Answers
0
Assuming your vm disk files are in the qcow2
format (which is the default for OpenStack), you should be able to first identify the appropriate base file by running:
qemu-img info <filename>
This will yield information about the qcow2 disk image, including the path to the backing file. Output will look something like this:
$ qemu-img info /var/lib/nova/instances/instance-0000000c/disk
image: /var/lib/nova/instances/instance-0000000c/disk
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 149M
cluster_size: 65536
backing file: /var/lib/nova/instances/_base/06a057b9c7b0b27e3b496f53d1e88810a0d1d5d3_20
The information you care about is the backing_file
. This is supposed to be a raw
format disk image create from Glance, where the filename (before the _
) should be a glance image id.
You should be able to use that to download the image from Glance, convert it to raw
format if necessary, and put it in the right place.

larsks
- 277,717
- 41
- 399
- 399