VMFS Recovery™
Recover data from damaged or formatted VMFS disks or VMDK files
Recover data from damaged or formatted VMFS disks or VMDK files
Last updated: Nov 19, 2024

Unlocking a Locked VM in Proxmox: A Complete Guide

Your Proxmox VM could get locked after taking a snapshot, cloning, or backup. When this happens, you will get any of these error responses:

  • “Error: VM is Locked (Backup)”
  • “Error: VM is Locked (Snapshot)”
  • “Error: VM is Locked (Clone)”

From the error, you can clearly see the cause of the VM lock, so you can know how best to tackle the situation. Apparently, as the VM is locked, there’s almost nothing you can access on the machine, and you can’t make edits either. So, you would have to unlock the VM to continue using it; unlocking a locked Proxmox VM isn’t that technical, and in this post, we will explain the different ways to go about it.

Understanding the Locked VM Issue in Proxmox

What Causes a VM to Get Locked?

VMs get locked due to quite different reasons, most times, as a “safe mode” to prevent a stipulated damage scenario, or probably because there’s an ongoing activity such as backup processing, cloning, or snapshot.

  • Pending or Ongoing Operations: If a Proxmox VM is undergoing a backup, snapshot creation, or migration, Proxmox locks the VM to avoid conflicts.
  • Failed Operations: Similarly, in cases where a task such as a backup or migration fails, the VM might remain locked – as the process is yet to complete successfully.
  • Manual Locking: Administrators may manually lock a VM to enforce restricted access to the VM files and prevent random changes during crucial maintenance schedules.
  • System Crashes or Power Failures: Unexpected shutdowns or crashes during any operation can lock a VM to trigger a safe mode.

So to say, if a backup process, snapshot creation or deletion, or VM migration task is interrupted, Proxmox may keep the VM locked until you manually unlock it.

Common Scenarios Leading to a Locked VM

Here are common scenarios that can lead to a locked virtual machine (VM) in Proxmox:

1. Snapshot Creation or Deletion in Progress

When creating or deleting a snapshot, Proxmox locks the VM to prevent conflicts. This can result in the VM being locked until the snapshot operation completes.

2. Backup Operations

Proxmox locks VMs during backup processes to ensure data consistency. If a backup fails or is interrupted, the VM might remain in a locked state.

3. Migration Tasks

VM migration between nodes can cause the VM to lock temporarily. If the migration encounters issues or fails, the lock may persist.

4. Disk I/O Problems

If there are disk or storage issues (e.g., a slow or unresponsive storage backend), VMs can lock to prevent data corruption or inconsistencies.

5. Manual Locking

Proxmox administrators may lock VMs manually to prevent unintended changes or interactions, such as during maintenance or troubleshooting.

6. Stuck Tasks

If a task (backup, migration, or snapshot) gets stuck or doesn't properly terminate, the VM may remain locked. Restarting the task or manually clearing the lock is often required.

7. Corrupted Configuration

Configuration file corruption or errors can also lead to a VM being locked. This might happen if the configuration was altered improperly or during a failed operation.

8. Hardware Failures

Underlying hardware issues, such as failed storage or network devices, can lock VMs to prevent further damage or loss of data.

How to Identify a Locked VM in Proxmox

Signs and Symptoms of a Locked VM

A locked Proxmox VM would prevent you from carrying out any operations on the machine and would print an error message when you try to perform advanced actions. In essence, a locked VM in Proxmox would exhibit the following signs:

  • Inability to start or stop
  • Print task/operation failure notifications
  • Display a VM is Locked error message, or appear as locked under its properties on the status page.

Checking VM Status in Proxmox

You can confirm the status of a Proxmox VM via the web interface or using PowerCLI commands, whichever is convenient for you.

Using the Web Interface:

  • On the VMs page, look out for the VM you want to check its status
  • Navigate to the Summary tab and check what’s written in the “Status” section. If the VM is locked, it’ll be indicated here.

Using the Command Line:

  • Access your Proxmox host via SSH and run the following command: `qm list`
  • Find the “lock” column, and if it shows a value (e.g., “backup,” “snapshot,” or “migrate”), the VM is locked.

Steps to Unlock a Locked VM in Proxmox

There are only two known ways to unlock a locked Proxmox VM; either you use command line instructions or the web interface.

Unlocking a Proxmox VM via Web Interface

You will have to log in to your Proxmox host web interface and access the VM from the left pane.

  • Check for running tasks on the VM and kill them
  • Restart Proxmox services and check the status of your VM again, then try accessing the VM files to see if truly the machine has been unlocked.

Unlocking a VM via Command Line

This happens to be the commonest and preferred method for most people, although it requires good knowledge of PowerCLI cmdlets.

  • First, you have to list the VMs in your environment to get the ID of the locked one: cat /etc/pve/.vmlist
  • Now, unlock or kill the VM: qm unlock
    • Where should be replaced with the actual ID of the VM you wish to unlock.
  • Wait for the command to run. There are cases where this won’t unlock the VM, and as such, you have to manually remove the lock.

Unlocking a Proxmox VM Manually

It is recommended to use this manual method if you get an error during the command line unlock process. Usually, if the command line doesn’t work, you will get the error: “can't lock file '/var/lock/qemu-server/lock-.conf' - got timeout.” Here’s how to do the manual unlocking – it’s still a cmdlet action:

  • Run the following command: rm /var/lock/qemu-server/lock-VMID.conf

Verifying the Unlock Status

To verify the unlock status of a virtual machine (VM) in Proxmox, you can use both the Proxmox Web GUI and the command line interface (CLI). Here's how to do it:

1. Using the Proxmox Web GUI

  • Step 1: Log in to the Proxmox Web UI.
  • Step 2: Navigate to the Datacenter tab and select the node where your VM is located.
  • Step 3: Expand the node and click on the VM that you suspect is locked.
  • Step 4: In the VM's summary page, check for any indication that the VM is locked. Typically, the lock status will be shown next to the VM state (such as "locked" or "running").
  • Step 5: If the VM is locked, Proxmox will display the type of lock (e.g., backup, snapshot, or migrate) in the VM summary.

2. Using the Command Line Interface (CLI)

If you're more comfortable using the terminal, or if you need more detailed information, you can check the lock status using the Proxmox CLI.

  • Step 1: Access the Proxmox node via SSH or use the local terminal.
  • Step 2: Run the following command to check if a VM is locked:
qm list

This will list all the VMs and their statuses. If the VM is locked, it will be indicated in the output.

  • Step 3: Alternatively, you can check the specific VM’s configuration for a lock by using the following command:
qm config

Replace with the actual ID of your VM. Look for the lock parameter in the output. If the VM is locked, the lock type will be listed here (e.g., lock: backup).

3. Unlocking a Locked VM

If the VM is locked and you want to unlock it, you can manually unlock it using the CLI:

  • Step 1: To clear the lock, run the following command:
qm unlock

Replace with the ID of the VM that is locked. This will remove the lock from the VM.

Tip: VMware ESXi vs Proxmox

Preventing VM Lock Issues in Proxmox

Best Practices for VM Management

1) Plan and Schedule Maintenance Operations

  • Schedule backups, migrations, and snapshot tasks during off-peak hours to minimize the risk of disruptions.
  • Ensure that the underlying storage infrastructure can handle the load before initiating large-scale operations like mass backups or migrations.

2) Avoid Simultaneous Operations on the Same VM

  • Do not initiate multiple operations (e.g., backup, migration, or snapshot creation) on the same VM at the same time, as this can cause conflicting locks and potential issues.

3) Use Proper Storage Solutions

  • Ensure that the storage backends used for VMs are fast, reliable, and well-configured to prevent bottlenecks that might lead to VMs locking during I/O-intensive operations.

4) Ensure Consistent Backups

  • Regular backups are critical, but ensure that they do not overlap or conflict with other tasks. Use Proxmox’s backup schedule feature to automate and space out backups efficiently.

5) Proper Resource Allocation

  • Allocate adequate CPU, memory, and storage resources to VMs to prevent situations where resource exhaustion could trigger lock issues during operations like migration or snapshot creation.

6) Manual Locking for Maintenance

  • Manually lock VMs when performing critical maintenance tasks to prevent unintended interactions. Remember to unlock the VMs when the maintenance is completed.

7) Avoid Configuration File Corruption

  • Always make changes to VM configurations through the Proxmox Web GUI or CLI to avoid manual errors that could lead to a locked VM due to corrupted configurations.

Regular Monitoring and Maintenance Tips

  • Monitor Task Status: Regularly check ongoing tasks (backups, snapshots, migrations) using the Proxmox Web GUI or CLI (qm list or pve tasks) to ensure there are no failed or hanging processes that may cause locks.
  • Regularly Check Storage Performance: Monitor storage I/O performance to ensure that bottlenecks or failures do not lead to locked VMs. Use tools like iostat or Proxmox’s built-in storage monitoring to detect slowdowns or issues early.
  • Monitor System Logs: Check system logs (journalctl or /var/log/syslog) for signs of hardware issues, storage problems, or other anomalies that may cause a VM to become locked.
  • Set Up Alerts and Notifications: Configure Proxmox to send alerts for critical system events, such as failed backups or snapshot operations, to allow for prompt intervention if a VM becomes locked.
  • Update and Patch Proxmox Regularly: Ensure Proxmox and its related components (e.g., QEMU, storage backends) are up to date to benefit from stability and performance improvements, which can help prevent lock issues.

Ready to get your data back?

To start VMware data recovery, press the FREE DOWNLOAD button below to get the latest version of DiskInternals VMFS Recovery® and begin the step-by-step recovery process. You can preview all recovered files absolutely for FREE. To check the current prices, please press the Get Prices button. If you need any assistance, please feel free to contact Technical Support. The team is here to help you get your data back!

Troubleshooting Persistent Lock Issues

When the Standard Unlock Methods Fail

1. Verify Active Tasks

  • Check if there are any ongoing tasks related to the locked VM that might be causing the lock. Use the following command to list the active tasks:
pve tasks
  • Identify if the task related to the VM is stuck or incomplete, and attempt to cancel or terminate it if necessary.

2. Force Stop the VM

  • If a VM remains locked after a failed operation and the standard unlock (qm unlock ) doesn’t work, forcefully stopping the VM may help. Use the following command to force stop the VM:
qm stop --force
  • Replace with the actual ID of the VM. After stopping the VM, try unlocking it again using the qm unlock command.

3. Manual Lock Removal

If the VM remains locked due to a configuration file issue, you can manually edit the VM's configuration file to remove the lock entry. Follow these steps:

  • Navigate to the VM’s configuration directory:
    cd /etc/pve/qemu-server/
    • Open the VM’s configuration file (named .conf) and look for a line that starts with lock:.
    • Remove the lock: line and save the file.

    4. Check for Storage or Resource Issues

    • Locked VMs might be the result of storage I/O issues or hardware resource shortages. Check the storage performance and node health to ensure that the environment is stable. You can also inspect the logs for any I/O errors or failures:
    journalctl -f
    • Address any issues before trying to unlock the VM again.

    Advanced Troubleshooting Techniques

    1. Check Task Logs

    • Examine detailed task logs for any failed operations related to the locked VM. Use the Proxmox GUI to navigate to Datacenter > Task History, or use the CLI:
    pve tasks --vmid
    • Review the logs for any clues as to why the VM is locked and proceed accordingly.

    2. Inspect System and VM-Specific Logs

    • Check the Proxmox system logs and VM-specific logs for any underlying issues (e.g., hardware problems, disk errors, or migration failures):
    tail -f /var/log/syslog

    or

    qm showcmd

    This can give more insight into processes that are blocking the VM from being unlocked.

    3. Force Unlock via API

    • Proxmox provides an API that can be used for advanced troubleshooting. You can use API tools like curl to interact with the Proxmox API and clear a lock:
    curl -k -X POST "https://:8006/api2/json/nodes//qemu//status/unlock" -b "PVEAuthCookie="
    • Ensure that you authenticate first, and replace the and with your actual node and VM details.

    4. Reboot the Host

    • As a last resort, if the VM remains locked and none of the above methods work, a reboot of the Proxmox host may clear lingering locks. This approach should be used cautiously, especially in production environments, as it affects all running VMs on the host.
    Note: Proxmox vs VMware

    Conclusion

    What more? Unlocking VMs in Proxmox can be a very simple task, but in some cases, it may be a hard nut to crack. Always find out the cause of the lock before attempting to unlock it. Ignore using the PowerCLI if you’re not familiar with cmdlets and the command line interface. If you tried and still your VM won’t unlock, contact Proxmox support.

Related articles

FREE DOWNLOADVer 4.23, WinBUY NOWFrom $699

Please rate this article.
51 reviews