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:
Add the option “*pquota*” to fstab so the xfs partition gets mounted with project quotas enabled.
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.
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
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
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