KVM snapshotting. How to see what's inside the qcow2 file?

Solution 1:

In order to shrink the image, I'd suggest to use virt-sparsify

export TMPDIR=/var/tmp/
virt-sparsify --check-tmpdir=continue <name>.qcow2 <name>_sparsed.qcow2

Make sure you have enough space in the TMPDIR, otherwise the conversion would crash.

Don't use virt-sparsify on running VM images. You may end up with corrupted image! (see man)


Then you can also use compress option (-c) of the qemu-img convert. However that would probably have some impact on the performance, but probably only during startup and initial load of services.

Solution 2:

qcow2 images can be inspected & mounted using quemu-nbd.

qemu-nbd --connect=/dev/nbd0 /path/to/your/vm-image.qcow2
fdisk /dev/nbd0 -l
mount /dev/nbd0p1 /mnt/your/mountpoint/

to list/create/delete snapshots use qemu-img snapshot

e.g. to list the available snapshots

qemu-img snapshot -l /path/to/your/vm-image.qcow2

to check snapshots content mount the snapshot

qemu-nbd --connect=/dev/nbd0 /path/to/your/vm-image.qcow2 --load-snapshot=1

the snapshot identifier is either its id or the name