AdvFS Guide to File System Administration: Chapter 3

## Chapter 3: Managing Quotas

- - -

Enabling quotas allows you to track and control the amount of physical storage that each user, group, or fileset consumes. AdvFS allows you to impose quotas and eliminates the slow reboot activities associated with them on UFS.

The AdvFS quota system is compatible with the Berkeley-style quotas of UFS. However, the AdvFS quota system differs in two ways. AdvFS:

- Differentiates between quota maintenance and quota enforcement. Quota information is always maintained, but enforcement can be activated and deactivated.
- Supports fileset quotas.

This chapter includes the following sections:

Introducing Quotas

- Quota Limits
- Grace Period
- Quota Files

- Users and Groups
- Filesets
- Relocating Quota Files

Initiating Quotas and Grace Periods

- User and Group Quotas

- Setting User Quotas
- Setting the User Grace Period
- Setting Group Quotas
- Setting the Group Grace Period

- Setting Quota Limits for Special Conditions
- Activating Quotas at System Startup
- Activating Quotas Manually
- Fileset Quotas

- Setting Fileset Quotas
- Setting the Fileset Grace Period
- Activating Fileset Quotas

Setting Quotas for Multiple Users, Groups, and Filesets

- Multiple Users and Groups

- Prototype User Example
- Prototype Group Example

- Multiple Filesets

Verifying File and Disk Space Usage

- Users and Groups

- Print the Tag and Full Path Name for Each File
- Summarize Fileset Ownership
- Display Disk Usage and Limits
- Verify Fileset Quota Consistency
- Summarize Quotas by Fileset

- Filesets

- Display Used and Available Disk Space
- Display File Domain Attributes
- Display Fileset Attributes

Deactivating Quotas

- Users and Groups
- Filesets

## Introducing Quotas

-

You can impose quotas in AdvFS to limit the number of blocks or the number of files that a user, a group of users, or a fileset can use. AdvFS user and group quotas are similar to UFS quotas. You can set a separate quota for each user or each group of users for each fileset.

Fileset quotas limit the amount of disk storage or the number of files by fileset. They restrict the space that a fileset itself can use. Fileset quotas are useful when a file domain contains multiple filesets. Without fileset quotas, any fileset can grab all of the disk space in the file domain.

For example, it is useful to set quotas on filesets that contain home directories such as `/usr/users` because these filesets can grow rapidly. Conversely, setting quota limits on the `/tmp` fileset is not recommended because this fileset is likely to fluctuate in size.

Note You must have root user privilege to set and edit quotas.

## Quota Limits

- -

Quotas can have two types of limits: hard and soft. A hard limit cannot be exceeded. No more space can be allocated or files created. A soft limit permits a period of time during which the limit can be exceeded.

Hard and soft limits can be set or changed by the root user at any time and take effect the next time quotas are activated. Hard and soft limits can be set for users, for groups, and for filesets.

## Grace Period

- -

Associated with each soft quota is a grace period. The grace period is the amount of time during which the soft limit can be exceeded. When the grace period expires, you cannot create new files or allocate any more disk space. Updating existing files may have unexpected results. To restart the grace period, you must delete files to fall below the soft limit.

The timer for the grace period starts when the user exceeds the soft limit. It is turned off and reset each time usage drops below the soft limit. If you change the grace period after the user has exceeded the soft limit, the old grace period stays in effect until usage drops below the limit.

Note that for each fileset, only one grace period can be set for all users and one grace period can be set for all groups. However, the grace periods set for disk usage and for the number of files do not need to be the same.

When soft limits are imposed, AdvFS sets a default grace period of 7 days. This period can be changed (see Initiating Quotas and Grace Periods). You can specify the grace period in days, hours, minutes, or seconds. You can also:

- Set the grace period to 0 days to impose the default grace period of 7 days.
- Set the grace period to 1 second to allow no grace period.

## Quota Files

- -

AdvFS creates quota files to track quotas, grace periods, and fileset usage. The data structure of these files is the same as that used by UFS to hold its quota information and is defined in `/usr/include/ufs/quota.h`. Quota files are maintained within the fileset but, unlike UFS, the user cannot delete or create them. Quota files are present in the fileset even if limits have not been established.

## Users and Groups

- -

AdvFS keeps user and group quota information in the root directory of the fileset in the `quota.user` and `quota.group` files. These files are created when the fileset is created and are indexed by user ID and group ID. Each quota file entry contains the following information: hard block limit, soft block limit, block usage, hard file limit, soft file limit, file usage, block grace period, and file grace period.

Quota files are sparse files; that is, there are holes in the file where no user IDs or group IDs fall. If you examine the size of the `quota.user` or `quota.group` file with the `ls` command, your file size may appear enormous. The command shows the space spanned by the whole file. For example:

    # ls -l quota.user

    -rw-r----- 1 root operator 294912 Jul20 08:50 quota.user

The `du` command shows how many blocks this file actually uses:

    # du -k quota.user
    16      quota.user

## Filesets

- -

AdvFS keeps fileset soft and hard limits in the structural information associated with the fileset. It contains the same information that the user and group quota files contain: hard block limit, soft block limit, hard file limit, and soft file limit. AdvFS uses the `quota.group` file to maintain the fileset grace period.

## Relocating Quota Files

- -

You can relocate the `quota.user` and `quota.group` files to subdirectories of the fileset. You can neither relocate them to other filesets nor delete them. The `/etc/fstab` file entry must be updated to include the path and name of the relocated file(s).

For example,to relocate the `quota.user` file, the following `/etc/fstab` entry will identify `quota.user` as `nquot` and point to its location in the `dir4` subdirectory under the `/mnt` mount point:

    userquota=/mnt/dir4/nquot

If the group quota file is not moved, the complete entry in the `/etc/fstab` file will now be:

`domain_1#fset /mnt advfs rw,userquota=/mnt/dir4/nquot,groupquota 0 2`

## Initiating Quotas and Grace Periods

- -

The following sections describe how to set and activate:

- User and group quotas and grace periods
- Fileset quotas and grace periods

## User and Group Quotas

- -

To establish user and group quotas for a fileset, follow these steps:

1. Modify the `/etc/fstab` file to have the correct mount options.
2. Mount the fileset to which the quotas apply.
3. Use the `edquota` command to set the quota limits.
4. Use the `quotaon` command to enable quota enforcement.

The `/etc/fstab` file must have the quota mount options for the fileset and the fileset must be mounted. The mount point options should include:

    advfs rw,userquota,groupquota 0 2

If you specify a group quota, it will apply to all users belonging to that group. Group quotas can take precedence over user quotas. If you specify a user quota that is larger than the group quota, it will have no effect because the group quota will take effect before the user quota is reached.

Use the `edquota` command to set the quotas for users and groups and again to change the grace period. Note that for each fileset, only one grace period can be set for all users and one grace period can be set for all groups. However, you do not have to set the same grace period for the number of blocks and for the number of files.

The `quotaon` and `quotaoff` commands enable and disable enforcement of the quotas you have set.

Follow these general steps to initiate user and group quotas and grace periods:

1. Add quota file mount point options to the `/etc/fstab` file.
2. Issue the `edquota` command with the `-u` flag to set user quotas or the `-g` flag to set group quotas.
3. When the user or group quota information is displayed, modify the values in the limits fields as needed Then, exit the editor, saving the changes.
4. To set user or group grace periods, issue the `edquota` command with the `-ut` flag for user or `-gt` flag for group.
5. When the grace period information is displayed, modify the days as needed. Then, exit the editor, saving the changes.

If quotas have already been activated for a fileset, the new limits become effective immediately. If quotas are not yet activated for a fileset, the new limits become effective as soon as quotas are activated.

Once you have set quotas for a single user, you can use the `edquota` command with the `-p` flag to create prototype quota files. You can then apply the prototype quota to other users you specify. See Setting Quotas for Multiple Users, Groups, and Filesets.

## Setting User Quotas

- -

The following example sets quotas for the user `user5`:

1. If they do not already exist, add quota mount-point options to the `/etc/fstab` file. Note that there can be no spaces in the list of options delimited by commas; that is, from `rw` through `groupquota`:

       domain_1#test1 /test1 advfs rw,userquota,groupquota 0 2

       domain_2#test3 /test3 advfs rw,userquota,groupquota 0 2

       domain_4#test4 /test4 advfs rw,userquota,groupquota 0 2

2. Issue the `edquota` command with the `-u` flag followed by the user name. If you specify more than one user name, the edits will affect all users named. The command creates a temporary file with an ASCII representation of the current quotas assigned to the named users and invokes an editor to allow you to modify the file:

       # edquota -u user5

       Quotas for user user5:

       /test1: blocks in use: 0, limits (soft = 0, hard = 0)

               inodes in use: 0, limits (soft = 0, hard = 0)

       /test3: blocks in use: 0, limits (soft = 0, hard = 0)

               inodes in use: 0, limits (soft = 0, hard = 0)

       /test4: blocks in use: 0, limits (soft = 0, hard = 0)

               inodes in use: 0, limits (soft = 0, hard = 0)

The values for `blocks in use` and `inodes in use` are the current block usage and the number of files for each fileset. You cannot change them. Soft and hard limits of 0 (zero) indicate that no limits have been set.

3. To change user quotas for `user5` for fileset `test3`, edit the file to enter the new limits for disk usage on the `blocks` line and enter the new limits for the number of files on the `inodes` line:

       /test3:blocks in use: 0, limits(soft=5000, hard=10000)

              inodes in use: 0, limits(soft= 100, hard=  200)

4. Exit the editor, saving the changes.

If quotas have already been activated for fileset `test3`, the new limits become effective immediately. If quotas are not yet activated for a fileset, the limits become effective as soon as quotas are activated.

## Setting the User Grace Period

- -

When you impose soft limits, you can set one grace period for all fileset users. If you do not specify a grace period, AdvFS defaults to a 7-day grace period. You can choose different grace periods for the number of blocks and for the number of files.

The following example sets the grace period for all users of fileset `test3`:

1. Run the `edquota` command with the user grace period flags. The command creates a temporary file with an ASCII representation of the current grace period and invokes an editor to allow you to modify the file:

    #edquota -ut

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

    Grace period before enforcing soft limits for users:

    /test1: block grace period: 0 days,file grace period: 0 days

    /test3: block grace period: 0 days,file grace period: 0 days

    /test4: block grace period: 0 days,file grace period: 0 days

Note that this display may be misleading. Having grace periods of 0 days, as this example shows, does not mean that there is no grace period. It means that the default (7 day) grace period is in effect. If you want to have no grace period, set the grace period to 1 second.

2. To set the user grace period for the number of blocks and for the number of files for `test3`, edit the file to change the existing grace period:

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

       Grace period before enforcing soft limits for users:

       /test1: block grace period: 0 days, file grace period: 0 days

       /test3: block grace period: 2 days, file grace period: 3 days

       /test4: block grace period: 0 days, file grace period: 0 days

3. Exit the editor, saving the changes.

If quotas are on, this grace period becomes effective immediately unless a user has already exceeded the soft limit for `test3`. In that case, the new grace period becomes effective for that user once the user drops below the soft limit.

## Setting Group Quotas

- -

The following example sets quotas on `test3` for the group `rsgusers`:

1. If they do not already exist, add quota mount-point options to the `/etc/fstab` file. Note that there can be no spaces in the list of options delimited by commas; that is, from `rw` through `groupquota`:

       domain_1#test1 /test1 advfs rw,userquota,groupquota 0 2

       domain_2#test3 /test3 advfs rw,userquota,groupquota 0 2

       domain_4#test4 /test4 advfs rw,userquota,groupquota 0 2

2. Issue the `edquota` command with the `-g` flag. If you specify more than one group name, the edits will affect all groups named. The command creates a temporary file with an ASCII representation of the current quotas assigned to the named groups and invokes an editor to allow you to modify the file:

       # edquota -g rsgusers

       Quotas for group rsgusers:

       /test1: blocks in use: 0, limits (soft=0, hard=0)

               inodes in use: 0, limits (soft=0, hard=0)

       /test3: blocks in use: 0, limits (soft=0, hard=0)

               inodes in use: 0, limits (soft=0, hard=0)

       /test4: blocks in use: 0, limits (soft=0, hard=0)

               inodes in use: 0, limits (soft=0, hard=0)

   The values for `blocks in use` and `inodes in use` are the current block usage and the number of files for each fileset. You cannot change them. Soft and hard limits of 0 (zero) indicate that no limits have been set.

3. To change the group quotas for `test3`, edit the file to enter the new limits for disk usage on the `blocks` line and enter the new limits for the number of files on the `inodes` line:

       /test3: blocks in use:0,limits(soft=60000, hard=80000)

               inodes in use:0,limits(soft= 6000, hard= 8000)

4. Exit the editor, saving the changes.

If quotas have already been activated for fileset `test3`, these limits become effective immediately. If quotas are not yet activated for `test3`, these limits become effective as soon as quotas are activated.

## Setting the Group Grace Period

- -

When you impose soft limits, you can set one grace period per fileset for all groups. If you do not specify a grace period, the grace period remains the AdvFS default of 7 days. You can set different grace periods for the number of blocks and for the number of files.

The following example sets the grace period for all groups for fileset `test3`:

1. Run the `edquota` command with the group grace period flags. The command creates a temporary file with an ASCII representation of the current grace period and invokes an editor to allow you to modify the file:

       # edquota -gt

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

       Grace period before enforcing soft limits for groups:

       /test1: block grace period: 0 days,file grace period: 0 days

       /test3: block grace period: 0 days,file grace period: 0 days

       /test4: block grace period: 0 days,file grace period: 0 days

   Note that this display may be misleading. Having grace periods of 0 days, as this example shows, does not mean that there is no grace period. It means that the default (7 day) grace period is in effect. If you wish to have no grace period, set the grace period to 1 second.

2. To set the group grace period for the number of blocks and for the number of files for `test3`, edit the file to change the existing grace period:

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

       Grace period before enforcing soft limits for groups:

       /test1: block grace period:   0 days, file grace period: 0 days

       /test3: block grace period: 12 hours, file grace period: 5 days

       /test4: block grace period:   0 days, file grace period: 0 days

3. Exit the editor, saving the changes.

If quotas are on, this grace period becomes effective immediately unless a group has already exceeded the soft limit for `test3`. In that case, the new grace period becomes effective for that group once the group drops below the soft limit.

## Setting Quota Limits for Special Conditions

- -

You can use the `edquota` command to modify existing quotas for special cases:

- Set the hard limit to 0 days to impose no quota limits. This is the default.
- Set the hard limit to 1 second to permit no disk space allocations.
- Set the soft limit to 1 second and the hard limit to 0 days to permit disk-space allocations on a temporary basis. These limits remain in effect until you unmount the fileset.

## Activating Quotas at System Startup

- -

You can automatically start user and group quota enforcement during system initialization by modifying the `/etc/rc.config` flag. Edit the `QUOTA_CONFIG` flag to read:

    QUOTA_CONFIG=YES

This entry causes the `/sbin/init.d` quota script `sbin/init.d` to run the `quotaon` and `quotacheck` commands.

Then, edit the `/etc/fstab` file entry to add `userquota` and `groupquota` to the mount point. Quota enforcement is enabled for the mounted fileset the next time and every time you reboot.

Note If you unmount a fileset when quota enforcement is active, you must explicitly reactivate quota enforcement with the `quotaon` command when you remount the fileset. This must be done even with the `QUOTA_CONFIG=YES` entry.

## Activating Quotas Manually

- -

If your system is running and you want to activate new quotas for a mounted fileset, you must run the `quotaon` command.

To establish new user or group quotas do the following:

1. Edit the `/etc/fstab` file entry for your fileset to add `userquota` and `groupquota` to the mount point.
2. Run the `edquota` command to enter the hard and soft limits and to enter the grace period.
3. Run the `quotaon` command to activate the quotas you have chosen.

If your system is set up to initialize quotas (see Activating Quotas at System Startup ), you do not need to run the `quotaon` command again unless you have unmounted your fileset. If you have initialized your system without quota enforcement, you must run the `quotaon` command to start enforcement each time you reboot.

The following example activates quotas for the filesets for which quota values were set in the previous sections:

    # quotaon -av
    /test1:  group quotas turned on
    /test1:  user quotas turned on
    /test3:  group quotas turned on
    /test3:  user quotas turned on
    /test4:  group quotas turned on
    /test4:  user quotas turned on

By default, both user and group quotas are affected by the `quotaon` and `quotaoff` commands. You can choose to enable quotas either for users (with the `-u` flag) or for groups (with the `-g` flag). You can also specify the filesets for which user or group quotas will be enforced. See Deactivating Quotas.

## Fileset Quotas

- -

Fileset quotas limit the number of files or the amount of disk space a fileset can use. Without fileset quotas imposed, a fileset has access to all of the available disk space in the file domain.

The fileset quotas are set with the `chfsets` command. You can set both soft and hard limits for the number of files and for the number of blocks that a fileset can use. Fileset grace periods are set with the `edquota` command. If you set no grace period, the grace period remains at the AdvFS default grace period of 7 days.

If fileset quotas are set, they are enabled whenever you mount the fileset.

## Setting Fileset Quotas

- -

Use the `chfsets` command to define fileset quota values. You can set a soft limit for the number of files (`-F` flag), a hard limit for the number of files (`-f` flag), a soft limit for block usage (`-B` flag), and a hard limit for block usage (`-b` flag). The command displays both the old and new limits.

The following example sets fileset quotas for the `set_1` fileset in `domain_2`. Note that unlike the quota commands, the `showfsets` command displays block usage in 512-byte blocks. If you wish to display kilobyte values, use the `-k` flag.

1. To display existing fileset quotas, use the `showfsets` command:

       # showfsets domain_2 set_1

       set_1

         Id : 2feff762.00034e3f.1.8001

         Clone is     : set_1_clone

         Files        : 7,     SLim= 0,    HLim= 0

         Blocks (512) : 118,   SLim= 0,    HLim= 0

         Quota Status      : user=on group=on

   Here `SLim` is the soft limit and `HLim` is the hard limit for the number of files (`Files`) and the current block usage (`Blocks`).

2. Use the `chfsets` command to set the quotas. Note that the arguments for block usage for the `chfsets` command are in units of 1 kilobyte, not 512 bytes as shown by the `showfsets` command display.

       # chfsets -F 10000 -f 20000 -B 250000 -b 500000 domain_2 set_1

       set_1

         Id : 2feff762.00034e3f.1.8001

         File H Limit  : 0 --> 20000

         Block H Limit : 0 --> 500000

         File S Limit  : 0 --> 10000

         Block S Limit : 0 --> 250000

   Here `File H Limit` is the hard limit for the number of files, `Block H Limit` is the hard limit for block usage, `File S Limit` is the soft limit for the number of files, and `Block S Limit` is the soft limit for block usage.

3. To verify the new fileset quotas, run the `showfsets` command again:

       # showfsets domain_2 set_1

       set_1

          Id                 : 2feff762.00034e3f.1.8001

          Clone is           : set_1_clone

          Files              :     7,     SLim=   10000,   HLim=     20000

          Blocks (512)       :   118,     SLim=  500000,   HLim= 1000000

          Quota Status       : user=on group=on

   Note The `showfsets` command shows the blocks in units of 512 bytes so they will appear twice as large as the values you input with the `chfsets` command. Use the `showfsets` command with the `-k` flag to display blocks in 1-kilobyte units.

## Setting the Fileset Grace Period

- -

Use the `edquota` command to change the grace period for which a fileset can exceed its soft limits. The default AdvFS grace period of 7 days remains in effect until you change it.

You can set only one grace period per fileset, but you can set different values for block usage and number of files. The grace period applies to all users and all groups. If the grace period is reset, the new grace period for the fileset takes effect immediately unless the fileset has already exceeded its soft limits. In that case, the new grace period becomes effective once the fileset drops below the soft limit.

The following example sets the grace period for the `set_1` fileset:

1. Run the `edquota` command with the grace period flags and the fileset name. The command creates a temporary file with an ASCII representation of the current grace period and invokes an editor to allow you to modify the file:

       # edquota -gt

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

       Grace period before enforcing soft limits for set_1:

       /test1: block grace period: 0 days,file grace period: 0 days

       /test3: block grace period: 0 days,file grace period: 0 days

       /test4: block grace period: 0 days,file grace period: 0 days

   Note that this display may be misleading. Having grace periods of 0 days, as this example shows, does not mean that there is no grace period. It means that the default (7 day) grace period is in effect. If you wish to have no grace period, set the grace period to 1 second.

2. To change the fileset grace period for the number of blocks and for the number of files, edit the file to change the existing grace period:

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

       Grace period before enforcing soft limits for set_1:

       /test1: block grace period: 0 days, file grace period: 0 days

       /test3: block grace period: 12 hours, file grace period: 5 days

       /test4: block grace period: 0 days, file grace period: 0 days

3. Exit the editor, saving the changes.

## Activating Fileset Quotas

- -

Running the `chfsets` command activates fileset quotas immediately. No further steps are needed. Fileset quotas are in effect whenever you mount the fileset.

## Setting Quotas for Multiple Users, Groups, and Filesets

- -

You can set quotas for more than one user, group, or fileset without accessing and entering values for each one individually. AdvFS allows you to modify quotas for a list of users, groups, or filesets with a single command.

No special procedure is needed to set grace periods for multiple filesets because for each fileset one grace period applies to all users, to all groups, or to all filesets in a file domain.

## Multiple Users and Groups

- -

You can use the `edquota` command with the `-p` flag to take an existing set of quotas and establish it as a prototype user or group quota. You can then apply the prototype to one or more users or groups.

For example, you can set up all student accounts to have the same disk usage quota. To do this, you would:

1. Establish one set of quotas with the desired limits for a single student using the `edquota` command.
2. Use the `edquota` command with the `-p` flag to apply the quotas set up for the first user to all students.
3. As students are added at a later date, you can use the `edquota -p` command to apply the prototype quota to new student users.

## Prototype User Example

- -

The following example sets up prototype-user quotas that are then used to modify the quotas for other users:

1. Set quotas for one user, `user5`:

       # edquota -u user5

       Quotas for user user5:

       /test1:blocks in use: 0,limits(soft= 20000,hard= 30000

              inodes in use: 0,limits(soft=   350,hard=   500)

       /test3:blocks in use: 1,limits(soft= 30000,hard= 40000)

              inodes in use: 4,limits(soft=   400,hard=   550)

       /test4:blocks in use: 2,limits(soft= 10000,hard= 20000)

              inodes in use: 1,limits(soft=   150,hard=   200)

       /test5:blocks in use: 2,limits(soft=100000,hard=150000)

              inodes in use:1,limits(soft=   5000,hard=  7000)

2. Create quotas for new users `user7`, `user8`, and `user9`, using the quotas from user `user5` as a prototype:

       # edquota -p user5 -u user7 user8 user9

3. To verify that the quotas were set, run the `edquota` command for `user7`:

       # edquota -u user7

       Quotas for user user7:

       /test1:blocks in use: 0,limits(soft= 20000,hard= 30000)

              inodes in use: 0,limits(soft=   350,hard=   500)

       /test3:blocks in use: 0,limits(soft= 30000,hard= 40000)

              inodes in use: 0,limits(soft=   400,hard=   550)

       /test4:blocks in use: 0,limits(soft= 10000,hard= 20000)

              inodes in use: 0,limits(soft=   150,hard=   200)

       /test5:blocks in use: 0,limits(soft=100000,hard=150000)

              inodes in use: 0,limits(soft=  5000,hard=  7000)

## Prototype Group Example

- -

The following example sets up prototype group quotas that are then used to modify the quotas for another group:

1. Set quotas for the group, `rsgusers`:

       # edquota -g rsgusers

       Quotas for group rsgusers:

       /test1:blocks in use:0,limits(soft=100000,hard=200000)

              inodes in use:0,limits(soft= 10000,hard= 20000)

       /test3:blocks in use:0,limits(soft=300000,hard=400000)

              inodes in use:0,limits(soft= 30000,hard=40000)

       /test4:blocks in use:0,limits(soft=500000,hard=600000)

              inodes in use:0,limits(soft= 50000,hard= 60000)

       /test5:blocks in use:0,limits(soft=350000,hard=450000)

              inodes in use:0,limits(soft= 35000,hard= 45000)

2. Create quotas for a new group, `rsgstudents`, using the quotas from group `rsgusers` as a prototype:

       # edquota -p rsgusers -g rsgstudents

3. To verify that the quotas were set, run the `edquota` command for `rsgstudents`:

       # edquota -g rsgstudents

       Quotas for group rsgstudents:

       /test1:blocks in use:0,limits(soft=100000,hard=200000)

              inodes in use:0,limits(soft= 10000,hard= 20000)

       /test3:blocks in use:0,limits(soft=300000,hard=400000)

              inodes in use:0,limits(soft= 30000,hard= 40000)

       /test4:blocks in use:0,limits(soft=500000,hard=600000)

              inodes in use:0,limits(soft= 50000,hard= 60000)

       /test5:blocks in use:0,limits(soft=350000,hard=450000)

              inodes in use:0,limits(soft= 35000,hard= 45000)

## Multiple Filesets

- -

You can set quota limits for multiple filesets by listing more than one fileset name when you run the `chfsets` command.

For example, to change the hard limits for the `data` and `data2` filesets in `test1_domain`, enter the names of both filesets after the `chfsets` command:

    # chfsets -b 1000 -f 200 test1_domain data data2
    data
            Id           : 2fdf591b.000855fa.2.8001
            File H Limit : 11 --> 200
            Block H Limit: 121 --> 1000
    data2
            Id           : 2fdf591b.000855fa.3.8001
            File H Limit : 50 --> 200
            Block H Limit: 200 --> 1000

See Setting Fileset Quotas for a description of the output parameters.

## Verifying File and Disk Space Usage

- -

You can monitor file and disk space usage even if quotas are not being enforced. If you are enforcing quotas, you can periodically verify your quota setup. The following commands allow you to examine file activity and quota limits for users, groups, and fileset quotas.

## Users and Groups

- -

You can display user and group quota information in a number of ways. If you are not the root user, you can display information only for your own files. The root user can display all user and all group quota information for all filesets.

The commands shown in Table 7 are useful for examining disk space and file usage for filesets for which user and group quotas are enforced. See the reference page for each command for details on using the commands.

Table 7 Disk Space Usage Information Commands

Command | Description
`ncheck` | Prints the tag and full path name for each file in the fileset
`quot` | Summarizes fileset ownership
`quota` | Displays disk usage and limits by user or group
`quotacheck` | Checks fileset quota consistency
`repquota` | Summarizes quotas for a fileset

## Print the Tag and Full Path Name for Each File

- -

The `ncheck` command lists files by tag (inode) number. By piping the output to the `sort` command, you can use the sorted output as input for the `quot` command to list all files and their owners. Use the following format to generate the listing:

    ncheck domain#fileset|sort + on|quot -n domain#fileset

## Summarize Fileset Ownership

- -

The `quot` command displays block usage and the number of files in the fileset that each user owns. If you do not specify a fileset, the command processes all filesets of type `ro` and `rw` that are listed in the `/etc/fstab` file.

In the following example, the `quot` command is issued with no options to display only blocks:

    # quot domain_1#set_1
    domain_1#set_1:
    34128   root
      816   user5

In the following example, the `quot` command is issued with the `-f` flag to display both blocks and files:

    # quot -f domain_1#set_1

    domain_1#set_1:
    34128     125   root
      816       9   user5

## Display Disk Usage and Limits

- -

The `quota` command displays the block usage, number of files, and quotas for a user. This command can be run by users to look at their own disk space usage or by the root user to look at system usage.

You can choose to display quota information for all filesets listed in the `/etc/fstab` file or for all mounted filesets. You can restrict your output to those files where usage is over the soft limit.

For each user, this command displays the block usage of the fileset, soft limit (`quota`), hard limit (`limit`), grace period, and number of files used. An asterisk (*) in a column means that that soft quota limit has been exceeded.

The following example shows quota information for the user `user5`:

    # quota -u user5
    Disk quotas for user user5 (uid 446):
    Filesystem blocks  quota   limit grace files quota limit  grace
             /     60    100     150           3    10    20
          /usr  11071*  5000   10000 24:40     2    20    40
        /test1    816  20000   30000           9   350   500
        /test2  22032  50000  200000           2  2000  4000
        /test3   2344  10000   15000         370  1000  2000
        /test4  18023* 10000   20000 7days     3   100   150
        /test5  32012* 20000   50000 7days     0  2000  3000

The following example shows quota information for the group `rsgusers`:

    # quota -g rsgusers
    Disk quotas for group rsgusers (gid 15):
    Filesystem blocks  quota   limit grace files quota limit  grace
             /    118    200     300           2    20    40
          /usr  23184* 10000   20000 7days     2    40    80
        /test1  36136 100000  200000         124 10000 20000
        /test2  44064 200000  400000           4  2000  4000
        /test3   3587  30000   60000         628  3000  5000
        /test4  51071 150000  300000           6  1050  1800
        /test5  61044 100000  200000           3 10000 20000

## Verify Fileset Quota Consistency

- -

The `quotacheck` command verifies that actual block use and number of files are consistent with the established limits. It examines user and group files, builds a table of current disk usage, and compares this table with that stored in the disk quota file. If any inconsistencies are detected, AdvFS updates both the quota file(s) and the current system copy.

If you do not enable quotas automatically at system startup, it is a good practice to run the `quotacheck` command when quotas are first enabled. To ensure accuracy, run this command when there is no activity on the system.

The `quotacheck` command only checks filesets that have the `userquota` or `groupquota` option specified in the `/etc/fstab` file. By default both user and group quotas are checked, but you can specify either by selecting the `-u` or `-g` flag.

The `quotacheck` command requires that filesets be mounted with quotas enabled. Select the `-v` flag (verbose) to display inconsistencies found and procedures performed during the checking process.

The following example shows a verbose check of the fileset `set_1` that displays no inconsistencies:

    # quotacheck -v domain_1#set_1
    *** Checking user and group quotas for domain_1#set_1 (/test1)

The following example checks all filesets that have quotas defined in the `/etc/fstab` file. In this example the `quotacheck` command fixes inconsistencies in `/usr`:

    # quotacheck -va
    *** Checking user and group quotas for /dev/rrz0g (/usr)
    *** Checking user and group quotas for domain_1#set_1 (/test1)
    /usr: root   fixed: inodes 3057 -> 3022 blocks 100616 -> 123440
    /usr: system fixed: inodes 2483 -> 2488 blocks 91721 -> 114568
    /usr: adm    fixed: inodes 280 -> 240   blocks 487 -> 464

In this display, `inodes` is the number of files and `blocks` is the block usage.

## Summarize Quotas by Fileset

- -

The `repquota` command displays the actual disk usage and quotas for the specified filesets. To be included in the summary, the fileset must have a quota entry in the `/etc/fstab` file. By default both user and group quotas are reported, but you can specify either by using the `-u` flag for user or the `-g` flag for group.

For each user or group, the `repquota` command prints the current number of files, the amount of space used, and the quota limits established with the `edquota` command.

The following example summarizes quotas for a single fileset mounted on `/test1`:

    # repquota -v /test1
    *** Report for user quotas on /test1 (domain_1#set_1)
                      Block limits              File limits
    User       used    soft    hard  grace  used  soft  hard  grace
    root  --  34088       0       0          123     0     0
    user5 --    816   20000   30000            9   350   500

The following example displays information for all filesets in `/etc/fstab` that have quotas defined. This example contains both UFS and AdvFS files:

    # repquota -va
    *** Report for group quotas on /usr (/dev/rz0g)
                      Block limits              File limits
    Group         used  soft  hard  grace   used  soft  hard  grace
    system   -- 114568     0     0          2488     0     0
    daemon   --    144     0     0             1     0     0
    uucp     --    801     0     0             8     0     0
    mem      --   1096     0     0            10     0     0
    bin      -- 108989     0     0          3219     0     0
    mail     --    209     0     0             2     0     0
    terminal --     56     0     0             2     0     0
    adm      --    464     0     0           240     0     0
    operator --    392     0     0             3     0     0
    211      --   6937     0     0            33     0     0
    *** Report for user quotas on /usr (/dev/rz0g)
                      Block limits              File limits
    User          used  soft  hard  grace   used  soft  hard  grace
    root     -- 123440     0     0          3022     0     0
    bi       -- 102534     0     0          2940     0     0
    uucp     --    729     0     0             7     0     0
    adm      --      1     0     0             1     0     0
    user5    --     15    18    24             1     0     0
    kraetsch --   6937     0     0            35     0     0
    *** Report for group quotas on /test1 (domain_1#set_1)
                      Block limits              File limits
    Group         used  soft  hard  grace   used  soft  hard  grace
    system   --  22816     0     0            50     0     0
    daemon   --  12088     0     0            82     0     0
    *** Report for user quotas on /test1 (domain_1#set_1)
                      Block limits              File limits
    User          used  soft  hard  grace   used  soft  hard  grace
    root     --  34088     0     0           123     0     0
    user5    --    816 20000 30000             9   350   500
    *** Report for group quotas on /test3 (domain_2#set_1)
                      Block limits              File limits
    Group        used   soft  hard  grace   used  soft  hard  grace
    system   --  1593      0     0             6     0     0
    *** Report for user quotas on /test3 (domain_2#set_1)
                      Block limits              File limits
    User         used   soft  hard  grace   used  soft  hard  grace
    root     --  1593      0     0             6     0     0

## Filesets

- -

You can also examine how system resources are being used by looking at fileset activity.

Table 8 commands are useful for examining disk space and file usage of filesets:

Table 8 Fileset Disk Usage Information Commands

Command | Description
`df` | Displays disk space used and available disk space for a fileset
`showfdmn` | Displays the attributes of a file domain
`showfsets` | Displays the attributes of filesets in a file domain

## Display Used and Available Disk Space

- -

The `df` command displays the disk space used and available for a fileset as follows:

- If a fileset quota has been set, the command displays the amount of space available for the fileset.
- When both soft and hard quota limits are set, the command calculates the disk space available using the soft limit.
- If there is less space in the domain than is allowed by the fileset quota, the command displays the actual space available in the file domain.
- If fileset quotas have not been established, the command displays the domain size; all unused space is available to each fileset.

The following example displays the amount of space available for `fileset_1`:

    # df /fileset_1
    Filesystem        512-blocks  Used Avail  Capacity  Mounted on
    test_domain#fileset1    1500  1750     0      117%  /fileset1

The `df` command calculates capacity using the soft limit for the amount of space available. Because the usage is over the soft limit, the capacity is determined by the actual space used (1750/1500) and appears as more than 100%.

AdvFS calculates each fileset capacity independently. If the domain has multiple filesets, all unused space is available for each fileset unless the space is limited by fileset quotas. Because the space is counted more than once, the `df` command displays the total capacity as more than 100%. In the following example, the filesets `domain_1#test3` and `domain_1#test4` each can use all of the available disk space from the volumes in `domain_1`:

    # df
    Filesystem   512-blocks     Used     Avail Capacity  Mounted on
    domain_1#test3  2000000   390820     98864    80%    /test3
    domain_1#test4  2000000   271580     98864    73%    /test4

## Display File Domain Attributes

- -

Although it does not specifically address filesets, the `showfdmn` command is useful for obtaining statistics to make decisions about filesets and their quotas. The command shows the attributes of a file domain and information about each volume in the domain. For single-volume or multivolume file domains, the command shows the total volume size, the total number of free blocks, and the total percentage of volume space currently allocated.

## Display Fileset Attributes

- -

The `showfsets` command with the `-q` flag shows file usage, hard and soft limits, and grace period information for the filesets in the specified domain. It shows the block usage, the block usage limit, the number of files, and the file limit. The correct information will be displayed only if the fileset is mounted.

The following example shows fileset information for the domain `test_domain`:

    # showfsets -q test_domain

                     Block (512) Limits       File Limits

       Fileset  BF  used soft hard grace  used soft hard grace

       fileset1 +-  1750 1500 2000 11:32    35  300  400

In this example, the plus sign (+) in the `BF` field means that the soft limit for block usage is exceeded. An asterisk (*) indicates that the hard limit has been reached.

## Deactivating Quotas

- -

You can turn off quota enforcement either temporarily or permanently. You can obtain file and disk space usage information regardless of whether you are enforcing quotas.

## Users and Groups

- -

The `quotaoff` command turns off quota enforcement until the `quotaon` command is run again either manually or through system initialization that turns quotas on.

The `umount` command turns off quotas before it unmounts a fileset. If you remount the fileset, you must run the `quotaon` command to enforce user and group quotas for the fileset.

If you want to permanently turn quotas off for a user or group, use the `edquota` command to set quota limits to 0 (zero). To prevent quotas from ever being activated for a fileset, run the `quotaoff` command. Then, remove the `userquota` and `groupquota` entries for the fileset in the `/etc/fstab` file.

## Filesets

- -

Use the `chfsets` command with the hard and soft limits set to 0 (zero) to deactivate quotas on a fileset.

- - - -

© Copyright Digital Equipment Corporation 1996
All rights reserved