Disk quotas

Disk quotas can be implemented by a system administrator as a way to manage restrictions on storage for users or groups of users. They allow the administrator to balance storage resources so that it is possible to manage finite capacity in a suitable way. An example of disk quotas in use would be, for example, a web hosting provider that allocates a certain amount of disk storage space per customer, or to limit certain users from consuming the full resources of the file-system, thereby preventing the file-system filling up and starving other users or the system of storage. There are two types of restrictions that can be put in place, one is which controls the number of files/directories, and  which can restrict based on storage blocks (size). When set limits are reached, it is possible to notify the system administrator or user consuming the resources in question, informing them to take appropriate action.

Kernel
Kernel support is required for disk quotas, if support for journaled quotas is required, the option "Quota formats vfsv0 and vfsv1 support" also needs to be enabled.

fstab
To enable quotas, some configuration is required by editing and enabling  and/or  in the options for each file-system upon which quotas need to be managed. For journaled quota support, add the mount options. Additional information regarding and filesystem (quota) options can be found by referring to the  man page. Quotas are set and edited by the quota tools which manage configuration files located in the root of each file-system named, and for new quota version formats and ,  for older formats.

After has been edited accordingly, the file-systems need to be remounted. Repeat the following mount command example below for every file-system that has been edited and enabled for quotas.

Group quotas (local system)
It is possible to apply quotas to groups of users, if this is desired a group has to be present on the system to assign the quota to. This creates a new group quotagroup and adds two users to the group, assuming there are already users alice and bob. For creating new users and groups please refer to Complete_Handbook/Configuring_the_system and Knowledge_Base:Adding_a_user_to_a_group.

Creating the quota files
After has been edited, the quota files need to be created with the quotacheck command and the   or   option. The following command creates the quota files as neccessary for user and group quotas on the filesystem.

Enabling quotas
Gentoo provides an init script to run quotacheck and initialize quotas when the system starts. The file can be edited and customized to provide different parameters to the  and  commands if necessary.

After doing any customization to the file, it's time to start the quota system. The following commands start the quota init script and adds it to the runlevel to persist when the system reboots.

Checking if quotas are enabled
To make sure whether quotas are enabled or not, the following command can be executed.

Environment variables
?

Files
/etc/quotagrpadmins /etc/quotatab

Usage
(Explain how to use the package/software/tool/utility in this section.)

Invocation
The Linux quota tools contain several commands to create and manage filesystem quotas. The following are some basic examples of putting the tools to use.

Init scripts
Gentoo provides an init script to check quotas and turn quotas on and off. Using the Gentoo init scripts are preferred over using quotaon / quotaoff manually unless it's known what is really being done.

Starting quotas through the Gentoo init script

Stopping quotas through the Gentoo init script

repquota
Displaying summaries of quotas for filesystems

setquota
Setting disk quotas on the command line is accomplished with the command. From the man page the usage states     as parameters to be passed when setting quotas, these need to be balanced according to requirements. To unset a quota limit the value can be set at 0 (zero).

To calculate the amount of blocks per GB a command similar to the following can be used, replace 32 with the required GB for the quotas to be set if it's required to limit based on (size) usage.

Once the and  values have been decided, a quota can now be set. The following command sets a soft limit of 30GB, a hard limit of 32GB and removes inode limits for user alice on the file-system.

edquota
Editing user or group quotas is accomplished with the command, the user or group to be edited, and -a for all filesystems or specify the filesystem with the -f option. The following command will edit the quotas for user bob on the /home filesystem. The set EDITOR will be opened to begin editing quotas.

Changing the values allows placing soft or hard limits on the amount of blocks or inodes for user bob, exiting the EDITOR and saving the file will apply the specified quotas.

quotastats
Querying quota statistics

quotaon & quotaoff
Turning on filesystem quotas for all filesystems

Turning off filesystem quotas for all filesystems

quota
Displaying users disk usage and limits

Troubleshooting
(Troubleshoot issues in this section. Separate issues by best describing the error with a new section name. Remove if no issues are known.)

Issue 1
When X happens, Y is how you fix it.

Removal
(Explain how to properly remove the software. If this section needs more than an 'emerge -C' command each step should be explained in detail so that no trace of the software remains on the system.)

Turning off quotas
The quotas for each filesystem should be turned off before removal and removed from the runlevel.

Removing configuration
To clean up the system if quotas are not required any more perform thefollowing steps

Edit and remove quota options for filesystems

Remove the quota configuration files

External resources

 * (Link to external resources (outside the Wiki) using bullet points in this section. It is common for the information in this section to full sentences that are links.)
 * [Information on quotas from the ext4 wiki]