9

I'm running some Xen-servers and started migrating to KVM.

Currently my guests are either running on raw-images or LVMs.

I found libvirt providing some very nice snapshot features (virsh snapshot-create, ...) so I decided to use qcow2 instead of raw/lvm.

And here is my question: libvirt creates the same sort of snapshots on the qcow2 image as if I use qemu-img - is it possible to mount them ? I read something about qemu-nbd and the possibility of mounting qcow but I could not find a word about snapshots.

2 Answers 2

6

You should apply the snapshot and mount the image like always. It's better to create a snapshot right before applying if you want to turn back to the original disk contents before you do these operations. After you apply the snapshot you just mount the image with qemu-nbd as always:

# modprobe nbd max_part=8
$ qemu-img snapshot -c backup image.qcow2
$ qemu-img snapshot -a old_snapshot image.qcow2
$ qemu-nbd --connect=/dev/nbd0 image.qcow2
# mount /dev/nbd0p1 /mnt

You might want to save snapshot separately and mount it as another disk drive. For this you should use convert comand for qemu-img.

$ qemu-img convert -s old_snapshot image.qcow2 old_snapshot.qcow2
$ qemu-nbd --connect=/dev/nbd0 old_snapshot.qcow2
# mount /dev/nbd0p1 /mnt    

See man qemu-img(1) and qemu-nbd(1) for more details.

1
  • In between the qemu-nbd connect and the mount, it can be very helpful to run a partprobe -s /dev/nbd0 otherwise the partitions aren't always discovered especially from within quick running bash scripts.
    – Dave
    May 30, 2014 at 15:42
0

it uses qemu-img for snapshot creation. So if you mount a snapshot, it should be able to access the rest of the images further down the snapshot chain

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .