So I needed to do per-directory hard quotas for my users. Luckily, xfs supports “project” quotas which allow a directory hierarchy to be soft or hard limited.

To set this up for a user, lets call him derpface:

  1. Add the option “*pquota*” to fstab so the xfs partition gets mounted with project quotas enabled.

  2. Run the following commands to setup the project and directory declarations:

    mkdir /srv/derpface echo 1600:/srv/derpface >> /etc/projects echo derpface:1600 >> /etc/projid

Note that the “1600? is merely a project id. I would use the UID or something unique to that user. I’m also using the username as the project name in this example to make things simpler.

  1. And now tell xfs to enable and apply a certain limit to the project.

    xfs_quota -x -c 'project -s derpface' /srv 
    xfs_quota -x -c 'limit -p bhard=300g derpface' /srv
  2. Done:) View your hard work with the following status command:

    xfs_quota -x -c "report -h" /srv

Note that if you were to bind mount this directory “*/srv/derpface*”, like for example, in a docker container, it would show as a 300GB volume

Thanks oracle!

PS: If you ever want to modify the quota, just re-run the command with the modified storage allowance:

xfs_quota -x -c 'limit -p bhard=600g derpface' /srv
Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.