lost and found ( for me ? )

Showing posts with label snapshots. Show all posts
Showing posts with label snapshots. Show all posts

Ubuntu 14.04 KVM : create snapshots

Reference

Here are examples of how to take snapshots on KVM.

KVM host : Ubuntu 14.04
VM : Ubuntu 14.04

list snapshots of the VM
virsh # snapshot-list ubuntu1404-vm8
Name                 Creation Time             State
------------------------------------------------------------

virsh #

create a snapshot.
error, KVM does not support taking snapshots with raw format.
I need to convert the VM image format to qcow2 from raw.
virsh # snapshot-create-as ubuntu1404-vm8 ss01
error: unsupported configuration: internal snapshot for disk vda unsupported for storage type raw

shutdown the VM and covert the format type to qcow2.
virsh # shutdown ubuntu1404-vm8

# qemu-img convert -f raw -O qcow2 ubuntu1404-vm8.img ubunt
u1404-vm8.qcow2

start the VM
# file ubuntu1404-vm8.qcow2
ubuntu1404-vm8.qcow2: QEMU QCOW Image (unknown version)

# mv ubuntu1404-vm8.qcow2 ubuntu1404-vm8.img

edit the XML file of that VM to use qcow2 image.
# virsh edit ubuntu1404-vm8

from
<driver name='qemu' type='raw'/>

to
<driver name='qemu' type='qcow2'/>

start the VM
virsh # start ubuntu1404-vm8
Domain ubuntu1404-vm8 started

create a snapshot.
The VM is paused while creating a snapshot.
virsh # snapshot-create-as ubuntu1404-vm8 ss01

virsh # snapshot-create-as ubuntu1404-vm8 ss02

virsh # snapshot-list ubuntu1404-vm8
Name                 Creation Time             State
------------------------------------------------------------
ss01                 2015-01-04 13:04:13 +0900 running


virsh # snapshot-create-as ubuntu1404-vm8 ss02
Domain snapshot ss02 created
virsh #
virsh # snapshot-list ubuntu1404-vm8
Name                 Creation Time             State
------------------------------------------------------------
ss01                 2015-01-04 13:04:13 +0900 running
ss02                 2015-01-04 13:06:13 +0900 running

virsh #
virsh # snapshot-info --current ubuntu1404-vm8
Name:           ss02
Domain:         ubuntu1404-vm8
Current:        yes
State:          running
Location:       internal
Parent:         ss01
Children:       0
Descendants:    0
Metadata:       yes

virsh #

Go to the snapshot “ss01”
virsh # snapshot-revert ubuntu1404-vm8 ss01

virsh #

delete a snapshot.
virsh # snapshot-delete ubuntu1404-vm8 ss02
Domain snapshot ss02 deleted

KVM : how to take snapshots


Here’s an example of how to take snapshots.



# libvirtd --version
libvirtd (libvirt) 0.9.8

# qemu-system-x86_64 --version
QEMU emulator version 1.0 (qemu-kvm-1.0), Copyright (c) 2003-2008 Fabrice Bellard

# uname -ri
3.2.0-31-generic x86_64

# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 12.04.1 LTS"


take snapshots of the VM called ubuntu12-04-vm1.
# virsh list --all | grep 10
10 ubuntu12-04-vm1      running

# time virsh snapshot-create ubuntu12-04-vm1


[ while taking snapshots ]

The VM will be suspended while taking the snapshots.
# virsh list --all | grep 10
10 ubuntu12-04-vm1      paused


check the status
# virsh snapshot-list ubuntu12-04-vm1
Name                 Creation Time             State
------------------------------------------------------------
1349063425           2012-09-29 12:50:25 +0900 running


[ after finishing taking the snapshots ]

In my environment, it took about 13 minutes to take the snapshots.
# time virsh snapshot-create ubuntu12-04-vm1
Domain snapshot 1349063425 created

real    13m32.901s
user    0m0.052s
sys     0m0.016s

# virsh list --all | grep ubuntu12-04-vm1
10 ubuntu12-04-vm1      running

# virsh snapshot-list ubuntu12-04-vm1
Name                 Creation Time             State
------------------------------------------------------------
1349063425           2012-09-29 12:50:25 +0900 running

[ revert the snapshots ]

# virsh list --all | grep ubuntu12-04-vm1
11 ubuntu12-04-vm1      running

# virsh snapshot-list ubuntu12-04-vm1
Name                 Creation Time             State
------------------------------------------------------------
1349063425           2012-09-29 12:50:25 +0900 running

# time virsh snapshot-revert ubuntu12-04-vm1 1349063425

real    0m5.784s
user    0m0.000s
sys     0m0.008s

delete the snapshot
# time virsh snapshot-delete ubuntu12-04-vm1 1349063425
Domain snapshot 1349063425 deleted


real    0m1.330s
user    0m0.008s
sys     0m0.000s