Author: Karthi S
In this article, we walk through enabling and managing user quotas on an ext4 filesystem in CentOS 7.9, from fstab configuration to applying quotas for multiple users.
1. Fstab entry for quota configuration
Ensure /etc/fstab contains the necessary options:
UUID=xxxxxxxxx-f5xx-43xx-xxbb-xxxxxxxxxxxxxx /home/userfolder auto defaults,rw,nofail,usrquota,grpquota 0 0
This enables user and group quotas and mounts the filesystem with quota support.
2. Verify mount and filesystem type
mount | grep /home/userfolder /dev/mapper/centos-7.9 on /home/userfolder type ext4 (rw,relatime,seclabel,data=ordered)
3. Install the quota package
yum install quota -y
4. Remount to enable quota
sudo mount -o remount /home/userfolder
You should see usrquota and grpquota in the mount options.
5. Run quota check
sudo quotacheck -um /home
This creates aquota.user and aquota.group.
6. Enable quotas
sudo quotaon -uv /home/userfolder
7. Verify quotas are active
quotaon -ap
8. Set quotas for users
Example soft limit 1.8GB, hard limit 2GB:
sudo setquota -u username 1800M 2048M 0 0 /home/userfolder
9. Verify quotas for users
sudo repquota /home/userfolder
10. Automate quota setup for multiple users
Create setupquota_ext4.sh:
#!/bin/bash mntpnt=/home/userfolder users="$( ls $mntpnt )" for user in $users do echo "Setting quota for user: $user" sudo setquota -u $user 1800M 2048M 0 0 /home/userfolder done
11. Final check
sudo repquota /home/userfolder
Conclusion
By following these steps, you can enable and manage user quotas on ext4 and apply consistent limits across multiple users.