Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Add quota support on Mac OS X UNIX

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.]


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.


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,, 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 data file containing group quotas
.quota.ops.user mount option file used to enable user quotas mount option file used to enable group quotas

When 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 .quota
7870 quotacheck NAMI "//"
7870 quotacheck NAMI "//.quota.ops.user"
7870 quotacheck NAMI "/Volumes/Spider/"
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 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*
/ /Volumes/Spider/
/.quota.ops.user /Volumes/Spider/.quota.ops.user

Now 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 -a
quotacheck: creating quota file //.quota.user
quotacheck: creating quota file //
quotacheck: creating quota file /Volumes/Spider/.quota.user
quotacheck: creating quota file /Volumes/Spider/

One way to view the resulting disk usage data is via the repquota(8) command.

$ sudo repquota -a -v

With 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 quota
Disk quotas for user root (uid 0): none

To 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 /
-rw-r----- 1 root operator 524352 Aug 7 14:01 /.quota.user
-rw-r--r-- 1 root admin 0 Aug 6 19:45 /
-rw-r--r-- 1 root admin 0 Aug 6 19:45 /.quota.ops.user


To recap, disk usage tracking is enabled via the following steps.

  1. Create .quota.ops.user and
  2. Create these empty files as root at the top level of the filesystem in question.

  3. Run quotacheck -a.
  4. The quotacheck command creates (or updates) the .quota.user and index files recording current usage.

  5. Run quotaon -a.
  6. This command enables automatic tracking of disk usage for filesystems the above steps have been performed on.


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 -1
fs=/ type=group blocks=6264 blocks-hard=0 blocks-soft=0 files=785 files-hard=0
files-soft=0 name=500

Imposing 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 2439888
50% /
/dev/disk1s4 78128400 65912496 12215904 84% 8239060 1526988
84% /Volumes/Spider

To 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 $USER

The 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.

  • Currently 1.57 / 5
  You rated: 1 / 5 (7 votes cast)

Add quota support on Mac OS X | 5 comments | Create New Account
Click here to return to the 'Add quota support on Mac OS X' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add quota support on Mac OS X
Authored by: designr on Aug 12, '03 01:23:35PM


Can this technique be used on OS X Server 10.2.x?

Is it safe?

Are there any pitfalls?

What happens when OS X Server 10.3 is released?

thanks in advance,

[ Reply to This | # ]
Add quota support on Mac OS X
Authored by: XSage on Aug 13, '03 01:02:48AM
Looking at this timeline, seems Darwin 6, Mac OS X 10.2 and OS X Server 10.2 are all the same at the unix level. In principle you wouldn't think quota stuff would be a problem. But if that's not enough a quick google shows someone in omnigroup doing this same stuff with OS X Server three years ago. As for Panther I'm assuming it's still going to work, but then again, apple has done things like break wget... but I don't think this will be the case.


[ Reply to This | # ]
Quota support native to OS X Server
Authored by: extra88 on Aug 13, '03 08:24:35AM
OS X Server v10.2 has a GUI for setting per-user disk quotas. I'm sure the GUI is just a front-end for the commandline tools, like the firewall GUI for ipfw.

OS X Server Features - File & Print Services

[ Reply to This | # ]

Add quota support on Mac OS X
Authored by: core on Aug 13, '03 09:14:30AM


i tested this once with jaguar. quotas work unix-like but the finder does not recognize the reason why it is not allowed to copy one (too big) file to a group-quotaed folder for instance.
it just gave me a common error. bad for the unexpierienced user - and those are the one that typically get limited.
so for this purpose it seems useless to me until the finder learns about it. (10.3?)


[ Reply to This | # ]
Add quota support on Mac OS X
Authored by: dasil003 on Apr 30, '05 06:28:50PM

I just tested this out on Tiger and it works well... I was concerned that when you hit your hard limit you might not be able to login because of the need to do some temporary housekeeping, but that appears not to be the case. In fact, you seem to be able to do most things, with errors cropping mostly in regards to actually downloading and copying files. So if you inform the users about the limit, they should be able to delete files themselves to get back under.

Soft limits do nothing, but if you were to create a login script that checked your soft limit you could generate an AppleScript warning or something to alert the user. They could still get errors, but if you have a legitimate need for quotas (eg. you don't want your kids filling up your hard drive with downloads), then at least you limit the errors to the people who are responsible for them :)

[ Reply to This | # ]