How to create a live snapshow of a running KVM virtual machine

KVM Snapshotting and Cloning 101

Snapshotting

First the VM must be in qcow2 format. Do this to check:

virsh dumpxml nsx.example.com | grep -i qemu
<emulator>/usr/libexec/qemu-kvm</emulator>
<driver name='qemu' type='qcow2'/>

Next do this:

virsh snapshot-create-as --domain nsx.example.com --name "04nov2023s0" --description "test" --live
error: Operation not supported: live snapshot creation is supported only with external checkpoints

The confusing message will go away once you drop --live.

To see the snapshot(s):

virsh snapshot-list --domain nsx.example.com
Name Creation Time State
------------------------------------------------------------
04nov2023s0 2023-11-04 12:07:48 +0200 running

Cloning

Suspend the machine:

virsh suspend ns2.vander.host
Domain ns2.vander.host suspended

Try prompt and fail:

virt-clone --prompt
WARNING --prompt mode is no longer supported.
ERROR Either --auto-clone or --file is required, use '--auto-clone or --file' and try again.

Do manual cloning using the command line:

virt-clone -o nsx.example.com -n nsx.example.com.clone -f ./nsx.example.com.clone.raw
WARNING Setting the graphics device port to autoport, in order to avoid conflicting.
Allocating 'nsx.example.com.clone.raw' | 10 GB 00:06:22

Clone 'nsx.example.com.clone' created successfully.

It took around 6 minutes to clone 10 gigabytes.

Then copy it to another hypervisor took quite long:

> 9668MB 49.0MB/s 03:17

Reference

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top