Wednesday, March 16, 2011

Enable Quota on RHEL/CentOS

Quota is used for limiting the disk usage for users or groups.

###To verify that the quota is enabled in the kernel###
#grep CONFIG_QUOTA /boot/config-`uname -r`
CONFIG_QUOTA=y
CONFIG_QUOTA_NETLINK_INTERFACE=y
# CONFIG_QUOTA_DEBUG is not set
CONFIG_QUOTA_TREE=y
CONFIG_QUOTACTL=y
[root@rajat rajat]#

Create user :
#useradd rajat
#passwd latar


Edit /etc/fstab :
From :
/dev/sda5 /home ext3 defaults 1 2
To :
/dev/sda5 /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

No comments: