The cart is empty

File system quotas are essential for managing and controlling the amount of data users and groups can store on a server. In a CentOS 7 environment, configuring quotas is relatively straightforward but requires careful planning and understanding of a few steps. This article will guide you through the process of enabling and configuring quotas for users and groups on CentOS 7, step by step.

Preparation

Before getting started, it's essential to ensure that the file system you want to enable quotas on is mounted with the necessary options. To check the currently mounted file systems, you can use the command:

mount

If the file system is not yet mounted with quota options (usrquota for user quotas, grpquota for group quotas), you'll need to modify the /etc/fstab file and add these options to the appropriate mount entry.

Configuring /etc/fstab

  1. Open the /etc/fstab file in an editor:
    nano /etc/fstab
    ​
  2. Find the mount entry for the file system where you want to enable quotas and add usrquota,grpquota to the options list. For example:
    /dev/mapper/centos-home /home                   xfs     defaults,usrquota,grpquota        0 0
    ​
  3. Save and close the file. Then remount the file system with the new options using umount and mount commands, or simply restart the system.

 

Enabling Quotas

After configuring /etc/fstab, you need to initialize and enable quotas.

  1. For ext4 file systems, run:
    quotacheck -cug /home
    ​

    For XFS, use xfs_quota:

    xfs_quota -x -c 'state on' /home
    
  2. Then enable quotas:
    quotaon /home
    ​

 

Setting Quotas

After enabling quotas, you can set specific limits for users or groups.

  1. To set a quota for a user, use setquota:
    setquota -u username 500000 550000 0 0 /home
    ​

    This sets a soft quota of 500 MB and a hard quota of 550 MB for the user username on the /home file system.

  2. For groups, use a similar command with the -g option:
    setquota -g groupname 1000000 1050000 0 0 /home
    ​

 

Monitoring Quotas

To view quota usage for all users or groups, you can use the repquota command:

repquota /home

This command provides a summary of space and file usage for each user or group.

 

Properly configuring quotas on CentOS 7 can help efficiently manage disk resources and prevent individual users or groups from monopolizing disk space. Follow the above steps to ensure your quotas are correctly set and managed.