Thursday , 19 September 2019
Latest topics!!

[Solved] Container already locked – OpenVZ

As we know, OpenVZ is a container-based virtualization for Linux. OpenVZ creates multiple secure, isolated Linux containers (otherwise known as VEs or VPSs) on a single physical server enabling better server utilization and ensuring that applications do not conflict. Each container performs and executes exactly like a stand-alone server; a container can be rebooted independently and have root access, users, IP addresses, memory, processes, files, applications, system libraries and configuration files.

You will sometimes face an issue like receiving the following message while trying to start a VPS in an OpenVZ node. Error details pasted below:

Container already locked

Check the below examples I have mentioned, you will receive a message like Container already locked and unable to start as shown below:

[root@twinnode ~]# vzctl start 528
Locked by: pid 10259, cmdline /usr/sbin/vzctl start 528
Container already locked

In normal cases the container will start when we remove the “.lck” file “/vz/lock/528.lck”, replace 528 with the container ID which you are facing this issue.

[root@twinnode ~]# rm /vz/lock/528.lck
rm: remove regular file `/vz/lock/528.lck'? y

Then kill with a check point as below(replace 528 with the container ID which you are facing this issue):

[root@twinnode ~]# vzctl chkpnt 528 --kill
Container is not running

Even after doing this when you try to start the container, you may receive a quota related error ((error) can’t lock quota file, some quota operations are performing for id 528) as shown below:

[root@twinnode ~]# vzctl start 528
Starting container...
vzquota : (error) can't lock quota file, some quota operations are performing for id 528
vzquota on failed [7]

Form the error message, it is clear that some vzquota operation is already runnning, there by we have to find the process associated with the quota check and kill it as shown below:

Find the process using the command “ps aux | grep vzquota”

[root@twinnode ~]# ps aux | grep vzquota
root       10336  0.1  0.0   4424  1228 ?        D    Feb08   0:08 /usr/sbin/vzquota on 528 -b 157286500 -B 157286500 -i 78643300 -I 78643300 -e 0 -n 0 -s 1 -u 1000
root      159922  0.0  0.0  61236   772 pts/1    S+   01:21   0:00 grep vzquota

Here the process ID is 10336, replace it with the process ID you received in the above step. then run the command “kill -9 ” as shown below:

[root@twinnode ~]# kill -9 10336

Next step is to turn off the Quota for the container:

[root@twinnode ~]# vzquota off 528
vzquota : (error) Quota is not running for id 528
vzquota : (warning) Repairing quota: it was incorrectly marked as running for id 528

Then start the OpenVZ container using the command “vzctl start:

[root@twinnode5 ~]# vzctl start  528
Starting container...
Container is mounted


About Harikrishnan M

Working as Senior System Administrator at Twinbeeservers.

Leave a Reply

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