Here's how to configure disk quotas on Linux:
- Install the necessary packages:
apt install quota quotatool
- Modify the /etc/fstab file to enable quotas on the desired filesystem by adding the usrquota and/or grpquota options. For example:
/dev/sdb1 /mnt/data ext4 defaults,usrquota,grpquota 0 0
- Remount the filesystem to apply the changes.
- Create the quota database files and generate the disk usage table with the quotacheck command.
- Enable quotas with the quotaon command:
quotaon -vgu /mnt/data
- Assign quotas to users or groups using the edquota or quotatool command. For example, for a user:
edquota username
or
quotatool -u username -bq 1G -l 2G /mnt/data
In the editor opened by edquota, you can set soft and hard limits for blocks (disk space) and inodes (number of files).
Quotas allow you to limit disk space usage per user or group by setting soft limits (which can be temporarily exceeded) and hard limits (which can never be exceeded).