Reese Knowledgebase

Cannot lock Container

View Kristian Reese's profile on LinkedIn

If you like this article, please +1 or Recommend via FB with the provided buttons above:

Article ID: 129
by: Reese K.
Posted: 23 Sep, 2013
Last updated: 23 Sep, 2013
Views: 3549

Cannot lock Container

If a container cannot be locked, and no lock file exists in /vz/lock, then check the private area of the container and look for an empty file named .lck.  If it's there, remove it and retry whatever action desired.

In this example below, I could not start the container.  I was always presented with an error "Cannot lock Container".  There wasn't an associated lock file in /vz/lock, so I began trying other things to clear the issue.

At first, I tried to unregister / register the container hoping that would clean any issues.

[root@vps09 ~]# vzctl start 18262
Cannot lock Container

[root@vps09 private]# vzctl unregister 18262
Container successfully unregistered

[root@vps09 private]# vzctl register /vz/private/18262 18262
Container successfully registered

When that didn't work, I tried to rename the container, or assign it a new CTID:

[root@vps09 private]# vzmlocal 18262:100
Moving/copying CT#18262 -> CT#100, [], [] ...
vzctl_conf_get_param(QUOTAUGIDLIMIT) return 150
can't lock CT#18262 : CT locked
Can't move/copy CT#18262 -> CT#100, [], [] : can't lock CT#18262 : CT locked

That also did not work so I decided to strace the process to see what was happening:

[root@vps09 private]# strace vzctl start 18262
stat("/vz/private/18262", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
statfs("/vz/private/18262", {f_type="NFS_SUPER_MAGIC", f_bsize=65536, f_blocks=16613376, f_bfree=4015923, f_bavail=4015923, f_files=31876689, f_ffree=21535839, f_fsid={0, 0}, f_namelen=255, f_frsize=65536}) = 0
stat("/vz/private/18262", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/vz/private/18262/.lck", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
open("/vz/private/18262/.lck", O_RDWR)  = 5
fcntl(5, F_GETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1, pid=0}) = 0
close(5)                                = 0
write(2, "Cannot lock Container\n", 22Cannot lock Container) = 22

After removing the empty .lck file, the container started:

[root@vps09 private]# file /vz/private/18262/.lck
/vz/private/18262/.lck: empty
[root@vps09 private]# rm /vz/private/18262/.lck
rm: remove regular empty file `/vz/private/18262/.lck'? y
[root@vps09 private]#
[root@vps09 private]#
[root@vps09 private]# vzctl start 18262
Starting Container ...
vzquota : (warning) Incorrect quota shutdown for id 18262, recalculating disk usage
Container mounted
Setup slm memory limit
Setup slm subgroup (default)
CPU limit: 400.0%
Setting devperms 20002 dev 0x7d00
Adding offline management to Container(1): 4643
Adding IP address(es): ip.ip.ip.ip
Hostname for Container set:
Container start in progress...
[root@vps09 private]#

This article was:   Helpful | Not Helpful
Prev   Next
Watch active MySQL queries as they come and go     perl