Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
926 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...