KB10003 How manually remove snapshot from KVM

KB ID: 10003

Product: vProtect

Version: 3.8.0 +

Published: 2020-07-08

Last modified: 2020-07-08

Problem

vProtect creates a snapshot when taking backup, and leave it if the user want later create incremental backup.

If user removes vProtect, then snapshot stay on VM.

Before that stop vprotect-server


example:

list snapshot:

virsh snapshot-list alpine_c8

[root@kvm-c8 ~]# virsh snapshot-list alpine_c8
Name Creation Time State
------------------------------------------------------------
vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2 2020-07-07 13:48:47 +0200 disk-snapshot
vProtect-aa2878cb-288c-4ac9-b1ec-5a328f22a6f5 2020-07-07 14:03:07 +0200 disk-snapshot
vProtect-b534b5dd-9480-4336-bf17-81a4308dfb6f 2020-07-07 14:42:07 +0200 disk-snapshot
vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6 2020-07-07 15:48:27 +0200 disk-snapshot

remove snapshot:

virsh snapshot-delete --domain alpine_c8 --snapshotname vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6

[root@kvm-c8 ~]# virsh snapshot-delete --domain alpine_c8 --snapshotname vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6
error: Failed to delete snapshot vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6
error: unsupported configuration: deletion of 1 external disk snapshots not supported yet


Solution

Check your VM, it must be running:

virsh list --all
[root@kvm-c8 ~]# virsh list --all
Id Name State
----------------------------------------------------
1 alpine_c8 running


List all existing snapshot for your VM:

virsh snapshot-list alpine_c8

[root@kvm-c8 ~]# virsh snapshot-list alpine_c8
Name Creation Time State
------------------------------------------------------------
vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2 2020-07-07 13:48:47 +0200 disk-snapshot
vProtect-aa2878cb-288c-4ac9-b1ec-5a328f22a6f5 2020-07-07 14:03:07 +0200 disk-snapshot
vProtect-b534b5dd-9480-4336-bf17-81a4308dfb6f 2020-07-07 14:42:07 +0200 disk-snapshot
vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6 2020-07-07 15:48:27 +0200 disk-snapshot


Get configuration of your VM, and get path to disk image.

virsh dumpxml alpine_c8
<domain type='qemu' id='1'>
<name>alpine_c8</name>
<uuid>e14a550b-31ec-4d08-927f-af638d9a8c28</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://alpinelinux.org/alpinelinux/3.8"/>
</libosinfo:libosinfo>
</metadata>
<memory unit='KiB'>524288</memory>
<currentMemory unit='KiB'>524288</currentMemory>
<vcpu placement='static'>1</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.6.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6'/>
<backingStore type='file' index='1'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-b534b5dd-9480-4336-bf17-81a4308dfb6f'/>
<backingStore type='file' index='2'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-aa2878cb-288c-4ac9-b1ec-5a328f22a6f5'/>
<backingStore type='file' index='3'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2'/>
<backingStore type='file' index='4'>
<format type='qcow2'/>
<source file='/var/lib/libvirt/images/alpinelinux3.8.qcow2'/>
<backingStore/>
</backingStore>
</backingStore>
</backingStore>
</backingStore>
<target dev='hda' bus='ide'/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu'/>
<target dev='hdb' bus='ide'/>
<readonly/>
<alias name='ide0-0-1'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
<controller type='usb' index='0' model='ich9-ehci1'>
<alias name='usb'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x7'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci1'>
<alias name='usb'/>
<master startport='0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0' multifunction='on'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci2'>
<alias name='usb'/>
<master startport='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x1'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci3'>
<alias name='usb'/>
<master startport='4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'>
<alias name='pci.0'/>
</controller>
<controller type='ide' index='0'>
<alias name='ide'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='direct'>
<mac address='52:54:00:68:90:e2'/>
<source dev='ens192' mode='bridge'/>
<target dev='macvtap0'/>
<model type='e1000'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/1'/>
<target type='isa-serial' port='0'>
<model name='isa-serial'/>
</target>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/1'>
<source path='/dev/pts/1'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
<listen type='address' address='127.0.0.1'/>
</graphics>
<video>
<model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
<alias name='video0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='selinux' relabel='yes'>
<label>system_u:system_r:svirt_tcg_t:s0:c271,c460</label>
<imagelabel>system_u:object_r:svirt_image_t:s0:c271,c460</imagelabel>
</seclabel>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+107:+107</label>
<imagelabel>+107:+107</imagelabel>
</seclabel>
</domain>


List all disk of your VM:

ll /var/lib/libvirt/images/alpinelinux3.8.qcow2*

[root@kvm-c8 ~]# ll /var/lib/libvirt/images/alpinelinux3.8.qcow2*
-rw-------. 1 qemu qemu 1611071488 Jul 7 13:48 /var/lib/libvirt/images/alpinelinux3.8.qcow2
-rw-------. 1 qemu qemu 5963776 Jul 7 14:03 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2
-rw-------. 1 qemu qemu 14221312 Jul 7 14:42 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-aa2878cb-288c-4ac9-b1ec-5a328f22a6f5
-rw-------. 1 qemu qemu 22282240 Jul 7 15:48 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-b534b5dd-9480-4336-bf17-81a4308dfb6f
-rw-------. 1 qemu qemu 3407872 Jul 7 15:55 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6


On disk attached to VM check chain of disks:

qemu-img info /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6 --backing-chain -U

[root@kvm-c8 ~]# qemu-img info /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6 --backing-chain -U
image: /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6
file format: qcow2
virtual size: 1.5G (1610612736 bytes)
disk size: 13M
cluster_size: 65536
backing file: /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-b534b5dd-9480-4336-bf17-81a4308dfb6f
backing file format: qcow2
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

image: /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-b534b5dd-9480-4336-bf17-81a4308dfb6f
file format: qcow2
virtual size: 1.5G (1610612736 bytes)
disk size: 21M
cluster_size: 65536
backing file: /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-aa2878cb-288c-4ac9-b1ec-5a328f22a6f5
backing file format: qcow2
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

image: /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-aa2878cb-288c-4ac9-b1ec-5a328f22a6f5
file format: qcow2
virtual size: 1.5G (1610612736 bytes)
disk size: 14M
cluster_size: 65536
backing file: /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2
backing file format: qcow2
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

image: /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2
file format: qcow2
virtual size: 1.5G (1610612736 bytes)
disk size: 5.6M
cluster_size: 65536
backing file: /var/lib/libvirt/images/alpinelinux3.8.qcow2
backing file format: qcow2
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

image: /var/lib/libvirt/images/alpinelinux3.8.qcow2
file format: qcow2
virtual size: 1.5G (1610612736 bytes)
disk size: 1.5G
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: true
refcount bits: 16
corrupt: false

In our example we have all disk in the same chain.


Get simple name of disks:

virsh domblklist alpine_c8

[root@kvm-c8 ~]# virsh domblklist alpine_c8
Target Source
------------------------------------------------
hda /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6
hdb -


Merge disk, that process can take a while, depend of disk size:

virsh blockcommit alpine_c8 hda --verbose --pivot --active

[root@kvm-c8 ~]# virsh blockcommit alpine_c8 hda --verbose --pivot --active
Block commit: [100 %]
Successfully pivoted


When the disk is merged you can check it is single file:

virsh domblklist alpine_c8

[root@kvm-c8 ~]# virsh domblklist alpine_c8
Target Source
------------------------------------------------
hda /var/lib/libvirt/images/alpinelinux3.8.qcow2
hdb -


Next remove snapshot information from VM:

virsh snapshot-delete --children --domain alpine_c8 --snapshotname vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2 --metadata

[root@kvm-c8 ~]# virsh snapshot-delete --children --domain alpine_c8 --snapshotname vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2 --metadata

Domain snapshot vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2 deleted


When you check again files of disks on file system you see active is "/var/lib/libvirt/images/alpinelinux3.8.qcow2", and rest images still on filesystem:

ll /var/lib/libvirt/images/alpinelinux3.8.qcow2*

[root@kvm-c8 ~]# ll /var/lib/libvirt/images/alpinelinux3.8.qcow2*
-rw-------. 1 qemu qemu 1611071488 Jul 8 13:48 /var/lib/libvirt/images/alpinelinux3.8.qcow2
-rw-------. 1 qemu qemu 5963776 Jul 7 14:03 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2
-rw-------. 1 qemu qemu 14221312 Jul 7 14:42 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-aa2878cb-288c-4ac9-b1ec-5a328f22a6f5
-rw-------. 1 qemu qemu 22282240 Jul 7 15:48 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-b534b5dd-9480-4336-bf17-81a4308dfb6f
-rw-------. 1 qemu qemu 3478943 Jul 7 16:24 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6


Remove not require files from filesystem:

rm /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-aa2878cb-288c-4ac9-b1ec-5a328f22a6f5 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-b534b5dd-9480-4336-bf17-81a4308dfb6f /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6

[root@kvm-c8 ~]# rm /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-157e97b2-aec8-4e6b-8181-0022427e92e2 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-aa2878cb-288c-4ac9-b1ec-5a328f22a6f5 /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-b534b5dd-9480-4336-bf17-81a4308dfb6f /var/lib/libvirt/images/alpinelinux3.8.qcow2-vProtect-f05555c7-a881-4b18-b5b2-f4a84eba71c6


Filter by label

There are no items with the selected labels at this time.