Ubuntu – Recovering running KVM guest disk image

kvm-virtualizationlibvirtUbuntu

I am running several KVM guests on an Ubuntu 10.04 host. Due to carelessness, the qcow2 images of the running hosts have been deleted. They are still running and responding properly as well as reading/writing, etc. If you stop a guest, it will refuse to boot due to a missing image though.

I am curious to know where these files are written to and read from currently. Is it in memory? Bonus question is, is it possible to recover the data back into a qcow2 image? This is not mission critical data so I'm glad to experiment here. It would mostly just be a time-saver if I didn't have to rescue the data and re-create each guest.

Best Answer

Having an open file descriptor and having a directory entry are different, somewhat related things. As long as KVM has the qcow2 files open they still exist on the disk in the same blocks they did before. On Linux you can recover the files from /proc/[pid]/fd/[file descriptor] using the method described in this SuperUser question.