• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Life always offers you a second chance ... Its called tomorrow !!!

    Thursday, September 13, 2012

    How to implement Quota in Red Hat Linux

    Quota Implementation is done in Linux to limit the storage consumption per user/group. I have tested the below commands in Red Hat 5&6 as well as the commands will work in CentOS and OEL 5&6 respectively.

    • Limit storage consumption per user/group
    • Based on disk block usage or inode usage
    • Imposed in 2 stages (thresholds) : soft and hard
      • Soft limit: may be exceeded for up to the grace period
      • Hard limit: may never be exceeded under any circumstance
    • 'quota*' rpm
    • Must associate file systems with quota management: user and/or group
    Check the presence of the package.
    # rpm -qa | grep quota

    If the package is missing you can install using yum.
    # yum -y install quota

    Enable in '/etc/fstab' as shown below
    LABEL=/        /          ext4   defaults,usrquota,grpquota        1    1

    Remount the file system on which you have implemented quota# mount -o remount /
    NOTE: Optional methods of remounting the file system is either to use mount/umount or reboot the system

    This command will reflect whether or not 'usrquota', 'grpquota' options have been enabled
    # mount
    /dev/sda3 on / type ext4 (rw,usrquota,grpquota)

    Create quota database files and generate disk usage table - defines baseline
    # quotacheck -cug /
    NOTE: 'quotacheck' should be run in single user mode OR when the system reboots to facilitate read only remount of the file system.

    Use '-m' to override
    This creates /aquota.user and /aquota.grp
    # quotacheck -mcug /
    Check defined quota database:
    # quotacheck -amvug
    quotacheck: Your kernel probably supports journaled quota but you are not using it.
    Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.
    quotacheck: Scanning /dev/sda3 [/] done
    quotacheck: Checked 17088 directories and 173144 files

    Assign quota policies per user and/or group:
    # edquota deepak
    Disk quotas for user deepak (uid 500):
      Filesystem      blocks       soft       hard   inodes     soft     hard
      /dev/sda3          36         40          50      9          0        0

    Now here you can manually limit the block and files for each user or group.
    For example if you want to set the storage limit to 100MB as soft limit and 120MB as hard limit for user 'deepak'
    # edquota deepak
    Disk quotas for user deepak (uid 500):
      Filesystem      blocks       soft       hard   inodes     soft     hard
     /dev/sda3          36        102400     122880    9         0        0

    To check the assigned quota and the current status
    # repquota /dev/sda3
    *** Report for user quotas on device /dev/sda3
    Block grace time: 7days; Inode grace time: 7days
                           Block limits                File limits
    User            used    soft    hard  grace    used  soft  hard  grace
    deepak    +-     36    102400 122880  7days    7354     0     0

    To modify the grace period, by default it is set to 7 days which you can change accordingly
    # edquota -T deepak
    Times to enforce softlimit for user deepak (uid 500):
    Time units may be: days, hours, minutes, or seconds
     Filesystem                         block grace               inode grace
     /dev/sda3                         604100seconds                  unset

    To verify if the quota is on
    # quotaon -p /
    group quota on / (/dev/sda3) is on
    user quota on / (/dev/sda3) is on

    If the quota is turned off in your case, you can turn them on manually using this command
    # quotaon -vug /

    Follow the below links for more related articles

    What is the difference/comparison between Unix and Linux ?
    What are the maximum and minimum limits for RHEL 4 vs 5 vs 6 ?
    Step by Step Linux Boot Process Explained In Detail
    What is the difference between ext3 and ext4 filesystem in Linux ?
    How to configure Private Network in VMware Workstation
    9 examples to help you understand top command usage in Unix/Linux
    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    15 tips to enhance security of your Linux machine
    Why is Linux more secure than windows and any other OS
    Understanding Load Average in Linux and when to be worried about it?
    Disk Attachment Technology FC vs SAS vs iSCSI
    Understanding UMASK value in Linux
    How to keep a track of all the commands run by any user in Linux
    How do you check Linux machine is Physical or Virtual remotely?
    RAID levels 0, 1, 2, 3, 4, 5, 6, 0+1, 1+0 features explained in detail