[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt-users] re-create disk image file



On 11/05/2012 01:25 PM, Joe Linoff wrote:
> Hi Henrik:
> 
> When I tried to copy the file descriptor file a "Stale NFS file handle"
> error was generated:
> 
> $ cp -f /proc/13196/fd/9 /tmp/guest.img
> cp: cannot stat `/proc/13196/fd/9': Stale NFS file handle
> 
> I suppose that makes sense because the file was accidently deleted but
> from the NFS server perspective it really isn't there. Do you know of
> any way to work around it?
> 
>> Or why not just attach a new disk to the guest and copy stuff inside
> the guest?
> 
> I understand how that would work to recover individual files/directories
> but I don't understand how I would be able to recover the entire image.
> Can you explain?

Wouldn't something like:

dd /dev/vda /dev/vdb

from within the guest do the trick of copying the entire image?  But
that's risky if the guest is actively modifying /dev/vda at the same time.

What version of libvirt and qemu are you using?  If at least 0.9.6 and
1.2 respectively, I think it should be possible to use 'virsh blockpull'
to resolve your conundrum, as follows:

# Create a new qcow2 file that wraps the deleted but still-open file
virsh snapshot-create-as $dom --no-metadata --disk-only \
  --diskspec /tmp/guest.img,file=/tmp/guest.img1

# Pull the contents into the new file
virsh blockpull $dom /tmp/guest.img1 --wait --verbose

at which point, the new file /tmp/guest.img1 should contain everything
in use by the old deleted file, while no longer needing to keep the old
file around, so it will finally be safe to stop your guest.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]