6.7.1 Setting Project Quotas

User and group quotas are supported by other file systems, such as ext4. The XFS file system additionally allows you to set quotas on individual directory hierarchies in the file system that are known as managed trees. Each managed tree is uniquely identified by a project ID and an optional project name. Being able to control the disk usage of a directory hierarchy is useful if you do not otherwise want to set quota limits for a privileged user (for example, /var/log) or if many users or groups have write access to a directory (for example, /var/tmp).

To define a project and set quota limits on it:

  1. Mount the XFS file system with project quotas enabled:

    # mount -o pquota device mountpoint

    For example, to enable project quotas for the /myxfs file system:

    # mount -o pquota /dev/vg0/lv0 /myxfs
  2. Define a unique project ID for the directory hierarchy in the /etc/projects file:

    # echo project_ID:mountpoint/directory >> /etc/projects

    For example, to set a project ID of 51 for the directory hierarchy /myxfs/testdir:

    # echo 51:/myxfs/testdir >> /etc/projects
  3. Create an entry in the /etc/projid file that maps a project name to the project ID:

    # echo project_name:project_ID >> /etc/projid

    For example, to map the project name testproj to the project with ID 51:

    # echo testproj:51 >> /etc/projid
  4. Use the project subcommand of xfs_quota to define a managed tree in the XFS file system for the project:

    # xfs_quota -x -c ’project -s project_namemountpoint

    For example, to define a managed tree in the /myxfs file system for the project testproj, which corresponds to the directory hierarchy /myxfs/testdir:

    # xfs_quota -x -c ’project -s testproj’ /myxfs
  5. Use the limit subcommand to set limits on the disk usage of the project:

    # xfs_quota -x -c ’limit -p arguments project_namemountpoint

    For example, to set a hard limit of 10 GB of disk space for the project testproj:

    # xfs_quota -x -c ’limit -p bhard=10g testproj’ /myxfs

For more information, see the projects(5), projid(5), and xfs_quota(8) manual pages.