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
Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.Get the Linux Sysadmin Course Now!
If you enjoyed this article, you might also like..
|
|
|
|






My name is Ramesh Natarajan. I will be posting instruction guides, how-to, troubleshooting tips and tricks on Linux, database, hardware, security and web. My focus is to write articles that will either teach you or help you resolve a problem. Read more about
{ 7 comments… read them below or add one }
yeah thanks for this great information can i know what is the difference between vi editor and cat ?????
How to setup quota for users who already used some space in the machine ?
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
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?
thanks for u r quotas configuration information
How to setup quota for users who already used some space in the machine ?
and in which situation the quotas implementation is useful.
Hi,
Do we need to add a quotacheck -avug on cron jobs?
I guess it should be repquota?