KVM is a hyper visor used by a lot of Linux distributions. I am currently using it and very happy with it. I have most of the abilities paid hypervisors like HyperV, Vmware provides.
Snapshots is picture of the VM in specified time. For example we will install new application but it can brake our system. We want to backup our system and if something bad happens we want to revert back. The simplest and fast solution is snapshot. I saves the status of disk and ram. And can be retrieved back.
Entering Virsh Console
The tool we will use to manage snapshots and libvirt is virsh. We can use virsh from bash or enter into virsh console. Both are same effect but I prefer to enter console.
$ sudo virsh

- virsh needs root privileges so we provide sudo or run with root account.
- virsh# is our virsh console
Create Snapshot of Vm
Snapshots can be created by different ways but we will use libvirt to create snapshot. We will use the snapshot-create-as
command by providing the VM name which is poftut
in this case.
virsh # snapshot-create-as poftut1 Domain snapshot 1477620808 created
- We provide snapshot-create-as command to snapshot poftut1 is the domain name of the vm
- 1477620808 is snapshot id of the vm.
List Snapshots
One VM may have more than one snapshots. We can list the snapshot of the specified VM like below.
virsh # snapshot-list poftut1
- snapshot-list is the command and
- poftut1 vm name is provided. We can use domain id for vm name
Name Creation Time State ------------------------------------------------------------ 1477620808 2016-10-28 05:13:28 +0300 shutoff
- As we see snapshot-list command gives details of the snapshot
- 1477620808 is snapshot name
- 2016-10-28 05:13:28 +0300 is snapshot date
- shutoff is the status of vm while taking snapshot
Get Details of Snapshot
We can get more detail about snapshot with snapshot-info command.
virsh # snapshot-info poftut1 1477620808
- snapshot-info is the command get detailed info about snapshot.
- poftut1 is the vm of the snapshot
- 1477620808 is the snapshot name
Name: 1477620808 Domain: poftut1 Current: yes State: shutoff Location: internal Parent: - Children: 0 Descendants: 0 Metadata: yes
Revert Back The Snapshot Previous Version
We have changed vm and we want to revert back. It is easy as creating snapshot
virsh # snapshot-revert poftut1 1477620808
- snapshot-revert is the command used
- poftut1 is the vm name
- 1477620808 is the snapshot name
Delete Snapshot
We want to delete snapshot because we have completed our work.
virsh # snapshot-delete poftut1 --snapshotname 1477620808
- snapshot-delete is command we will use
- poftut1 is the vm name
- We will provide snapshot name with –snapshotname argument and 1477620808
Domain snapshot 1477620808 deleted
- We have deleted the snapshot
How To Create Snapshot of KVM / Libvirt / Qemu Vm? Infografic
