Quotas can be used to limit how much disk spave a user or group can use . Here's how to implement quotas in Linux.

  1. Check if quotas are enabled (by default they're not)
       mount | grep ' / '
       /dev/mapper/vg00-lvroot on / type xfs (rw,relatime,seclabel,attr2,inode64,logbsize=256k,sunit=512,swidth=512,noquota)
  2. As we can see from the output (noquota in the output), quotas are not currently enabled so we need to enable them.
    1. For the root filesystem, edit /etc/default/grub updating the line GRUB_CMDLINE_LINUX by adding the following:
          rootflags=usrquota,grpquota
    2. This enabled quotas for both users and groups. Since we updated the grub config, we need to rebuild grub ( For more grub2 information, check this article About grub2 )
            cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.orig
            grub2-mkconfig -o /boot/grub2/grub.cfg
            shutdown -r now
  3. For other filesystems, e.g. if /home is a seperate filesystem and not part of /
    1. update /etc/fstab, e.g.
            /dev/VolGroup00/LogVol02 /home     ext3    defaults,usrquota,grpquota  1 2
    2. Then remount the filesystem
  4. Now that quotas have been enabled, we need to be able to control them. To do this we need to have the quota package installed. To check
    1. RHEL/CentOS
          rpm -qa | grep quota
          yum -y install quota (if not installed)
    2. Ubuntu/Ubuntu based
           dpkg -l | grep quota
           apt-get install quoya (if not installed) 
  5. Now we can see what the current quota settings are: repquota -as
  6. Soft and hard limits can be set with quotas. When utilsation reaches the soft limit, the user gets a warning. The hard limit cannot be exceeded. (inodes shows the number of inodes used and hard and soft limits can be set on inodes, the last 2 values, currently both 0 ) To set a quota for a user: edquota -u username . This will open an editor session, e.g.
       Disk quotas for user user01 (uid 1001):   
    Filesystem                blocks     soft     hard   inodes   soft   hard   
    /dev/vg00/lvhome          203620    400000   500000    2619      0      0
  7. After updating, check using quota username
  8. Quotas can be set at the group level by using the -g flag, e.g. edquota -g users

Never miss a thing subscribe to our newsletter For more super cool techie stuff check out our blog!!

Recent Changes

Contribute to this wiki

Why not help others by sharing your knowledge? Contribute something to this wiki and join out hall of fame!
Contact us for a user name and password