Configure Quota on CentOS 6

Steps

Check for kernel support

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

Install the package

yum install quota

Edit /etc/fstab file

vi /etc/fstab

dev/mapper/VolGroup-lv_root /                       ext4 defaults,usrquota,grpquota        1 1

Remount the file system

mount -o remount /

Check the file system

mount | grep usrquota

/dev/mapper/VolGroup-lv_root on / type ext4 (rw,usrquota,grpquota)

Create quota files

quotacheck -avugm

Turn on quota

First time run it manually, after every reboot it will start from /etc/rc.d/rc.sysinit file

quotaon -avug

Commands

Quotas can be set with the edquota or setquota command

  • Edit the user quota: edquota -u <user>
  • Edit the soft time limits for each filesystem: edquota -t
  • Displays users’ disk usage and limits: quota -u <user>
  • Report on all filesystems: repquota -a
  • Display only information on filesystems where usage is over quota: quota -q
  • Queries the kernel for quota statistics: quotastats
  • Set quota from shell (format: soft-block-limit hard-block-limit soft-inode-limit hard-inode-limit - 200/300 MB): setquota -u <user> 204800 307200 0 0 /
  • Display the block size of the file system: dumpe2fs /dev/sda1 | grep -i 'Block size'
  • Test quota: dd if=/dev/zero of=quota_test bs=4k count=100000