How unlock a VM in Proxmox

Background

When you can’t shutdown or reboot or even stop a VM in Proxmox it’s quite distressing. Surely it should just reboot when you press the button?

There is a reason why reboots or stops sometimes simply do not work with virtualization. In summary a VM is a file and to protect a file from corruption it’s locked. So when some abnormal condition occurs, or when you have a weird OS / virtualized hardware that doesn’t understand shutdown initialization commands, you have this specific problem.

Fortunately via Bob Cares and the command line we can now solve this problem. Or you could just wait 10 minutes, because that is the amount of time a reboot timeout will take before you can then just press stop. At that point, please don’t try reboot again. Use stop.

Continue if you want to force stuff. Not recommended but documented here anyway for the impatient.

By this time you’ve already noticed the UI doesn’t respond to any of the halt commands.

Let’s tackle this using the command line.

cat /etc/pve/.vmlist

Get the VMID. You can also get the VM ID via the UI, and then do this:

qm unlock <VMID>

Now in some circumstances this won’t work. Instead of it working, there will be more frustration and you might see this after a few seconds:

# qm unlock <VMID>
trying to acquire lock...
can't lock file '/var/lock/qemu-server/lock-<VMID>.conf' - got timeout

Do not fret. But first a reality check. Do you run the risk of forcibly closing an open file? If you are unsure, do not continue and phone a friend. For the brave soles who want to continue:

# ps aux | grep "/usr/bin/kvm -id <VMID>"

You’ll see a ton of text, so look carefully now.

kill -9 process_id

Reference

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top