17 Jan 2010

Create filesystem quotas on Gentoo

The Gentoo documentation for adding user quotas actually tells the user to create invalid quota files, leaving quotacheck to fix them up on next reboot. This is pretty stupid, so here’s the proper way to create user quotas:

  1. Add usrquota (and/or grpquota) to the filesystem options in /etc/fstab:

    /dev/sda4 /mnt/foo reiserfs noatime,usrquota 0 0

  2. Ensure the filesystem root does not have any of the quota files:

    rm -f /mnt/foo/quota.* /mnt/foo/aquota.*

  3. Create the quota file(s). Make sure you pass quotacheck the device, not the mountpoint!

    quotacheck -ucvd /dev/sda4

    If you wish to enable group quotas, add -g to the arguments. The key here is the -c argument: this tells the tool to create the quota files if they are missing.

  4. Switch on quotas:

    quotaon /mnt/foo

Also, the big red warning in the Gentoo docs can safely be ignored, I’ve never had a problem with quotas on ReiserFS.