21 Nov 2018

OpenVz useful commands

Here is the list of some useful OpenVz commands which should be run from the main node :

1. To fetch the consumption of disk for each container in the node along its it’s hostname and cid

vzlist -H -o veid,hostname,diskspace | awk ‘{ printf(“%d\t%s\t%.2f GB\n”, $1, $2, $3/(1024*1024))}’

 

2. To find the load average of each container on the node. Pretty useful command to find the culprit.

vzlist -o ctid,laverage,hostname

 

3. Using ploop containers? Use this command to free up some space.

vzctl compact [ctid]

 

4. Change the number of cpu allocated to a container by the following command

vzctl set [cid] –cpus 4 –save

 

5. Command to modify the disk space allocated to a container

vzctl set [cid] –diskspace 480G:500G –save

 

6. Vctl Command to change password of a container (including root user)

vzctl set [ctid] –userpasswd [username]:[password]