Posted in RHCE
Quota on RHEL/CentOS
Here are the steps to implementing quotas on a RedHat based system :
We will enable quotas on /home on the /dev/hda3 partition.
Create user :
useradd user1
passwd user1
Edit /etc/fstab :
From :
/dev/hda3 /home ext3 defaults 1 2
To :
/dev/hda3 /home ext3 defaults,usrquota,grpquota 1 2
Remount the disk (make sure it’s not in use) :
mount -o remount /home
Check if usrquota and grpquota are enabled :
mount | grep /home
Create quota files :
quotacheck -cvug /home
This creates /home/aquota.user and /home/aquota.group
Check quota :
quotacheck -avug
Enable quota for user1 :
edquota user1
Edit soft and hard limits (1000 = 1 MB) or inode values.
Check the quota for user1 :
quota user1
Enable quota :
quotaon -avug
In addition :
Through a cron, run everynight when the filesystem is not used :
quotaoff -avug && quotacheck -avug && quotaon --avug
Get quota stats :
repquota -a
Warn users when their quota has been reached :
warnquota
For some reason I had to manually edit /etc/quottab for warnquota to work
Comments
dnk
I was attempting to do this with a logical volume, so I added this to my fstab:
/dev/VolGroup00/LogVol00 / ext3 defaults,usrquota,grpquota 1 1
Then with checking:
# mount | grep /
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw,usrquota,grpquota)
I then tried the:
# quotacheck -cvug /
quotacheck: Cannot remount filesystem mounted on / read-only so counted values might not be right.
Please stop all programs writing to filesystem or use -m flag to force checking.
What is the proper way to do this when my home folder is not on it’s own drive?
Dan
Hello – If a quota is reached, how can you delete the file(s) to reuse the quota space?
Would deleting unused/unnecessary files in the /home directory accomplish this?
dan
Thanks Sebastian, one more question I’m hoping you might be able to answer. I am planning on taking RHCT soon. My question is on YUM (or rpm/apt). I see it is an objective on the Redhat site, but I heard during the exam we will have not have internet access. So is there a way to use it without the internet?
Sébastien Wains
Dan,
Yum can work with a local repository..
For practice you may be interested in creating a local repo (not up to date for RHEL5) :
http://www.wains.be/index.php/2007/02/26/creating-a-local-centos-mirror/
Nicolas Steinmetz
Thanks for the tip.
Little typo : there are two “-” for “quotaon –avug” on the line “quotaoff -avug && quotacheck -avug && quotaon –avug”.
Leave Comment
Please consider visiting the partners below if you enjoyed this article :If this post saved you time and money, please consider checking my Amazon wishlist.







hari
hello sebastian……The place i work at faces periodical power problems.so after a power cut situation my CENTos does not boot…its gives a message of some remount kind of stuff….. and the only remedy my sysadmin can figure out is formatting the PC…… leading to the loss of some of my important files……could you suggest some alternative please…….