The disk quota system (disk quotas) allows administrators to control the disk space that individual users or groups of users can occupy. Setting appropriate disk space limits is key to maintaining order and performance on servers, especially in multi-user environments.
To enable the disk quota system, start by modifying the configuration file /etc/fstab. In this file, add the options usrquota for user quotas and grpquota for group quotas.
Example entry in file /etc/fstab:
/dev/sda1 /home ext4 defaults,usrquota,grpquota 0 2
After making these changes, it is necessary to remount the file system to apply the changes. This can be done using the command:
sudo mount -o remount /home
In order for the quota system to work, the relevant files must be initialised. We use the command quotacheck, which will create the header files in the file system:
sudo quotacheck -ugm /
u: creates a file for usersg: creates file for groupsm: does not remount file system as read-only when checkingOnce the file system has been configured, quotas must be activated:
sudo quotaon -v /home
To check if the quotas have been activated, you can use:
quota -u <użytkownik>
This command will display the current use of storage space by the user in question.
To configure quotas for a specific user or group, use the command edquota. For a user, the command is as follows:
sudo edquota -u <użytkownik>
For group:
sudo edquota -g <grupa>
Limits can be set as:
Example of limit setting:
Disk quotas for user <użytkownik> (uid <uid>): Filesystem blocks soft hard inodes soft hard /dev/sda1 0 100M 110M 0 0 0
The grace period allows users to stay over the soft limit for a specified period of time. The default is 7 days, but this can be changed to other time units such as days, hours or minutes.
To adjust the grace period, you can use the command:
sudo edquota -t
Enter the values you wish to set.
To assign the same quota value to a user, you can use:
sudo edquota -p <użytkownik_źródłowy> <użytkownik_docelowy>
You can monitor the current quotas of all users using:
repquota -a
This command shows an overview of the disk space usage of all users.
In summary, the disk quota system in Debian allows flexible management of disk space, which is essential for maintaining order in multi-user environments.