Proxmox delete lvm snapshots on VM delete

EuroDomenii

Renowned Member
Sep 30, 2016
145
35
68
Slatina
www.domenii.eu
Usually, all the lvm snapshots for a VM are removed on VM deletion. But, during some benchmarks, I needed to create more than 100 snapshots for a VM. This time, all the snapshots remained intact, despite deletion of the VM ( this is valid for several VMs).

Code:
root@melania:/etc/pve/qemu-server# lvdisplay | grep Path | grep snap | wc -l
175

Code:
lvmthin: local-lvm
        thinpool vmstore
        vgname vmdata
        content rootdir,images

Code:
root@melania:/etc/pve/qemu-server# pveversion
pve-manager/6.2-12/b287dd27 (running kernel: 5.4.65-1-pve)
root@melania:/etc/pve/qemu-server# dpkg -l | grep lvm
ii  libllvm7:amd64                       1:7.0.1-8+deb10u2                 amd64        Modular compiler and toolchain technologies, runtime library
ii  liblvm2cmd2.03:amd64                 2.03.02-pve4                      amd64        LVM2 command library
ii  lvm2                                 2.03.02-pve4                      amd64        Linux Logical Volume Manager

Thanks!
 
  • Like
Reactions: Dominic
Hey,

do you get any warning/error messages from the destroy task?
 
This is how I've done the snapshots, during a https://www.phoronix-test-suite.com/

Code:
root@melania:/var/eurodomenii/scripts# cat snapshot_bench.sh
#https://superuser.com/questions/264528/problem-with-random-in-crontab
Number=$(bash -c 'echo $RANDOM')
qm snapshot $1 "snap-$Number" > /dev/null 2>&1

Code:
root@melania:/var/eurodomenii/scripts# cat /etc/crontab
*/15 * * * *      root    /var/eurodomenii/scripts/snapshot_bench.sh 404
 
The problem is the - in the snapshot name, the GUI prevents the usage of - in the snapshot name, the CLI however doesn't (the CLI should also check that, and that will probably added). Removing the - from the snapshot name should resolve the problem, the snapshots already created have to be deleted manually.
You can use lvremove -S as described in https://man7.org/linux/man-pages/man8/lvremove.8.html.
 
The patch is now applied in our git, so you should have the fix as soon as the package libpve-storage-perl 6.2-11 is out.