How to Fix Quotas


Last modified: November 29, 2022

Overview

Warning:
  • Quotas on some Ubuntu® servers may not work unless you take additional actions.

  • CloudLinux™ 7 updates may break quotas. For this reason, after each CloudLinux 7 update, you must run the /usr/local/cpanel/scripts/fixquotas script and then remount the file system.

  • If you disable and then reenable quotas, servers that use the XFS® filesystem and run the CentOS 7, CloudLinux 7 or 8, AlmaLinux OS 8, or Red Hat® Enterprise Linux® (RHEL) 7 operating systems require one of the following additional actions for quotas to function properly:

    • Use WHM’s Initial Quota Setup interface (WHM » Home » Server Configuration » Initial Quota Setup) to configure quotas.

    • Use the command line interface to run the /usr/local/cpanel/scripts/fixquotas script and then remount the file system.

    • Perform the /usr/local/cpanel/scripts/fixquotas script’s actions manually. For more information, read the Red Hat XFS and XFS Quota Management documentation.

This document describes how to confirm whether you properly configured the disk space quotas on your system’s devices. We enable quotas by default on new installations, but you must enable quotas for any device on which cPanel accounts exist.

Verify whether your device uses quotas

To verify whether your devices use quotas, connect to your system via SSH as the root user and perform the following actions in your command line interface:

Run the mount command

Run the mount command without any arguments to obtain basic information about all your currently-mounted file systems.

Entries that contain the usrquota variable are quota-enabled.

For example, the following output from the mount command confirms that the /dev/mapper/VolGroup00-LogVol00 device uses quotas because it contains a usrquota variable:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw,usrquota)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/usr/tmpDSK on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0)
/tmp on /var/tmp type none (rw,noexec,nosuid,bind)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
Note:

For more information about the mount command, visit the mount command documentation.

Examine the file system table contents

Important:

The /etc/fstab file is read-only. You cannot configure quotas by editing this file, only see whether quotas are enabled using the usrquota variable.

The file system table (/etc/fstab) file maps devices to their respective mount points within a system, displaying configuration options in six columns. These options determine the purpose of each file system and how it should mount:

Column Description Example
Device The physical device that contains the data. /dev/sda5
Mountpoint The filepath to the device’s data storage location. /backup
FStype The type of file system. ext3
Options The mount options for the file system. These options include the usrquota variable if quotas are enabled, as well as whether the system or users can execute programs on the device. defaults,noexec
Dump The dump option. This option has no impact on whether quotas are enabled. The dump backup utility uses this option. 0
Pass The fsck option. This option has no impact on whether quotas are enabled. The fsck file checking utility uses this option. 0

To display the contents of the /etc/fstab file, run the cat /etc/fstab command. The /etc/fstab file will resemble the following example, where entries that contain the usrquota variable are quota-enabled:

1
2
3
4
5
6
7
8
/dev/sda5               /backup                 ext3    defaults,noexec 0 0
LABEL=/boot             /boot                   ext3    defaults,usrquota  1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sda5               /swap                   swap    defaults        0 0
/usr/tmpDSK             /tmp                    ext3    defaults,noauto        0 0
Note:

For more information about the fstab file, visit the fstab command documentation, or connect to your system via SSH and run the man fstab command.

List the file systems in the /etc/mtab file with quota options enabled

Run the following command to print all of the file systems that exist in the /etc/mtab file with read and write privileges and quota options enabled:

repquota -a

The output will resemble the following example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
*** Report for user quotas on device /dev/vda1
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
root      -- 7824884       0       0         218302     0     0       
bin       --   73740       0       0             51     0     0       
nobody    --       0       0       0              4     0     0       
polkitd   --       0       0       0              2     0     0       
rpc       --       0       0       0              2     0     0       
rpcuser   --       0       0       0              4     0     0       
postfix   --       4       0       0             27     0     0       
chrony    --       4       0       0              3     0     0       
centos    --   13680       0       0           1773     0     0       
tss       --       8       0       0              2     0     0       
named     --     120       0       0             20     0     0       
mailman   --   38888       0       0           2199     0     0       
cpanel    --      28       0       0             17     0     0       

Enable quotas on your devices

After you verify which devices do not use quotas, connect to those devices via SSH as the root user and run the /usr/local/cpanel/scripts/initquotas script. This script adds the usrquota variable to the Options column in the /etc/fstab file.

Verify that you enabled quota files

After you run the /usr/local/cpanel/scripts/initquotas script, use the ls command with a wildcard character to confirm the following:

  • The quota files exist in the root directory (/).
  • Each file is greater than 0 bytes.

For example, the following ls -l /*.user command lists the contacts of the root directory (/):

1
2
3
root@host [/]# ls -l /*.user
-rwxr--r-- 1 root root 13312 Apr 26 16:39 /aquota.user*
-rwxr--r-- 1 root root    32 Apr 19 16:26 /quota.user*

The -l flag in this example causes ls output to display in long-listing format. This format displays the following information:

  • The file’s permissions.
  • Which user owns the file.
  • Which group owns the file.
  • The size of the file in bytes.
  • The file’s last modification date.

If there are no quota files in the root directory, run the /usr/local/cpanel/scripts/initquotas script again to create these files.

If quota files do exist, but quotas do not function, delete these quota files and then run the /usr/local/cpanel/scripts/initquotas or /usr/local/cpanel/scripts/fixquotas scripts.

A note about Virtuozzo®

If you use Virtuozzo, you must perform the following actions:

  • Enable second-level (per-user) quotas in addition to first-level (per-container) quotas.

  • Enable second-level quotas from the parent node.

For more information, read our Enable Quotas on a Virtuozzo VPS documentation.

How to fix quotas on Ubuntu

Some servers that run the Ubuntu operating system do not have the quota_v2 kernel module that enables quotas. If your server runs the Ubuntu operating system and quotas do not work, it may not have this module.

Check if your server has loaded its quota_v2 module

Run this command to check if your server has loaded its quota_v2 module:

lsmod | grep quota_v2

If your server has loaded its quota_v2 module, it will produce an output that resembles the following example:

quota_v2               16384  1
quota_tree             20480  1 quota_v2

If your server produces a response that does not contain quota_v2, you must install the appropriate quota_v2 module.

Install your server’s quota_v2 module

To install your server’s appropriate quota_v2 module, perform the following steps:

  1. Check your server’s kernel metapackage.

    a. Run the following command to find the server’s current boot image:

    grep BOOT /proc/cmdline | cut -f1 -d' ' | cut -f2 -d'=' 
    
    Your output may resemble the following example:
    /boot/vmlinuz-5.4.0-77-generic 
    

    b. Run the following command to find the kernel metapackage that corresponds to that boot image:

    dpkg -S /boot/vmlinuz-5.4.0-77-generic | cut -f1 -d: 
    
    Your output may resemble the following example:
    linux-image-5.4.0-77-generic 
    

    c. Run the following command to trace the package-dependency chain, where $example represents the kernel metapackage:

    apt-cache --installed rdepends $example

    Run this command for each kernel metapackage name in the Reverse Depends value until you find the metapackage with an empty Reverse Depends value.

    Your output may resemble the following example:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    
    root@ubuntu:~# apt-cache --installed rdepends linux-image-5.4.0-77-generic
    linux-image-5.4.0-77-generic
    Reverse Depends:
      linux-image-virtual
    
    root@ubuntu:~# apt-cache --installed rdepends linux-image-virtual
    linux-image-virtual
    Reverse Depends:
      linux-virtual
      linux-virtual
    
    root@ubuntu:~# apt-cache --installed rdepends linux-virtual
    linux-virtual
    Reverse Depends:
  2. Check which quota_v2 module you must install for your server’s empty Reverse Depends kernel metapackage:

    Kernel metapackage quota_v2 package
    linux-aws linux-modules-extra-aws
    linux-aws-edge linux-modules-extra-aws-edge
    linux-aws-lts-20.04 linux-modules-extra-aws-lts-20.04
    linux-azure linux-modules-extra-azure
    linux-azure-cvm linux-modules-extra-azure-cvm
    linux-azure-edge linux-modules-extra-azure-edge
    linux-azure-fde linux-modules-extra-azure-fde
    linux-azure-lts-20.04 linux-modules-extra-azure-lts-20.04
    linux-gcp linux-modules-extra-gcp
    linux-gcp-edge linux-modules-extra-gcp-edge
    linux-gcp-lts-20.04 linux-modules-extra-gcp-lts-20.04
    linux-gke linux-modules-extra-gke
    linux-gke-5.4 linux-modules-extra-gke-5.4
    linux-gkeop linux-modules-extra-gkeop
    linux-gkeop-5.4 linux-modules-extra-gkeop-5.4
    linux-ibm linux-modules-extra-ibm
    linux-ibm-lts-20.04 linux-modules-extra-ibm-lts-20.04
    linux-virtual linux-image-extra-virtual
    linux-virtual-hwe-20.04 linux-image-extra-virtual-hwe-20.04
    linux-virtual-hwe-20.04-edge linux-image-extra-virtual-hwe-20.04-edge
  3. Use the following command to install the appropriate quota_v2 module for your server’s empty Reverse Depends kernel metapackage, where $example is the name of the appropriate quote_v2 module:

    apt install $example
    Note:
    You may also run the /usr/local/cpanel/scripts/fixquotas script to automatically install the appropriate quota_v2 packages for each kernel metapackage on your server.

  4. Reboot your server.

Additional Documentation