From http://hints.macworld.com/article.php?story=20030808130810285:
The following notes are reproduced from the original article called Quota support on Mac OS X for better visibility. Some formatting has been lost from the original.
[robg adds: The author of the original document has released the document into the public domain, and disavowed any copyright claims, so the full text of the page has been recreated in the remainder of this hint, just in case the original goes away. So you can either read the rest of this hint, or just click the above link for the original article. Note that the page references a hint here which describes an easier way of accomplishing the same objective.]
Introduction
There exist a variety of quota systems for unix-like operating systems designed to record disk usage on a per-user (and per-group) basis, and optionally impose disk usage limits. Mac OS X version 10.2 ships with the Berkeley Software Distribution (BSD) quota system. These notes cover manual setup of quota support on a Mac OS X 10.2.6 system, along with uses of disk quotas. Those in a hurry should consider the following article: an easy method of creating disk quotas for users.
Setup
To obtain rough estimate of disk usage, use the quotacheck(8) command. Unfortunately, the manual is inconsistent, listing different mount option filenames in different sections.
-g Only group quotas are checked. The mount option file, .quota.opts.group, must exist at the root of the filesystem.-u Only user quotas are checked. The mount option file, .quota.opts.user, must exist at the root of the filesystem..quota.user data file containing user quotas.quota.group data file containing group quotas.quota.ops.user mount option file used to enable user quotas.quota.ops.group mount option file used to enable group quotasWhen the documentation is inaccurate, one solution is to record what the quotacheck command looks at when run, using the kernel tracing facility via the ktrace(1) command. The results of ktrace can be read from ktrace.out with the kdump(1) command.
$ sudo ktrace quotacheck -a$ sudo kdump -f ktrace.out | fgrep .quota7870 quotacheck NAMI "//.quota.ops.group"7870 quotacheck NAMI "//.quota.ops.user"7870 quotacheck NAMI "/Volumes/Spider/.quota.ops.group"7870 quotacheck NAMI "/Volumes/Spider/.quota.ops.user"The trace output shows quotacheck looking on the startup disk and an external firewire disk for the user and group quota setting files, .quota.ops.user and .quota.ops.group. These files must be created on each filesystem quota support will be enabled on, which can be done from the ktrace.out file with a bit of shell scripting.
$ sudo kdump -f ktrace.out | fgrep quota.ops |perl -nle 'print /"([^"]+)"/' | xargs sudo touch$ sudo rm ktrace.out$ ls /.quota* /Volumes/Spider/.quota*/.quota.ops.group /Volumes/Spider/.quota.ops.group/.quota.ops.user /Volumes/Spider/.quota.ops.userNow quotacheck can be run to provide rough disk usage on all currently mounted filesystems; the results of the run will be saved to the .quota.{user,group} index files.
$ sudo quotacheck -aquotacheck: creating quota file //.quota.userquotacheck: creating quota file //.quota.groupquotacheck: creating quota file /Volumes/Spider/.quota.userquotacheck: creating quota file /Volumes/Spider/.quota.groupOne way to view the resulting disk usage data is via the repquota(8) command.
$ sudo repquota -a -vWith empty .quota.ops.* quota configuration files, there should be no user or group disk space limitations. Current limitations can be viewed with the quota(1) command.
$ sudo quotaDisk quotas for user root (uid 0): noneTo enable automatic quota index updates without rebooting the system, use the quotaon(8) command. The quotaon manual indicates quota support will be automatically enabled at filesystem mount time for volumes with the proper .quota.*files.
$ sudo quotaon -a$ ls -lt /.quota.*-rw-r----- 1 root operator 131136 Aug 7 14:01 /.quota.group-rw-r----- 1 root operator 524352 Aug 7 14:01 /.quota.user-rw-r--r-- 1 root admin 0 Aug 6 19:45 /.quota.ops.group-rw-r--r-- 1 root admin 0 Aug 6 19:45 /.quota.ops.userSummary
To recap, disk usage tracking is enabled via the following steps.
Create .quota.ops.user and .quota.ops.group.
Create these empty files as root at the top level of the filesystem in question.
Run quotacheck -a.
The quotacheck command creates (or updates) the .quota.user and .quota.group index files recording current usage.
Run quotaon -a.
This command enables automatic tracking of disk usage for filesystems the above steps have been performed on.
Usage
One use of the quota index files is to record disk space usage over time. This allows reporting and capacity planning; for example, one may be able to predict when the current disk space will be consumed based on the average rate of usage increase. No limits on usage need be imposed, though limits to keep a single user from consuming all available space may be sensible to prevent other users or the system itself from experiencing problems.
The more traditional use of quotas has been to use the user and group options files to impose disk usage limits, and to script sending of warnings should usage get too close to the usage limit.
Recording Usage
To maintain historical logs of disk usage, the typical approach is to run repquota from cron(8), and to parse the resulting output into plaintext files, spreadsheet, or database. One tool of note is RRDTool, which can facilitate the generation of graphs on webpages, among other things.
The pquotarep script may help parsing the output of repquota into a format more suitable for conversion into other utilities.
$ sudo repquota -av | pquotarep | head -1fs=/ type=group blocks=6264 blocks-hard=0 blocks-soft=0 files=785 files-hard=0files-soft=0 name=500Imposing Limits
To impose limits, additional information on the totals for the filesystem in question can be obtained from the df(1) command. Both disk space usage and inode counts will need to be considered. The following commands show how to list that data for physical disk filesystems.
$ df -k | egrep '(^Filesystem|disk)'Filesystem 1K-blocks Used Avail Capacity Mounted on/dev/disk0s2 19533300 9578416 9759552 49% //dev/disk1s4 39064200 32956248 6107952 84% /Volumes/Spider$ df -i | egrep '(^Filesystem|disk)'Filesystem 512-blocks Used Avail Capacity iused ifree%iused Mounted on/dev/disk0s2 39066600 19156832 19519104 49% 2443435 243988850% //dev/disk1s4 78128400 65912496 12215904 84% 8239060 152698884% /Volumes/SpiderTo edit quota limits, use the edquota(8) command. This will launch vi(1) by default to edit the quota data, which will confound those of you not versed in unix editors. An alternative is to use " target=_blank>Webmin to setup and manage quotas.
$ sudo edquota $USERThe best way to test quotas is to create a new user account and subject it to various limits, rather than locking your main user account out or running the risk of preferences files being corrupted if hard limits are exceeded.
See Also:
http://hints.macworld.com/article.php?story=20090202064037457
https://secure-computing.net/wiki/index.php/HFS%2B_Disk_Quotas