Restricting or tracking disk usage by using disk quotas

About disk quotas

Filer disk quotas restrict disk space and the number of files used by a user, a group, or a qtree. For information about how to create a qtree, refer to Chapter 12, "Qtree administration." This chapter discusses how to manage disk quotas by editing the /etc/quotas file.

Format of the quotas file

To set up disk quotas, create a quotas file in the /etc directory.


Note: Keep a record of your quotas file in a safe place and update it as you change it, in case you must do a restore without having access to the root volume.


Following is a sample quotas file:

#Quota Target       type                 disk     files
/vol/home/user/joe  user                 500M      10K
21                  group                750M      75K
/vol/eng/proj1      tree                 750M      75K
writers             group@/vol/eng/proj1 300M      50K
*                   user                 50M       10K

Note: If the quota is a tree quota, the field in the type column of the quotas file displays tree, not qtree.


Keep a record of your quotas file in a safe place and update it as you change it, in case you must do a restore without having access to the root volume.

Quota Target field

Specifies the user, group, or qtree on which you want to impose restrictions. You can assign more than one quota to a user or group, but only one quota to a qtree. The entries can be in any order.

Quota target for a user quota

You specify a user with one of the following targets:

The methods are equivalent, and inform the filer of the UID of the target. A file or directory is used only as the source of a UID; there are no quota implications for that file or directory. The UID of the user must not be 0.

Any file or subdirectory you use in the Quota Target field is referenced repeatedly throughout the life of the system, so if you use a path name, choose a path name that will last for as long as the user account remains on the system. For example, use a user's home directory for a user quota.

Quota target for a group quota

You specify a group with one of the following targets:

The methods are equivalent. A file or directory is used only as the source of a GID; there are no quota implications for that file or directory. The GID of the group must not be 0.

Quota target for a tree quota

To create a tree quota, use the quota qtree command to create a directory in the root directory of a volume. The quota target in the quotas file for a tree quota is the complete path name of this directory.

Quota target for default quotas

Use an asterisk (*) in the Quota Target field to specify a default for the user or group quotas. Defaults do not apply to tree quotas. The default value applies to the following users or groups:

To override a default for a specific user or group, specify a quota for that user or group.

Type field

You can enter one of the following values in the Type field to define the quota type:

Disk field

Specifies the maximum amount of disk space that the quota target can use. In this field, K is equivalent to 1,024 bytes, M means 2^20 bytes, and G means 2^30 bytes. If you omit the K, M, or G, the default is K.

If you want to track the disk usage but do not want to impose a disk usage limit on the quota target, enter a dash (-) in the disk field.


Note: Do not put a blank in the Disk field; it acts as white space. The filer regards the following entries as equivalent:

#Quota Target      type      disk      files
/export            tree                75K
/export            tree      75K	 

Files field

Specifies the maximum number of files that the quota target can use. Use K to indicate 1,024 files. For example, 75K means 76,800 files. Use M to mean 2^20 and G to mean 2^30. You can omit the K, M, or G. For example, if you enter 100, it means the maximum number of files is 100. A blank in this field means there is no restriction on the number of files that the quota target can use.

If you want to track the number of files but do not want to impose a limit on the number of files that can be used by the quota target, enter a dash (-) in the files field.

Sample quotas file

Following is a sample quotas file that includes different kinds of quotas:

#Quota Target         type                  disk      files
/vol/home/user/jdoe   user                  500M      10K
108                   user                  500M      10K
jsmith                user@/vol/rls         500M      10K
publications          group                 750M
/vol/home/eng         group@/vol/cad        750M      75K
/vol/cad/proj1        tree                  750M      75K
writers               group@/vol/cad/proj1  150M      
*                     user                   50M      15K
*                     user@/vol/cad/proj1    50M      10K
*                     group                 750M      85K
*                     group@/vol/cad/proj1  100M      75K
mhoward               user                  150M     100K
mhoward               user@/vol/cad/proj1    75M      75K
mfisher               user                   -        -

Any operation that creates files or writes to them must satisfy all applicable quotas. The following list describes the effects of the sample quotas file:

Both user and group quotas apply to the entire specified volume (or the root volume if no volume name is specified). This is true even if the quota target in the quotas file is specified in the form of a path name. For example, if the quota target for the user named jdoe is /vol/home/user/jdoe, the filer imposes the quotas on all files written by jdoe, not just the ones written to /vol/home/user/jdoe.

The quota command

The quotas file specifies what the restrictions are on users, groups, and trees. Whether these restrictions take effect depends on the quota command. The quota command enables you to do the following tasks:

Some of the information from quota commands is available through SNMP using the Network Appliance custom MIB. For more information about the MIB, refer to "About the Network Appliance custom MIB."

Enabling or disabling quotas

The quota on|off command enables or disables quotas for all volumes or a specific volume. Use the following syntax when using the command:

quotas [on|off] volume

Use the following command to enable quotas for a volume:

quota on volume

This command computes the disk usage of each quota target. The computation can take a few minutes to complete for a large number of quotas. To find out how much quota initialization the filer has completed, use the quota command without any arguments. For example:

quota
vol0: quotas are on.
vol1: quotas are initializing (24% done).
vol3: quotas are off.

Use the following command to disable quotas for a volume:

quota off volume

Because the filer remembers whether quotas are on or off even after it reboots, there is no need to add a quota command to /etc/rc.

Resizing quotas

The quota resize command updates active quotas without recalculating disk usage, and is faster than quota off followed by quota on. An active quota is one that appears in the output of the quota report command, discussed in "Displaying information about quotas."

You use the quota resize command after changing limits for a group or user. For example, jdoe has a disk quota of 500 MB, as shown in the following example.

#Quota Target         type         disk      files
/vol/home/user/jdoe   user        500M      10K
*                   user        10M      10K

Use the quota resize command to update the quota if jdoe's disk quota were increased, as shown in the following example:

#Quota Target         type         disk      files
/vol/home/user/jdoe   user        600M      10K
*                   user        10M      10K
How quota resize affects newly added quota targets

The quota resize command usually ignores newly added quota targets. For each entry that it skips, the quota resize command prints the following message:

quota resize: new entry on line n in /etc/quotas

where n is a line number.

The quota resize command does not ignore newly added quota targets in the following situation:

If a default quota applies to the creator of a file, an active quota record is created for the owner of the file. If a newly added quota target is the user or group that has an active quota record, the quota resize command does not ignore the newly added quota target. That is, if a user or group has written to a file that is under the control of a default quota, a newly created entry in the quotas file for this user or group takes effect after a quota resize command.

After you edit the quotas file, if you want to make sure that all entries take effect, enter the quota off command followed by the quota on command. In this way, all quotas listed in the file become active.

Creating an active quota for a quota target

You can use the quota resize command so that quotas can take effect on targets that have not created any files.

Because a quota becomes active when a quota target has written a file, you can make an entry in the quotas file an active quota by following these steps:

  1. Create a file.
  2. Change ownership of the file to the quota target.

Because the quota target now has an active quota record, you can enter the quota resize command, including the volume name, to make the quota entry go into effect. This procedure takes less time than executing the quota off command followed by the quota on command because only the newly active quota is recalculated.

Displaying information about quotas

The quota report command displays the current consumption of files and space for each quota target and for each user and group that is under quota restrictions.

For example, if a user quota is specified in the quotas file for a user named jdoe, the quota report shows how many files and how much disk space have been used by jdoe. The Quota Specifier column in the quota report shows the same information as the Quota Target column in the quotas file, with the following exception:

If a user or group is under default quota restrictions, quota report displays information about the user or group as if the user or group had an entry in the quotas file. In this case, the Quota Specifier column in the quota report is blank.

With a path argument, quota report displays information about all quotas that apply to the specified file.

Creating a user quota

Follow these steps to limit disk space used by a user named jdoe.
Step Action
1 Decide who should be limited by a disk quota. In this example, the user is the owner of /vol/home/user/jdoe. The filer restricts disk usage of files with the same UID as /vol/home/user/jdoe.
2 Add the following line to the quotas file:
/vol/home/user/jdoe  user  300M  20K
Substitute the values you want for 300M and 20K. You can also use the UID of jdoe or the name jdoe if you have set up a passwd file on the filer or the NIS database. If you want the restrictions to apply to a volume other than the root volume, for example, the home volume, enter the following line:
/vol/home/user/jdoe  user@/vol/home  300M  20K
Substitute the values you want for 300M and 20K.
3 Use the quota on command, including the volume name. For example, if quotas are already on for the home volume, enter the following commands:
quota off home
quota on home
Alternatively, if jdoe is already under quota restriction, for example, if his files were restricted by a default user quota, enter the following command so that the user quota you just created can take effect:
quota resize home

Creating a group quota

Follow these steps to limit disk space used by a group named service.
Step Action
1 Decide which group should be limited by a disk quota. In this example, the group is the owner of /vol/home/user/service. That is, the filer restricts disk usage of files with the same GID as /vol/home/group/service.
2 Add the following line to the quotas file:
/vol/home/group/service  group  700M  100K
Substitute the values you want for 700M and 100K. You can also use the GID of the group or the name of the group. If you want the restrictions to apply to a volume other than the root volume, for example, the home volume, enter the following line:
/vol/home/group/service  group@/vol/home  700M  100K
Substitute the values you want for 700M and 100K.
3 Use the quota on command. If quotas are already on for the home volume, enter the following commands:
quota off home
quota on home
Alternatively, if the service group is already under quota restriction, for example, if the group's files are already restricted by a default group quota, enter the following command so that the group quota you just created can take effect:
quota resize home

Removing quota restrictions

To remove quota restrictions, follow these steps.
Step Action
1 Remove the appropriate line or lines from the quotas file.
2 Use the quota off and quota on commands, including the volume name. For example, enter the following commands:
quota off home
quota on home

When quotas are exceeded

This section describes how the filer responds when quotas are exceeded and what users see on the client systems.

Messages displayed by the filer when quotas are exceeded

When it receives a write request, the filer first determines whether the file to be written is in a qtree. If the write would exceed the qtree quota, the filer logs the following error message:

tid tree_id: tree quota exceeded on volume_name

If the qtree is not full but the write would cause either the user or group quota to be exceeded, the filer logs one of the following errors:

uid user_id: disk quota exceeded
gid group_id: disk quota exceeded

where user_id is the user's UID and group_id is the group's GID.

To the client, the filer returns an "out of disk space" error to the NFS write request or a "disk full" error to the CIFS write request. The following sections describe how the clients notify the users about quotas being exceeded.

Messages displayed on NFS clients

If a write from an NFS client to a filer causes a quota to be exceeded, the user experience depends on the operating system version and the application.

If a UNIX client mounts a filer without the noquota option, the login program on the client checks to see whether the user has reached the disk quota and file quota each time the user tries to log in to the client. The client displays a message to alert the user before displaying the system prompt if a quota was reached. In the following example, a user reached the disk quota on the filer mounted as /t/toaster on a client named client2:

rlogin client2
You have mail.
Block limit reached on /t/toaster
client2%

Not all versions of UNIX perform the quota check as described in this section. Also, the exact message printed varies from one version to another.

If a write causes a quota to be exceeded, the error message seen by the user depends on the application. For example, on a SunOS 4.x client, if a user tries to save a file using vi when his or her disk quota is reached, the error message is

Disc quota exceeded [Warning - /t/toaster/home/jdoe/file1 is 
incomplete]
Messages displayed on CIFS clients

If a write from a CIFS client to a filer causes a quota to be exceeded, the user experience depends on the operating system and the application. Following are two examples:

Cannot write file filename 
Cannot create or replace filename: Cannot read from the source file 
or disk. 

Copyright © 1999, Network Appliance, Inc. All rights reserved.

Part No. 210-02334
File: quota1.htm
Last updated: 04/26/99 08:11:47