Setting Filesystem Quotas on Ubuntu 22.04
Install the Quota Tools
Install the
quotacommand line tools usingaptpackage manager:sudo apt update
sudo apt install quotaUpdate the mount options for the filesystem by updating the corresponding entry in
/etc/fstabconfiguration file, using an editor of your choice to:# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda /home ext4 defaults,usrquota,grpquota 0 1
The options usrquota and grpquota enables quotas on the filesystem for both users and groups.
Ensure that you add the new options separated by a comma and no spaces.
Remount the filesystem to apply the new options:
sudo mount -o remount /home
Verify that the new options are used to mount the filesystem:
cat /proc/mounts | grep ' /home 'Create the
aquota.user, andaquota.groupfiles that contain information about the limits and the usage of the filesystem:sudo quotacheck -ugm /home
The option
-ucreates theaquota.userfile for users, the-goption creates theaquota.groupfile groups, and the-moption disables remounting the filesystem as read-only. You can view the quota files that are created using thels /homecommand.Turn on the quota system using:
sudo quotaon -v /home
Configure Quotas for a User
To edit quota for user
sudo setquota -u <example_user> 100M 110M 0 0 /home |
Check the new quota for the user:
sudo quota -v <example_user> |
If you want your users to be able to check their quotas, even if they do not have sudo access, then you need to give them permission to read the quota files you created. Create a users group, make those files readable by the users group, and then make sure all your users are added in the group.
Also, users can check their quota usage using the quota command:
quota -s --hide-device --show-mntpoint |