≡ Menu

5 Steps to Setup User and Group Disk Quota on UNIX / Linux

On Linux, you can setup disk quota using one of the following methods:

  • File system base disk quota allocation
  • User or group based disk quota allocation


On the user or group based quota, following are three important factors to consider:

  • Hard limit – For example, if you specify 2GB as hard limit, user will not be able to create new files after 2GB
  • Soft limit – For example, if you specify 1GB as soft limit, user will get a warning message “disk quota exceeded”, once they reach 1GB limit. But, they’ll still be able to create new files until they reach the hard limit
  • Grace Period – For example, if you specify 10 days as a grace period, after user reach their hard limit, they would be allowed additional 10 days to create new files. In that time period, they should try to get back to the quota limit.

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

# cat /etc/fstab
LABEL=/home    /home   ext2   defaults,usrquota,grpquota  1 2

Reboot the server after the above change.

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.

# 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 -l /home/

-rw-------    1 root     root        11264 Jun 21 14:49 aquota.user
-rw-------    1 root     root        11264 Jun 21 14:49 aquota.group

3. Assign disk quota to a user using edquota command

Use the edquota command as shown below, to edit the quota information for a specific user.

For example, to change the disk quota for user ‘ramesh’, use edquota command, which will open the soft, hard limit values in an editor as shown below.

# edquota ramesh

Disk quotas for user ramesh (uid 500):
  Filesystem           blocks       soft       hard     inodes     soft     hard
  /dev/sda3           1419352          0          0       1686        0        0

Once the edquota command opens the quota settings for the specific user in a editor, you can set the following limits:

  • soft and hard limit for disk quota size for the particular user.
  • soft and hard limit for the total number of inodes that are allowed for the particular user.

4. Report the disk quota usage for users and group using repquota

Use the repquota command as shown below to report the disk quota usage for the users and groups.

# repquota /home
*** Report for user quotas on device /dev/sda3
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      --  566488       0       0           5401     0     0
nobody    --    1448       0       0             30     0     0
ramesh    -- 1419352       0       0           1686     0     0
john      --   26604       0       0            172     0     0

5. Add quotacheck to daily cron job

Add the quotacheck to the daily cron job. Create a quotacheck file as shown below under the /etc/cron.daily directory, that will run the quotacheck command everyday. This will send the output of the quotacheck command to root email address.

# cat /etc/cron.daily/quotacheck
quotacheck -avug
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • susant August 27, 2010, 1:52 pm

    yeah thanks for this great information can i know what is the difference between vi editor and cat ?????

  • Anto January 31, 2011, 4:02 am

    How to setup quota for users who already used some space in the machine ?

  • Rinku July 20, 2011, 12:37 am

    Hello Sir one question please help to understand this question
    Q1.How can i connect with remote pc with in private network i mean my private network is A and his private network B with public ip ?
    Q2.How can i connect from private network A to private network B with his central sever that has public ?

    Please Help sir ,I know sir you can help because your every article on this website is awesome

  • raz October 26, 2011, 3:17 pm

    Great article. Thanks for writing it.
    You can also pipe your output to an email – it’s low end – for sure but it keeps you in the loop without having to login to the server.

    btw- those other comments on this article… OMG. really? 🙂

  • D M R April 30, 2012, 5:49 am

    thanks for u r quotas configuration information

  • Dammu Mohana Rao April 30, 2012, 5:52 am

    How to setup quota for users who already used some space in the machine ?
    and in which situation the quotas implementation is useful.

  • Nishaj June 7, 2012, 4:52 am

    Hi,

    Do we need to add a quotacheck -avug on cron jobs?
    I guess it should be repquota?

  • Senthil October 15, 2013, 1:51 am

    In step1, we don’t have to reboot the server after making fstab change. just remount is enough.

  • James February 4, 2014, 10:46 pm

    @Senthil, using Debian wheezy, I need to reboot in order for the kernel to be aware of the file system changes. Mount -a doesn’t cut it for me.

  • Biswa March 18, 2014, 10:11 pm

    Good article.

  • roni June 11, 2014, 11:31 pm

    In the below output i want to exclude a user “nobody” how can i do it

    # repquota /home
    *** Report for user quotas on device /dev/sda3
    Block grace time: 7days; Inode grace time: 7days
    Block limits File limits
    User used soft hard grace used soft hard grace
    ———————————————————————-
    root — 566488 0 0 5401 0 0
    nobody — 1448 0 0 30 0 0
    ramesh — 1419352 0 0 1686 0 0
    john — 26604 0 0 172 0 0

  • Hope January 30, 2015, 1:10 am

    Thanks, but now I cannot boot my system and can’t revert the changes, this happened just after doing the first thing you advised to do “# cat /etc/fstab
    LABEL=/home /home ext2 defaults,usrquota,grpquota 1 2
    Reboot the server after the above change.”

  • Anonymous February 20, 2015, 1:11 am

    Graceperiod def is wrong

  • Priya October 1, 2015, 2:01 pm

    Formulatin​g a plan to limit space allocation as per user role

    Hello friends,

    Since recently we have been getting a space issues on our Solaris server.
    we are looking to formulate a plan to limit the space per user.
    In the recent space issues, we had some users who were running very big jobs and because of that it is affecting the entire file system on our server. there is no limit is there for any user for space.

    so how can we implement this.
    from where and how can we start this, am beginner in Solaris Administration
    how much should we allocate based on their role.

    please can any one through some ideas or your experience on this.

    Thank you

  • priya October 1, 2015, 2:17 pm

    Hi Ramesh Natarajan,

    My name is Priya, am new to your blog.

    I have gone through the articles you are posting, they are really very informative and very helpful to everyone.
    Thank you very much for the nice work.

    I need your help with any script for Solaris server for space management
    I searched every where but could not find script that fulfills my requirement.
    for the past 2 months we are getting some space issues on our Solaris server.
    We had these issues on our Server several times, all of sudden the file system sas/saswork reaches Max 100 % suddenly and there by all other mounting points are reaching 100%.

    when we are checking the saswork or other files we did not find any bigger jobs running by any user or any big tables created.

    whatever is causing the space to peak is happening very quickly and the critical condition is upon us by the time we get the alert.

    we are looking for a daily report on files in the space sorted by size and by last date accessed? we want creating a space management report in SAS.

    do you have any existing script for this or can you assist with this please

    I would really appreciate if you can assist us with this with any kind of unix script.

  • chakchake November 20, 2015, 10:13 am

    I am not able to enforce user quota even after the disk-quota configuration is successful. I have set the hard & soft limit for disk quota size. The quota is turned on. Upon using ‘fallocate’ to push the disk quota boundary my ‘user’ is able to do it……Please help.