
Introduction
The file system (FS) HFS + 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 consumed values ​​for the user ID or group ID.
Turn on disk quotas
In order to enable quota support in the root directory, you need to create a
.quota.ops.user or
.quota.ops.group file .
- We get in the root terminal privileges:
sudo su
- Create an empty options file:
touch /.quota.ops.user
- After that, it will be possible to run the command:
repquoata -a
and evaluate the current consumption of the disk by users. If the command does not start, type: checkquota -a
To filter service users, you can use the grep: repquota -a | grep -v -E "^ \ _"
- Turn on quoting with the quotaon command (you can turn it back off using quotaoff ):
quotaon /
The parameter indicates the point of the mounted file system. In this example, there is only one root partition on the computer. In case it is necessary to establish quotas for several volumes, repeat the command for each of the mounted FSs.
From this point on, disk quotas are turned on and it is time to start setting up limit rules.
Set consumption limits
Quotas are configured, set consumption limits for our users. Adjustment of quotas will make on the example of the user "blondie". You can
edit user quotas using the
edquota command . A full description of the options can be found in man edquota, but we will use the -u (user) option:
edquota -u blondie
To edit, open the vi editor (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 the “hard” and “soft” modes. "Hard" limit can not be circumvented. As soon as the user reaches the limit of 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 with “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)
Mistress note
Inodes (inodes) are files in the file system. Each file gets its inode (including symbolic links).
Tricks
The established limit on the number of files used is easily circumvented using disk images (DMG). A disk image occupies only one inode on the file system, no matter how many files it contains or to what size it grows. File limit m. useful for service users so that any daemon does not accidentally block the file system with logs or core dumps.
useful links
- HFS + Disk Quotas / www.secure-computing.net
- Creating and using disk quotas / hints.macworld.com