In this article, we will check the way to unlock a container in OpenVZ
OpenVZ
OpenVZ is an operating system-level virtualization technology for Linux. It allows Multiple isolated OS instances, called containers/Virtual Private Servers(VPS)/Virtual Environments(VE) to run on one physical server.
Action Scripts
There could be some situations once you need to perform additional actions when a container is started/stopped. You need OpenVZ action scripts to perform these additional operations to manage a particular container. Action scripts are located in the /vz/private/CTID/scripts/ and /etc/vz/conf directories. There are both global and user-defined scripts for containers. The worldwide action scripts can be executed for all containers and user-defined action scripts are often only un a selected container identified by the container id(CTID). The vzctl has the capability to execute user-defined scripts when a selected vzctl command is run in a container. The vzctl command can execute action scripts like start, stop, restart, mount, and unmount.
syntax
—vzctl [flags] CTID –parameter value[…]
Example
1) To start out a container
—vzctl start CTID [–wait] [–force]
2) To prevent a container
—vzctl stop CTID [–FAST]
3) To restart a container
—vzctl restart CTID [–fast] [–skip-unmount]
4) To understand the present status of a container
—vzctl status CTID
where, start, stop, restart, status is the action script and the CTID is the Container ID.
Locked Container
The OpenVZ container fails to start out and becomes unresponsive sometimes if the action scripts don’t work properly. Sometimes the container will get stuck or unresponsive when time-consuming processes like automated or manual virtuozo backups. At this stage, the container will be unresponsive and is mentioned to be in a locked stage. While starting the OpenVZ container you’ll get an error like this
—[root@server ~]# vzctl stop CTID
—Container already locked
You won’t be ready to start, stop, restart or run any action scripts on the container at this stage.
Solution
Kill the method
If multiple failed attempts are made to start out or restart the container, then every such event will have a separate process id(PID). You want to remove all those pid and also the lock file. The pid can be found out by running the below command.
—ps aux | grep /usr/sbin/vzctl start CTID
—ps aux | grep /usr/sbin/vzctl restart CTID
You can kill the method by killing all those pid found from the above command. Run this command to kill every founded pid.
—kill -9 pid
Delete the lock file
The lock file contains no data and exists as an empty marker file. It contains properties and settings for the lock. The lock file signals the applications that a resource shouldn’t be used until the lock is released. The default location of the lock file is
—/vz/lock/CTID.lck
To release the resources and free the container from the lock, this file must be deleted. Each container has its own specific lock file. To delete the lock file use the command given below.
—[root@server ~]# rm /vz/lock/CTID.lck
—rm : remove regular file ‘/vz/lock/CTID.lck’? y
Kill the checkpoint
Finally kill the checkpoint of the container to unlock and free the resources. The parameter –kill is used to kill the container checkpoint.
—[root@server ~]# vzctl chkpnt CTID –kill
—Killing…
The container isn’t running
Start the container
Once you’ve run all of them, you’ll re-run your container using vzctl start/restart/stop command.
If you would like any longer help please contact our support department.
- 0 Users Found This Useful