
OS X: configure disk quotas for local users

Introduction
The HFS + file system (FS) on OS X supports quoting users and groups by ID at the volume level. The corresponding .quota.user and .quota.group files are located in the root directory. Each of them contains a header, followed by a hash table with the definition of limits, as well as the consumed values on the user or group ID.Turn on disk quotas
In order to enable quotas support in the root directory, you need to create a .quota.ops.user or .quota.ops.group file .- We get root privileges in the terminal:
sudo su
- Create an empty options file:
touch /.quota.ops.user
- After that, it will become possible to run the command:
repquoata -a
and measure the current disk consumption by users by name. If the command does not start, type:checkquota -a
To filter service users, you can use grep:repquota -a | grep -v -E "^ \ _"
- We enable quotas with the quotaon command (you can turn them off using quotaoff ):
quotaon /
The parameter points to a mounted file system point. In this example, there is only one root partition on the computer. If it is necessary to set quotas for several volumes, repeat the command for each of the mounted FS.
We set consumption limits
Quotas are set; we will set consumption limits for our users. We will configure quotas using the example of the blondie user. Custom quotas can be edited using the edquota command . A full description of the options can be found in man edquota, but we will use the -u (user) switch:edquota -u blondieThe vi editor will open for editing (a paste; ESC,: wq, ENTER save and exit). In our example, the result looks like this:
Quotas for user blondie: /: 1K blocks in use: 85963652, limits (soft = 0, hard = 0) inodes in use: 35294, limits (soft = 0, hard = 0)Limits can be set in hard and soft modes. Hard limit cannot be bypassed. As soon as the user reaches the limit, he receives a message about the inaccessibility of disk space. Soft limit can be bypassed for a while. Users are allowed to exceed their “soft” limit for the grace period. As soon as this time comes to an end, the “soft” limit is replaced by “hard”. You can use the edquota -t command to change the grace period . By default, in OS X, this period is one week.
Let's set our user 100G (hard) and 30G (soft) limits on disk space without restrictions on the number of files:
Quotas for user blondie: /: 1K blocks in use: 85963652, limits (soft = 31457280, hard = 104857600) inodes in use: 35294, limits (soft = 0, hard = 0)