There are a set of parameters determines disk quota in OpenVZ. The
OpenVZ disk quota is realized on two levels:the per-VPS level and the
per-user/group level. You can turn on/off disk quota on any level and
configure its settings.
The main parameters are DISK_QUOTA, DISKSPACE,DISKINODES, QUOTATIME,QUOTAUGIDLIMIT.
DISK_QUOTA : Indicates whether first-level quotas are on or off for all
VPSs or for a separate VPS.If is defined in the global configuration
file (GF).
# grep DISK_QUOTA /etc/sysconfig/vz
DISK_QUOTA=yes
DISKSPACE : Total size of disk space the VPS may consume, in 1-Kb blocks.It is defined in the separate configuration file(SF).
# grep DISKSPACE /etc/sysconfig/vz-scripts/101.conf
DISKSPACE="2000000:2200000"
DISKINODES : Total number of disk inodes (files, directories, and
symbolic links) the Virtual Private Server can allocate.It is defined
in the separate configuration file(SF).
# grep DISKINODES /etc/sysconfig/vz-scripts/101.conf
DISKINODES="200000:220000"
QUOTATIME
: The grace period for the disk quota overusage defined in seconds. The
Virtual Private Server is allowed to temporarily exceed its quota soft
limits for no more than the QUOTATIME period.It is defined in SF.
# grep QUOTATIME /etc/sysconfig/vz-scripts/101.conf
QUOTATIME="0"
QUOTAUGIDLIMIT
: Number of user/group IDs allowed for the VPS internal disk quota. If
set to 0, the UID/GID quota will not be enabled.It is defined in SF.
Turning on/off per vps disk quota:Now to turning on per vps disk quota do the following.
Edit the separate configuration file
# vi /etc/sysconfig/vz-scripts/101.conf
Add the following,
DISK_QUOTA=yes
If you set the above value to "no". The quota will be off.
# vzctl restart 101
# vzctl exec 101 df -h
Set up per vps disk quota:Now to set up per vps disk quota(eg : for a nod 102) we need to set up the following parameters DISKSPACE ,DISKINODES ,QUOTATIME
# vzctl set 102 --diskspace 1000000:1100000 --save
# vzctl set 102 --diskinodes 90000:91000 --save
# vzctl set 102 --quotatime 600 --save
# vzctl restart 102
# vzctl exec 102 df -h
Turning On/Off Second-Level Quotas for Virtual Private Server:The
parameter that controls the second-level disk quotas is QUOTAUGIDLIMIT
in the VPS configuration file. By default, the value of this parameter
is zero and this corresponds to disabled per-user/group quotas.
Enabling per-user/group quotas for a Virtual Private Server
requires restarting the VPS. The value for it should be carefully
chosen; the bigger value you set, the bigger kernel memory overhead
this Virtual Private Server creates. This value must be greater than or
equal to the number of entries in the VPS /etc/passwd and /etc/group
files.
# cat /etc/passwd|wc -l
55
# cat /etc/group|wc -l
66
# vzctl set 102 --quotaugidlimit 100 --save
# vzctl restart 102
Setting Up Second-Level Disk Quota Parameters:first to check the required packages are there in the vps.
# vzctl exec 102 rpm -q quota
Then ssh to the node 102
Now to edit the quota for the root do the following,
# edquota root
To report the quota do the folowing,
# repquota -a
This command gives the following output in my test vps.
# repquota -a
*** Report for user quotas on device /dev/simfs
Block grace time: 00:00; Inode grace time: 00:00
Block limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 455028 0 0 19878 0 0
smmsp -- 8 0 0 2 0 0
named -- 40 0 0 10 0 0
apache -- 8 0 0 2 0 0
rpm -- 9472 0 0 75 0 0
mysql -- 1332 0 0 163 0 0
To check the quota stats do the following operation in the host server.
# vzquota stat 102 -t