Posted in RHCE

Quota on RHEL/CentOS

March 23, 2007 - 7 comments

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

hari

April 10, 2007 - 10:57

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…….

dnk

July 10, 2007 - 2:03

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

March 4, 2009 - 23:38

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?

Sébastien Wains

March 4, 2009 - 23:42

Dan, yes

dan

March 6, 2009 - 23:39

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

March 6, 2009 - 23:45

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

July 26, 2010 - 11:24

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.

Before submitting, some rules :
- Is your comment related to the article ?
- You're having a problem ? Have you checked Google, other howtos, docs, manpages ?
- You're still having the problem ? Have you raised log verbosity, checked traces, ran tcpdump ?
- Have you checked your configuratoin for typo ?
Unless your comment is providing additional info or respect the rules above, DON'T comment.
If you don't understand what you are doing, I urge you to read the documentation, I'm not your free Level 1 helpdesk guy.