Saturday, March 20, 2010

How to configure disk qouta in centos linux

Sponsored Links
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 -enables limit on usage
CONFIQ_QUOTACTL=y -associated with disk quota manipulation.

If you have custom or upgraded kernel. Enable quota by running any of the following commands.
#make menuconfig
#make gconfig
#make xconfig

Check the quota package
#rpm -q quota

[root@server ~]# rpm -q quota
quota-3.13-1.2.3.2.el5
[root@server ~]#


For using Quotas the partition we are using for quota [quota can only be used per partition.] should be mounted with quota options. For that go to /etc/fstab and edit the partition mount options.

#vi /etc/fstab
LABEL=home /home ext3 defaults,usrquota,grpquota 1 1
:wq

If the partition is already mounted remount it for affecting changes in mount options.
#mount -o remount /home

Check the filesystem is mounted with changed options. If not, you may have to umount and mount again or u've to restart the system.
#mount -to check
Device_name on /mount_point type ext3 (rw,usrquota,grpquota)

Create quota database
#quotacheck -mcug /home
[ If you are using quotacheck -cug, it will throw an error that it cannot remount the filesystem mounted on m_point so counted values might not be right. Please stop all the programs writing to filesystem or use -m flag to force checking. This will happen when we use the filesystems like "/". Many processes are writing into "/" that time. Thats why it is throwing this error.]

-c option specifies that the quota files should be created for each file system with quotas enabled.
-u option specifies to check for user quotas.
-g option specifies to check for group quotas.
If not, those files will be created.

quotacheck -mcug /home -will create following files in /home
aquota.group
aquota.user

Assign quota policies for user
#edquota username
#quota username -shows the quota for set for that user

Assign quota policies for group
#edquota -g groupname -think a user should exist with that group
#quota -g groupname -shows the quota for set for that group

Defining prototypical users
edquota -p user1 user2

To see all user qouta reports
#repquota -a

To see the user quotas in /home
#repquota -u /home
To see the group quotas in /home
#repquota -g /home
To see the quotas in appropriate size
#repquota -s /home -shows used space and hard limit in MB
To check the quota is on or not
#quotaon -v /home

To update the usage
#quotacheck -mavug -execute this often for knowing latest usage info. Put it in cronjob. may need -f option.
[This will check all the files and directories in all partitions which is mounted with quota options.]
-a Check all mounted non-NFS filesystems in /etc/mtab
-v Verbose. Displays the information as it proceeds.
-u Checks for the user quotas.
-g Checks for the group quotas.


Add quotacheck to daily cron
# cat /etc/cron.daily/quotacheck
quotacheck -avug


Setting grace period
#edquota -t
10days not 10 days.

To enable and disable the qoutas
#quotaon -vaug with -m if needed. For only one partition; quotaon -vug /home
#quotaon -vaug -will turn on all the quotas [group and user]
#quotaoff -vaug -will turn off all the quotas [gruop and user]
Sponsored Links

No comments:

Post a Comment

Be nice. That's all.