Skip to main content
Engineering LibreTexts

04-F.13.4: Storage Issues - Quota Management

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Disk Quota

    This feature of Linux allows the system administrator to allocate a maximum amount of disk space a user or group may use. It can be flexible in its adherence to the rules assigned and is applied per filesystem.

    Set Up the filesystem

    Edit fstab to enable the quota mount option(s) on selected file systems, e.g.:

    pbmac@pbmac-server $ /etc/fstab
    /dev/sda3 /home ext4 defaults,usrquota 0 2

    To additionally enable the group quota mount option:

    pbmac@pbmac-server $ /etc/fstab
    /dev/sda3 /home ext4 defaults,usrquota,grpquota 0 2

    If supported by the kernel and file system it is recommended to use journaled quota instead:

    pbmac@pbmac-server $ /etc/fstab
    /dev/sda3 /home ext4 defaults,usrjquota=aquota.user,jqfmt=vfsv1 0 2

    Append to enable group quota.

    Remount the partition to apply the change:

     pbmac@pbmac-server # mount -vo remount /home

    Create Quota Index

    To create the quota index for /home:

     pbmac@pbmac-server # quotacheck -cum /home

    Append the -g parameter to also create a group index.

    To enable disk quotas for the desired file system:

    pbmac@pbmac-server # quotaon -v /home

    To disable disk quotas for the file system:

    pbmac@pbmac-server # quotaoff -v /home

    Enable Quota for user/group


    • To find out how many 1 kilobyte blocks there are for a partition use df command.
    • You may use an online bytes converter to calculate the correct amount of blocks.
    • The command setquota may be used as an alternative of edquota .

    Note: Block size is statically set to 1k regardless of filesystem block size.

    Quotas are configured using edquota (as the root user) that will be opened in the default configured text editor:

    pbmac@pbmac-server # edquota user
    Disk quotas for user  user  (uid 1000):
      Filesystem                   blocks       soft       hard     inodes     soft     hard
      /dev/sda3                        24          0          0          6        0        0
    blocks -   Indicates number of 1k blocks currently used by the user/group.
    soft -   Indicates max number of blocks for the user/group before a warning is issued and grace period countdown begins. If set to "0" (zero) then no limit is enforced.
    hard -   Indicates max number of blocks for the user/group can use. If maximum amount has been reached, no further disk space can be used. If set to "0" (zero) then no limit is enforced.
    inodes -   Indicates the current inodes amount used by the user/group.
    soft -   Indicates the soft inode limit for the user/group.
    hard -   Indicates the hard inode limit for the user/group.
    pbmac@pbmac-server # edquota ftpuser1
    Disk quotas for user ftpuser1 (uid  1000 ):
      Filesystem                   blocks       soft       hard     inodes     soft     hard
      /dev/sda3                        24    1000000    1048576          6        0        0

    In this case if ftpuser1 uses over 976MB of space a warning will be issued. If the hard limit of 1GB has been reached the user will be unable to write any more data.

    Warning: The hard limit applies to all files written by and for the respective user/group, including temporary files by started applications, which may crash at this point.

    Specify a Grace Period

    To give current users some time to reduce their file usage, a grace period can be configured. This specifies the allowed time a user/group can exceed their soft limit and while under their hard limit:

    pbmac@pbmac-server # edquota -t
    Grace period before enforcing soft limits for users:
    Time units may be: days, hours, minutes, or seconds
      Filesystem             Block grace period     Inode grace period
      /dev/sda3              7days                  7days

    The grace period can be set in seconds, minutes, hours, days, weeks or months.


    Shows all configured quotas:

    pbmac@pbmac-server # repquota -a

    Shows quotas on a specific partition:

    pbmac@pbmac-server # repquota  /home 

    Shows quotas that apply to a user/user group:

    pbmac@pbmac-server # quota -u  user 
    pbmac@pbmac-server # quota -g  group 

    Copy Quota Settings

    To one or several users. To copy quota settings from user1 to user2:

    pbmac@pbmac-server # edquota -p  user1   user2 

    To copy quota settings to several other users, append user3 user4 ...

    To groups

    To copy quota settings from group1 to group2:

    pbmac@pbmac-server # edquota -g -p  group1   group2 

    To All Users

    The idea is to modify the quota settings for one user and copy the setting to all other users. Set the quota for user1 and apply the quota to users with a UID greater than 999:

    pbmac@pbmac-server # edquota -p  user1  $(awk -F: '$3 > 999 {print $1}' /etc/passwd)

    Quota Warnings

    The command warnquota can be used to warn the users about their quota. Configuration is available in /etc/warnquota.conf.


    The command quotastats can be used to give more information about the current quota usage:

    pbmac@pbmac-server $ quotastats<
    Number of dquot lookups: 101289
    Number of dquot drops: 101271
    Number of still active inodes with quota : 18
    Number of dquot reads: 93
    Number of dquot writes: 2077
    Number of quotafile syncs: 134518740
    Number of dquot cache hits: 7391
    Number of allocated dquots: 90
    Number of free dquots: 2036
    Number of in use dquot entries (user/group): -1946

    Adapted from:
    "Disk quota" by Multiple contributors, ArchLinux is licensed under CC BY-SA 4.0

    04-F.13.4: Storage Issues - Quota Management is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?