How to: Enable Quotas

Warning

It is recommended to enable quotas before installing InterWorx.

While quotas are an optional feature, they are recommended for the full InterWorx experience. This article includes instructions on how to enable quotas for XFS (the default file system for CentOS 7) and EXT4.

Note

Quotas should be enabled on the partition where the /home directory is located. If /home is located under root (‘/’) , then quotas should be enabled on root (‘/’) . If there is a separate /home partition, then quotas should be enabled on /home, instead.

To Identify the File System type

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. At the CLI, check if quotas are already enabled by running the following:

    mount | grep ' / '
    
    • The filesystem type will show in the output (emphasis added):

    [root@server ~]# mount | grep ' / '
    /dev/nvme0n1p1 on / type **xfs** (rw,relatime,attr2,inode64,noquota)
    [root@server ~]#
    

    or

    [root@server ~]# mount | grep ' / '
    /dev/xvda1 on / type **ext4** (rw)
    [root@server ~]#
    

To Enable Quotas for XFS

The following details enabling quotas for root (‘/’). If there is a separate /home partition, replace all instances of / in the following examples with /home, instead.

  1. Log in to the server at the CLI as root, either via SSH or from the terminal

  2. At the CLI, check if quotas are already enabled by running the following:

    mount | grep ' / '
    
    • If quotas are disabled, the output will state ‘noquota’

    [root@server ~]# mount | grep ' / '
    /dev/mapper/centos_el7-root on / type xfs (rw,relatime,attr2,inode64,noquota)
    [root@server ~]#
    
    • If quotas are already enabled, the output will show ‘usrquota’ and ‘groupquota’

    [root@server ~]# mount | grep ' / '
    /dev/mapper/centos_el7-root on / type xfs (rw,relatime,attr2,inode64,usrquota,grpquota)
    [root@server ~]#
    
  3. In a text editor, open /etc/default/grub

  4. Append rootflags=usrquota,grpquota to the line beginning with GRUB_CMDLINE_LINUX

    GRUB_CMDLINE_LINUX="rd.lvm.lv=centos_el7/root vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos_el7/swap crashkernel=auto vconsole.keymap=us rhgb quiet rootflags=usrquota,grpquota"
    
  5. Backup the grub configuration:

    cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.orig
    
    • For servers using EFI, the grub.cfg file is located at /boot/efi/EFI/centos/grub.cfg

      cp /boot/efi/EFI/centos/grub.cfg /boot/efi/EFI/centos/grub.cfg.orig
      
  6. Generate the new grub configuration

    grub2-mkconfig -o /boot/grub2/grub.cfg
    
    • For servers using EFI:

      grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
      
  7. Reboot the server

  8. Verify that quotas have been enabled

    mount | grep ' / '
    

To Enable Quotas for EXT4

The following details enabling quotas for root (‘/’). If there is a separate /home partition, replace all instances of / in the following examples with /home, instead.

  1. At the CLI, check if quotas are already enabled by running the following:

    mount | grep ' / '
    
    • If quotas are disabled, the output will state ‘noquota’

    [root@server ~]# mount | grep ' / '
    /dev/xvda1 on / type ext4 (rw)
    [root@server ~]#
    
    • If quotas are already enabled, the output will show ‘usrquota’ and ‘groupquota’

    [root@server ~]# mount | grep ' / '
    /dev/xvda1 on / type ext4 (rw,usrquota,grpquota)
    [root@server ~]#
    
  2. Using a text editor, open the file /etc/fstab. The following example uses the Vim text editor:

    vim /etc/fstab
    
  3. Edit the entry for /, adding “usrquota” and “grpquota” options after “defaults”. The completed line will look similar to the following:

    UUID=92c597ca-70f5-48ee-a173-64188df8ca55 /                       ext4    defaults,usrquota,grpquota         1 1
    
  4. Save and exit the text editor

  5. Remount the / filesystem with the following:

    mount -o remount /
    
  6. Repeat Step 1 to check if quotas are enabled:

    [root@server ~]# mount | grep ' / '
    /dev/xvda1 on / type ext4 (rw,usrquota,grpquota)
    [root@server ~]#
    
  7. Create the quota database using the following quotacheck command. This creates aquota.user and aquota.group under /:

    quotacheck -cugvm /
    

    The flags:

    • -c create quota file

    • -v verbose output

    • -u user disk quota

    • -g group disk quota

    • -m force checking

    The output will look similar to the following:

    [root@server ~]# quotacheck -cugvm /
    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/xvda1 [/] done
    quotacheck: Cannot stat old user quota file //aquota.user: No such file or directory. Usage will not be substracted.
    quotacheck: Cannot stat old group quota file //aquota.group: No such file or directory. Usage will not be substracted.
    quotacheck: Cannot stat old user quota file //aquota.user: No such file or directory. Usage will not be substracted.
    quotacheck: Cannot stat old group quota file //aquota.group: No such file or directory. Usage will not be substracted.
    quotacheck: Checked 15509 directories and 97004 files
    quotacheck: Old file not found.
    quotacheck: Old file not found.
    [root@server ~]#
    
  8. Run the quotaon command to turn on quotas:

    quotaon /