Managing Disk Quotas In Linux

Managing Disk Quotas In Linux – Disk space can be restricted by implementing disk quotas which alert a system administrator before a user consumes too much disk space or a partition becomes full.  As a Linux system admin we generally face low disk space issues. By implementing the user and group disk quota on the file system we can resolve the space issue. Quota restricts the users to use only allowed disk and inodes on the particular file system. In this post we will discuss how to enable user & group disk quota on /home File system on CentOS 7.
For example on here, Set Quota on /home which is ext4 formatted.

Managing Disk Quotas In Linux

Note : If you have chosen a different partitioning scheme than I did, you must adjust this chapter so that quota applies to the partitions where you need it.

1. Mounted filesystem with quota option

[root@dummy ~]# nano /etc/fstab

#
UUID=9826f0ee-fe28-4ce8-a4ee-5c7a3ce7a358 / ext4 defaults 1 1
UUID=bd0447df-7482-4362-a7a5-7c081893c2c1 /home ext4 defaults,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0 1 2
UUID=24553cd3-229f-4d70-8a60-b8c8cd2a9193 swap swap defaults 0 0

And then reboot your linux to apply the change
Now check if quota is enabled:
[root@dummy ~]# mount | grep ‘ /home ‘
/dev/sda2 on /home type ext4 (rw,relatime,seclabel,data=ordered,jqfmt=vfsv0,usrjquota=aquota.user,grpjquota=aquota.group)
[root@dummy ~]#
When quota is active, we can see “usrquota,grpquota” in the mount option list.

2. Install and Configure Quota

To install quota, we run this command:
[root@dummy ~]# yum install quota
Enabling quota on a separate /home partition
[root@dummy ~]# touch /aquota.user /aquota.group
[root@dummy ~]# chmod 600 /aquota.*
[root@dummy ~]# mount -o remount /home
[root@dummy ~]# quotacheck -avugm
[root@dummy ~]# quotaon -avug
[root@dummy ~]# edquota budi
Managing Disk Quotas In Linux

As shown above we have two kind of Disk quota limits :
soft : It will warn the users if the soft limit of disk quota reached ( size is in KB), in above example for budi user soft limit is 180000 KB ( approx 1.8GB )
hard : It will not allow the users to create new files once the hard limit is reached. ( Size in KB ), in above example hard limit for budi user is 2000000 KB ( approx 2 GB )
Note : We can also set the Quota on the basis of the inodes ( i.e numbers of files that the user can create on particular file system)

Then save and close

3. Display Quota report for Users in human readable

[root@dummy ~]# repquota -as

4. Configure Grace Period for Soft Limit

Grace period is the amount of time during which soft limit can can be exceeded, once the grace period reached then soft limit will become the hard limit.
[root@dummy ~]# edquota -t
Managing Disk Quotas In Linux

Then save and close

 

Thats all and Good Luck

Add a Comment