Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

virtual machine - Restore VM after loosing base files

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...