Home‎ > ‎Server config‎ > ‎

Linux disk quotas

1. Enable quota check on filesystem

First, you should specify which filesystem are allowed for quota check.

Modify the /etc/fstab, and add the keyword usrquota and grpquota to the corresponding filesystem that you would like to monitor.

The following example indicates that both user and group quota check is enabled on /home filesystem

# vim /etc/fstab
UUID=4ea80ca3-37b7-447e-831a-700a38627029 /home ext4 defaults,usrquota,grpquota 1 2 

or

 /dev/hda1 /home ext4 defaults,usrquota,grpquota 1 2

Reboot the server after the above change. While rebooting it will take some time (only one time) to enable usrquota, grpquota on the /home filesystem. So wait.

2. Initial quota check on Linux filesystem using quotacheck

Once you’ve enabled disk quota check on the filesystem, collect all quota information initially as shown below. For that you may need to install the following packages.

# apt-get install quota quotatool
# quotacheck -avug 
quotacheck: Scanning /dev/sda3 [/home] done quotacheck: Checked 5182 directories and 31566 files quotacheck: Old file not found. quotacheck: Old file not found.

In the above command:

  • a: Check all quota-enabled filesystem
  • v: Verbose mode
  • u: Check for user disk quota
  • g: Check for group disk quota

The above command will create a aquota file for user and group under the filesystem directory as shown below.

# ls /home/ 
aquota.user aquota.group
# quotaon -avug

3. Install webmin gui to control hdd quota for the users & groups

First install the dependencies as shown below

# apt-get install apt-show-versions

For Ubuntu 12.04 you can download the webmin deb file from the below link

http://sourceforge.net/projects/webadmin/files/webmin/1.620/webmin_1.620_all.deb/download

and install as follows

# dpkg -i webmin_1.620_all.deb

Once you installed you can access the webmin in your browser at either https://localhost:10000/ or it will give you hostname as like below.

https://arulalan:10000/

You can download other os distro binary and source files from the below link.

http://sourceforge.net/projects/webadmin/files/webmin/

4. Open webmin gui

now log into webmin & search ‘quota’ you should see a result called “Disk Quotas”

click on it and press enable quotas on /home

now u can create/set hdd quotas like soft, hart limits & grace time for each users, groups… 

Soft limit : Actual size that you are allocating to the user/group
Grace time : Some grace period (seconds to days) you are allocating to allow the user to exceed the soft limit (upto grace period) but not hard limit.
Once they exceed the soft limit, then they have to revert back to less than their soft limit size within the allocated grace time period.
Hard limit : Hard limit that you are allocating to the user/group for the max size they can use at any most case. They can not exceed this limit at any time.

5. Notify the used home size & quota status report to the user when they login into the shell/terminal

Finally :-

add the below lines in the

# vim /etc/bash.bashrc

to show the users quota information with their limit & used space whenever they login to the shell/terminal.

echo "Your home directory quota information "quota -us $USERecho "Try to keep space < quota. You cant exceed the limit "