qemu-discuss
[Top][All Lists]
Advanced

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

[Qemu-discuss] How to fix/recover corrupted qcow2 images


From: Ziemowit Pierzycki
Subject: [Qemu-discuss] How to fix/recover corrupted qcow2 images
Date: Mon, 6 Oct 2014 12:42:11 -0500

Hi,

I think it's pretty common knowledge it's difficult to fix qcow2 corruption.  If you suspect you have a bad qcow2 drive image, check:

# qemu-img check bad_file.qcow2

If there are issues, make sure the VM is down because the last thing you want is to continue to write to the image or do repairs while it's being used and:

# qemu-img check -r bad_file.qcow2

The repair option may not be available on some older version of qemu and it most likely won't fix the corruption all the way, so here is what I do:

# modprobe nbd
# qemu-nbd --connect=/dev/nbd0 bad_file.qcow2
# ddrescue /dev/nbd0 new_file.raw
# qemu-nbd --disconnect /dev/nbd0
# qemu-img convert -O qcow2 new_file.raw new_file.qcow2

Now, boot it up and assuming the corruption wasn't that bad, it should go to the rescue mode where you can perform FSCK.  Treat qcow2 corruption like a hard drive with bad blocks.  So far it worked 100% of the time for me.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]