Quotas are used to limit a user’s or a group of users’ ability to consume disk space. This prevents a small group of users from monopolizing disk capacity and potentially interfering with other users or the entire system. Disk quotas are commonly used by Internet Service Providers (ISPs), by Web hosting companies, on FTP sites, and on corporate file servers to ensure continued availability of their systems.


Without quotas, one or more users can upload files on an FTP server and occupy all free space on a partition. Once the affected partition is full, other users are effectively denied upload access to the disk. This is also a reason to mount different filesystem directories on different partitions.


For example, if you only had partitions for your root (/) directory and swap space, someone uploading to yourcomputer could fill up all of the space in your root directory (/). Without at least a little free space in the root directory (/), your system could become unstable or even crash.



You have two ways to set quotas for users. You can limit users by inodes or by kilobyte-sized disk blocks. Every Linux file requires an inode. Therefore, you can limit users by the number of files or by absolute space. You can set up different quotas for different filesystems.



For example, you can set different quotas for users on the /home and /tmp directories if they are mounted on their own partitions.

Limits on disk blocks restrict the amount of disk space available to a user on your system. Older versions of Red Hat Linux included LinuxConf, which included a graphical tool to configure quotas.



Quota Settings in the Kernel

# grep CONFIG_QUOTA /boot/config-`uname -r`



CONFIG_QUOTA enables limits on usage; CONFIG_QUOTACTL is associated with disk quota manipulation.


# rpm -ql quota


As you can see for yourself, the quota package includes the following commands:


  • /sbin/quotaon /fs Enables quotas for the specified filesystem.
  • /sbin/quotaoff /fs Disables quota tracking.
  • /usr/sbin/edquota name Edits the quota settings for the specified username.Can also be used to set defaults or to copy quota settings from one user toanother.
  • /usr/bin/quota Allows users to see their current resource consumption and limits.
  • /usr/sbin/repquota Generates a report of disk consumption by all users for a quota-enabled filesystem.
  • /sbin/quotacheck Scans a filesystem for quota usage. Initializes the quota databases.


Quota Activation in /etc/fstab

the file /etc/fstab tells Linux which filesystems to mount during the boot process. You can include quota settings in /etc/fstab for users and/or groups.


Before you edit a key configuration file such as /etc/fstab, it’s a good idea to back it up and save it to any boot or rescue disks that you may have. If your changes lead to a catastrophic failure, you can boot your system from a rescue disk and then restore the original configuration file.


In this example, I add both user and group quotas to the /home directory filesystem:


#vi   /etc/fstab

/dev/sdb1  /home    ext3   exec,dev,suid,rw,usrquota,grpquota  1  2


Quota Management Commands


The next step is to create quota files. For user and group quotas, you’ll need the aquota .user and aquota.group files in the selected filesystem before you can activate actual quotas. You no longer need to create those files manually; onceyou’ve remounted the desired directory, the appropriate quotacheck command creates them automatically. For the /home directory described earlier, you’d use the following commands:


# mount  -o remount  /home

# quotacheck  -cugm  /home


  •  -c Performs a new scan.
  •  -v Performs a verbose scan.
  •  -u Scans for user quotas.
  •  -g Scans for group quotas.
  •  -m Remounts the scanned filesystem.




Once the commandis run, you should be able to find the aquota.user and aquota.group files in the configured directory.




Using edquota to Set Up Disk Quotas

To specify disk quotas, you need to run the edquota command. This edits the aquota .user or aquota.group file with the vi editor. In this example, pretend you have a user named sathish, and you want to restrict how much disk space she is allowed to use. You’d type the following command to edit sathish’s quota records:


# edquota -u sathish

Disk quotas for  user sathish (uid  501):

Filesystem    blocks     soft         hard           inodes       soft    hard

/dev/sdb1     22692  100000     120000           24             0       0



Set an  soft limit and a  hard limit for the user. We can see that sathish is currently using 22,692 blocks and has 24 files (inodes) on this partition. Each block takes up 1KB of space; thus user nancy’s files total approximately 22MB. In this example, we’ll show you how to set a limit so that sathish  does not take more than 100MB of space with her files


In addition, give user  sathish a seven-day grace period. If and when she exceeds the soft limit, she has that amount of time to get back under the soft limit. To set the grace period for all users, run the edquota -t command


edquota –t

Grace period before enforcing  soft limits   for the users:

Time   units   may be:days, hours, minutes, or seconds

Filesystem                     block grace period      inode grace period

/dev/sdb1                        7days                            7days






That is, a user may exceed the soft limit on either resource for up to

seven days. After that, further requests by that user to use files will be denied.


The edquota command allows you to use an already configured user’s quota as a template for new users


# edquota –up   sathish  arthar  sam  ben



You can also set up quotas on a per-group basis. To do this, simply run edquota with the -g group_name argument. Here, group_name would need to be a valid group as specified in the /etc/group file.



# edquota -g sathish




Automating Quota Settings

As an administrator, you’ll want to maintain any quotas that you create. For that purpose, it’s useful to run the aforementioned quotacheck command on a regular basis.


vi   /etc/crontab

0 2 * * 6 /sbin/quotacheck    –avug




Quota Reports

As an administrator, it can be useful to see reports on who is using the most disk space. You can generate reports on users, groups, or everybody on every partition. To view a report showing quota information for all users, run the repquota -a command.


# repquota -u /home



Alternatively, if you wanted to view quota information on user nancy, run the following quota command:


# quota -uv sathish



An individual user can check his own usage with the quota command, but only the administrative root user can examine the quotas for other users.