How to delete a snapshot while VM running with snapshot_delete_blkdev_internal?

rojoblandino

New Member
Sep 11, 2019
23
4
3
36
I have read some other threads that explain about how to find the snapshot of the qcow2 disk file and how to delete them, but none of them says if it is possible to do it while VM is running.

I have a VM with snapshot on the qcow2 disk, i can see them with qemu-img snapshot -l <path-to-file.qcow2>

I can not shutdown the VM because is a dedicate Database but after a failed snapshot the client deleted the snapshot from the config file but it is still on the qcow2 disk files.

I have not found information about using "snapshot_delete_blkdev_internal device name [id]"

device?
name?
id?

If I have for example the following snapshot:

Code:
# qemu-img info /tmp/usb/vm-100-disk-1.qcow2
image: /tmp/usb/vm-100-disk-1.qcow2
file format: qcow2
virtual size: 1 TiB (1099511627776 bytes)
disk size: 1.42 TiB
cluster_size: 65536
Snapshot list:
ID        TAG               VM SIZE                DATE     VM CLOCK     ICOUNT
1         snapshot1_A          0 B 2021-04-06 10:48:47809:06:54.109          
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false

How is the sintaxis for "snapshot_delete_blkdev_internal"?

I am using: pve-manager/6.3-4/0a38c56f (running kernel: 5.4.78-2-pve)

Thanks.
 
Last edited:

rojoblandino

New Member
Sep 11, 2019
23
4
3
36
What i have found.

Running "info block" i get the block device name:

Code:
# info block
drive-ide2 (#block125): /dev/cdrom (raw, read-only)
    Attached to:      ide2
    Removable device: locked, tray closed
    Cache mode:       writeback

drive-scsi0 (#block395): /var/lib/vz/images/111/vm-111-disk-0.qcow2 (qcow2)
    Attached to:      scsi0
    Cache mode:       writeback, direct
    Detect zeroe

Then running "info snapshots" i get the snapshot TAG:

Code:
# info snapshots
List of snapshots present on all disks:
ID        TAG                     VM SIZE                DATE       VM CLOCK
--        vaslatin1_sA                0 B 2021-05-03 15:08:43   00:02:41.171

Then running

Code:
snapshot_delete_blkdev_internal "drive-scsi0" "snapshot1_A"

It was runned on a develop enviroment, my question is, can it be runned on a running VM's safetly?
 
Last edited:

Fabian_E

Proxmox Staff Member
Staff member
Aug 1, 2019
928
122
43
Hi,
I don't think there should be any problem running this. PVE itself uses the same command, just via the QMP instead of the HMP. If the RAM was included in the snapshot, there should also be a state volume on the same storage (or your VM state storage if configured) and you probably want to remove that as well. And you should fix/remove the parent setting in the configuration file if not already done so.

That said, it's never a bad idea to have a working backup around.
 

rojoblandino

New Member
Sep 11, 2019
23
4
3
36
Hi,
I don't think there should be any problem running this. PVE itself uses the same command, just via the QMP instead of the HMP. If the RAM was included in the snapshot, there should also be a state volume on the same storage (or your VM state storage if configured) and you probably want to remove that as well. And you should fix/remove the parent setting in the configuration file if not already done so.

That said, it's never a bad idea to have a working backup around.
I have run the command but i have got following message:

VM 100 qmp command 'human-monitor-command' failed - unable to connect to VM 100 qmp socket

Now i do not see the snapshot but on the image info i see following data:


Code:
image: /var/lib/vz/images/100/vm-100-disk-1.qcow2
file format: qcow2
virtual size: 1 TiB (1099511627776 bytes)
disk size: 1.43 TiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false
 

Fabian_E

Proxmox Staff Member
Staff member
Aug 1, 2019
928
122
43
Not sure why the error message appeared, but it seems to have worked. If you're concerned about the size, see here (if trimming is not enough, you might need to use the qemu-img convert approach).
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!