Dino Geek, try to help you

How to implement a hard disk quota policy in an OpenVZ container?


A Hard disk quota policy sets a limit on the amount of disk space that can be used by each OpenVZ container. This prevents any single container from using up too much disk space and reducing the performance of the other containers on the same physical server.

Here are the steps you can follow to set up a hard disk quota for each OpenVZ container:

OpenVZ uses two types of quotas: per container and per user/group. We will show how to enable per container quota:

1. Initial setup: OpenVz kernel does not support quotactl system call directly. Therefore you should use `simfs` file system for quota support.

Check whether second level quotas are enabled:

``` $ cat /proc/user_beancounters
```

Look for the `dq` parameters:

``` uid resource held maxheld barrier limit failcnt 100: kmemsize 2483055 2755622 27525120 28049408 1054 lockedpages 0 0 600 700 0 privvmpages 113123 125505 131072 137216 200 shmpages 88 88 21504 21504 0 dummy 0 0 0 0 0 numproc 28 32 65 65 0 physpages 42374 46199 0 2147483647 0 vmguarpages 0 0 33792 2147483647 0 oomguarpages 42374 46199 26112 2147483647 0 numtcpsock 5 7 80 80 0 numflock 11 14 188 206 0 numpty 1 1 16 16 0 numsiginfo 0 1 256 256 0 tcpsndbuf 5568 7576 1720320 2703360 0 tcprcvbuf 0 4386 172032 2703360 3 othersockbuf 43784 46252 112608 277488 0 dgramrcvbuf 0 4384 65536 65536 3 numothersock 26 31 120 120 0 dcachesize 48027 54018 340992 362496 1033 numfile 545 608 9312 9312 0 dummy 0 0 0 0 0 dummy 0 0 0 0 0 dummy 0 0 0 0 0 numiptent 128 128 128 128 0 diskspace 220M 220M 220M 231M 0 diskinodes 29086 29088 600000 610000 0
```

If you see non-zero values in the barrier/limit columns on these lines, it means 2nd level quotas are enabled. If not, you should start from this point

1. Configure second level quota support: Edit `/etc/sysconfig/vz`:

``` DISK_QUOTA=yes QUOTAUGIDLIMIT=500
``` Default quotaugidlimit value is 0. You should change it to some non-zero value to enable per-user/group quotas inside container. This limit denotes max number of different user/group ids which may own files inside the container.

1. Restart OpenVZ service:
``` $ service vz restart
```

1. Set diskspace for container: To enable limit for container with id CTID use following:

``` $ vzctl set CTID —diskspace 10G:11G —save
```

In this example, soft limit is set to 10G and hard limit is set to 11G. When the used disk space reaches the soft limit, the operating system will start to warn the user, but it will not prevent the user from storing more data until the hard limit is reached. When the hard limit is reached, the user will not be able to store any more data.

This will limit the usage of the hard disk by the container. The changes will be saved in the configuration file and will be used when the container is restarted.

1. Restart container:

Updating the diskspace does not take effect immediately. It requires a container restart.

``` $ vzctl restart CTID
```

1. Check quota status: Once quota is enabled, you can check it with below command,

``` $ vzquota stat CTID
```

Remember, in order for quota to work, the host system kernel must support it. If the host system kernel does not support quota, the vzquota utility will fail with a corresponding error message. So, make sure your Kernel supports Quota.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use