System Administration Guide: Advanced Administration

Chapter 7 Managing UFS Quotas (Tasks)

This chapter describes how to set up and administer UFS quotas for disk space and inodes.

For information associated with managing UFS quotas, see the following:

For information about managing Oracle Solaris ZFS quotas, see Setting ZFS Quotas and Reservations in Oracle Solaris ZFS Administration Guide.

What Are UFS Quotas?

UFS uotas enable system administrators to control the size of file systems. Quotas limit the amount of disk space and the number of inodes, which roughly corresponds to the number of files, that individual users can acquire. For this reason, quotas are especially useful on the file systems where user home directories reside. As a rule, the public and /tmp file systems usually do not benefit significantly by establishing quotas.

Using UFS Quotas

Once quotas are in place, they can be changed to adjust the amount of disk space or the number of inodes that users can consume. Additionally, quotas can be added or removed as system needs change. For instructions on changing quotas or the amount of time that quotas can be exceeded, disabling individual quotas, or removing quotas from file systems, see Changing and Removing UFS Quotas.

In addition, quota status can be monitored. UFS quota commands enable administrators to display information about quotas on a file system, or search for users who have exceeded their quotas. For procedures that describe how to use these commands, see Checking UFS Quotas.

Setting Soft Limits and Hard Limits for UFS Quotas

You can set both soft limits and hard limits. The system does not allow a user to exceed his or her hard limit. However, a system administrator might set a soft limit, which the user can temporarily exceed. The soft limit must be less than the hard limit.

Once the user exceeds the soft limit, a quota timer begins. While the quota timer is ticking, the user is allowed to operate above the soft limit but cannot exceed the hard limit. Once the user goes below the soft limit, the timer is reset. However, if the user's usage remains above the soft limit when the timer expires, the soft limit is enforced as a hard limit. By default, the soft limit timer is set to seven days.

The timeleft field in the repquota and quota commands shows the value of the timer.

For example, let's say a user has a soft limit of 10,000 blocks and a hard limit of 12,000 blocks. If the user's block usage exceeds 10,000 blocks and the seven-day timer is also exceeded, the user cannot allocate more disk blocks on that file system until his or her usage drops below the soft limit.

The Difference Between Disk Block and File Limits

A file system provides two resources to the user, blocks for data and inodes for files. Each file consumes one inode. File data is stored in data blocks. Data blocks are usually made up of 1Kbyte blocks.

Assuming no directories exist, a user can exceed his or her inode quota by creating all empty files without using any blocks. A user can also use one inode, yet exceed his or her block quota, by creating one file that is large enough to consume all the data blocks in the user's quota.

Setting Up UFS Quotas

Setting up quotas involves these general steps:

  1. Ensuring that quotas are enforced each time the system is rebooted by adding a quota option to the /etc/vfstab file entries. Also, creating a quotas file in the top-level directory of the file system.

  2. After you create a quota for one use, copying the quota as a prototype to set up other user quotas.

  3. Before you turn quotas on, checking the consistency of the proposed quotas with the current disk usage to make sure that there are no conflicts.

  4. Turning on the quotas on for one or more file systems.

For specific information about these procedures, see Setting Up UFS Quotas (Task Map).

The following table describes the commands that you use to set up disk quotas.

Table 7–1 Commands for Setting Up UFS Quotas

Command 

Task 

Man Page 

edquota

Sets the hard limits and soft limits on the number of inodes and the amount of disk space for each user. 

edquota(1M)

quotacheck

Examines each mounted UFS file system, comparing the file system's current disk usage against information stored in the file system's disk quota file. Then, resolves inconsistencies. 

quotacheck(1M)

quotaon

Activates the quotas for the specified file systems. 

quotaon(1M)

quota

Displays users' UFS disk quotas on mounted file systems to verify that the quotas have been correctly set up. 

quota(1M)

Guidelines for Setting Up UFS Quotas

Before you set up UFS quotas, you need to determine how much disk space and how many inodes to allocate to each user. If you want to ensure that the total file system space is never exceeded, you can divide the total size of the file system between the number of users. For example, if three users share a 100-Mbyte slice and have equal disk space needs, you could allocate 33 Mbytes to each user.

In environments where not all users are likely to push their limits, you might want to set individual quotas so that they add up to more than the total size of the file system. For example, if three users share a 100-Mbyte slice, you could allocate 40 Mbytes to each user.

When you have established a quota for one user by using the edquota command, you can use this quota as a prototype to set the same quota for other users on the same file system.

Before you turn on the quotas, do the following:

The quotas you set up with the edquota command are not enforced until you turn them on by using the quotaon command. If you have properly configured the quota files, the quotas are turned on automatically each time a system is rebooted and the file system is mounted.

Setting Up UFS Quotas (Task Map)

Task 

Description 

For Instructions 

1. Configure a file system for quotas. 

Edit the /etc/vfstab file so that quotas are activated each time the file system is mounted. Also, create a quotas file.

How to Configure File Systems for UFS Quotas

2. Set up UFS quotas for a user. 

Use the edquota command to create disk quotas and inode quotas for a single user account.

How to Set Up UFS Quotas for a User

3. (Optional) Set up UFS quotas for multiple users. 

Use the edquota command to apply prototype quotas to other user accounts.

How to Set Up UFS Quotas for Multiple Users

4. Check for consistency. 

Use the quotacheck command to compare quotas to current disk usage for consistency across one or more file systems.

How to Check UFS Quota Consistency

5. Turn on UFS quotas. 

Use the quotaon command to initiate UFS quotas on one or more file systems.

How to Turn On UFS Quotas

ProcedureHow to Configure File Systems for UFS Quotas

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Edit the /etc/vfstab file and add rq to the mount options field for each UFS file system that will have quotas.

  3. Change directory to the root of the file system that will have quotas.

  4. Create a file named quotas.


    # touch quotas
    
  5. Change permissions to read/write for superuser access only.


    # chmod 600 quotas
    

Example 7–1 Configuring File Systems for UFS Quotas

The following /etc/vfstab example shows that the /export/home directory from the system pluto is mounted as an NFS file system on the local system. You can tell that quotas are enabled by the rq entry under the mount options column.


# device   device    mount     FS    fsck   mount   mount
# to mount       to fsck  point     type   pass  at boot options
# pluto:/export/home -   /export/home nfs    -     yes    rq

The following example line from the /etc/vfstab file shows that the local /work directory is mounted with quotas enabled, signified by the rq entry under the mount options column.


#device     device        mount  FS   fsck  mount    mount
#to mount         to fsck      point  type  pass  at boot options
#/dev/dsk/c0t4d0s0 /dev/rdsk/c0t4d0s0 /work ufs  3    yes     rq

See Also

ProcedureHow to Set Up UFS Quotas for a User

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Use the quota editor to create a temporary file that contains one line of quota information for each mounted UFS file system that has a quotas file in the file system's root directory.


    # edquota username
    

    where username is the user for whom you want to set up quotas.

  3. Change the number of 1-Kbyte disk blocks, both soft and hard, to the quotas that you specify for each file system.

  4. Change the number of inodes, both soft and hard, from the default of 0, to the quotas that you specify for each file system.

  5. Verify the user's UFS quota.


    # quota -v username
    
    -v

    Displays the user's quota information on all mounted file systems where quotas exist.

    username

    Specifies the user name to view quota limits.


Example 7–2 Setting Up UFS Quotas for a User

The following example shows the contents of the temporary file opened by edquota on a system where /files is the only mounted file system that contains a quotas file in the root directory.


fs /files blocks (soft = 0, hard = 0) inodes (soft = 0, hard = 0)

The following example shows the same line in the temporary file after quotas have been set up.


fs /files blocks (soft = 50, hard = 60) inodes (soft = 90, hard = 100)

ProcedureHow to Set Up UFS Quotas for Multiple Users

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Use the quota editor to apply the quotas you already established for a prototype user to the additional users that you specify.


    # edquota -p prototype-user username ...
    
    prototype-user

    Is the user name of the account for which you have set up quotas.

    username ...

    Specifies one or more user names of additional accounts. More than one user name is specified by separating each user name with a space.


Example 7–3 Setting Up Prototype UFS Quotas for Multiple Users

The following example shows how to apply the quotas established for user bob to users mary and john.


# edquota -p bob mary john

ProcedureHow to Check UFS Quota Consistency

The quotacheck command is run automatically when a system is rebooted. You generally do not have to run the quotacheck command on an empty file system with quotas. However, if you are setting up quotas on a file system with existing files, you need to run the quotacheck command to synchronize the quota database with the files or inodes that already exist in the file system.

Also, keep in mind that running the quotacheck command on large file systems can be time-consuming.


Note –

To ensure accurate disk data, the file systems being checked should be quiescent when you manually run the quotacheck command.


  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Run a consistency check on UFS file systems.


    # quotacheck [-va] filesystem 
    
    -v

    (Optional) Identifies the disk quotas for each user on a particular file system.

    -a

    Checks all file systems with an rq entry in the /etc/vfstab file.

    filesystem

    Specifies the file system to check.

    See the quotacheck(1M) man page for more information.


Example 7–4 Checking UFS Quota Consistency

The following example shows how to check quotas for the /export/home file system on the /dev/rdsk/c0t0d0s7 slice. The /export/home file system is the only file system with an rq entry in the /etc/vfstab file.


# quotacheck -va
*** Checking quotas for /dev/rdsk/c0t0d0s7 (/export/home)

ProcedureHow to Turn On UFS Quotas

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Turn on file system quotas.


    # quotaon [-v] -a filesystem ...
    
    -v

    Displays a message for each file system after quotas are turned on.

    -a

    Turns on quotas for all file systems with an rq entry in the /etc/vfstab file.

    filesystem ...

    Turns on quotas for one or more file systems that you specify. More than one file system is specified by separating each file system name with a space.


Example 7–5 Turning On UFS Quotas

The following example shows how to turn quotas on for the file systems on the /dev/dsk/c0t4d0s7 and /dev/dsk/c0t3d0s7 slices.


# quotaon -v /dev/dsk/c0t4d0s7 /dev/dsk/c0t3d0s7
/dev/dsk/c0t4d0s7: quotas turned on
/dev/dsk/c0t3d0s7: quotas turned on

Maintaining UFS Quotas (Task Map)

Task 

Description 

For Instructions 

Check for exceeded UFS quotas. 

Display the UFS quotas and disk use for individual users on file systems on which UFS quotas have been activated by using the quota command.

How to Check for Exceeded UFS Quotas

Check for UFS quotas on a file system. 

Display the UFS quotas and disk use for all users on one or more file systems by using the repquota command.

How to Check UFS Quotas on a File System

Change the soft limit default. 

Change the length of time that users can exceed their disk space quotas or inode quotas by using the edquota command.

How to Change the Soft Limit Default

Change UFS quotas for a user. 

Use the quota editor, edquota, to change quotas for an individual user.

How to Change UFS Quotas for a User

Disable UFS quotas for a user. 

Use the quota editor, edquota, to disable quotas for an individual user.

How to Disable UFS Quotas for a User

Turn off UFS quotas. 

Turn off UFS quotas by using the quotaoff command.

How to Turn Off UFS Quotas

Checking UFS Quotas

After you have set up and turned on UFS disk quotas and inode quotas, you can check for users who exceed their quotas. In addition, you can check quota information for entire file systems.

The following table describes the commands that you use to check quotas.

Table 7–2 Commands for Checking UFS Quotas

Command 

Task 

quota(1M)

Displays user quotas and current disk use, and information about users who are exceeding their quotas 

repquota(1M)

Displays quotas, files, and the amount of space that is owned for specified file systems 

ProcedureHow to Check for Exceeded UFS Quotas

You can display the UFS quotas and disk use for individual users on file systems on which quotas have been activated by using the quota command.

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Display user quotas for mounted file systems where quotas are enabled.


    # quota [-v] username
    
    -v

    Displays one or more users' quotas on all mounted file systems that have quotas.

    username

    Is the login name or UID of a user's account.


Example 7–6 Checking for Exceeded UFS Quotas

The following example shows that the user account identified by UID 301 has one 1–Kbyte quota but has not used any disk space.


# quota -v 301
Disk quotas for bob (uid 301):
Filesystem  usage  quota limit timeleft files quota  limit timeleft
/export/home   0      1     2             0      2      3
Filesystem

Is the mount point for the file system.

usage

Is the current block usage.

quota

Is the soft-block limit.

limit

Is the hard-block limit.

timeleft

Is the amount of time, in days, left on the quota timer.

files

Is the current inode usage.

quota

Is the soft-inode limit.

limit

Is the hard-inode limit.

timeleft

Is the amount of time, in days, left on the quota timer.


ProcedureHow to Check UFS Quotas on a File System

Display the UFS quotas and disk use for all users on one or more file systems by using the repquota command.

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Display all UFS quotas for one or more file systems, even if there is no usage.


    # repquota [-v]  -a filesystem
    
    -v

    Reports on UFS quotas for all users, even those users who do not consume resources.

    -a

    Reports on all file systems.

    filesystem

    Reports on the specified file system.


Example 7–7 Checking UFS Quotas on a File System

The following example shows output from the repquota command on a system that has quotas enabled on only one file system (/export/home).


# repquota -va
/dev/dsk/c0t3d0s7 (/export/home):
                  Block limits              File limits
User      used   soft   hard  timeleft  used  soft   hard  timeleft
#301  --            0      1   2.0 days         0      2      3  
#341  --    57     50     60   7.0 days  2      90    100  
Block limits

Definition

used

Is the current block usage.

soft

Is the soft-block limit.

hard

Is the hard-block limit.

timeleft

Is the amount of time, in days, left on the quota timer.

File limits

Is the definition of the file limits.

used

Is the current inode usage.

soft

Is the soft-inode limit.

hard

Is the hard-inode limit.

timeleft

Is the amount of time, in days, left on the quota timer.


Changing and Removing UFS Quotas

You can change quotas to adjust the amount of disk space or the number of inodes that users can consume. You can also remove quotas, for individual users or from entire file systems, as needed.

The following table describes the commands that you use to change quotas or to remove quotas.

Table 7–3 Commands for Changing and Removing UFS Quotas

Command 

Man Page 

Description 

edquota

edquota(1M)

Changes the hard limits and soft limits on the number of inodes or amount of disk space for each user. Also, changes the soft limit for each file system with a quota.  

quotaoff

quotaon(1M)

Turns off quotas for specified file systems. 

ProcedureHow to Change the Soft Limit Default

By default, users can exceed the soft time limits for their UFS quotas for one week. So, after a week of repeated violations of the soft time limits of either disk space quotas or inode quotas, the system prevents users from using any more inodes or disk blocks.

You can change the length of time that users can exceed their disk space quotas or inode quotas by using the edquota command.

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Use the quota editor to create a temporary file that contains soft time limits.


    # edquota -t
    

    where the -t option specifies the editing of the soft time limits for each file system.

  3. Change the time limits from 0 (the default) to the time limits that you specify. So, use numbers and the keywords month, week, day, hour, min, or sec.


    Note –

    This procedure does not affect current quota violators.



Example 7–8 Changing the Soft Limit Default

The following example shows the contents of the temporary file opened by the edquota command on a system where /export/home is the only mounted file system with quotas. The default value, 0, means that the default time limit of one week is used.


fs /export/home blocks time limit = 0 (default), files time limit = 0 (default)

The following example shows the same temporary file after the time limit for exceeding the blocks quota has been changed to 2 weeks. Also, the time limit for exceeding the number of files has been changed to 16 days.


fs /export/home blocks time limit = 2 weeks, files time limit = 16 days

ProcedureHow to Change UFS Quotas for a User

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Use the quota editor to open a temporary file that contains one line for each mounted file system that has a quotas file in the file system's root directory.


    # edquota username
    

    where username specifies the user name whose quota you want to change.


    Caution – Caution –

    You can specify multiple users as arguments to the edquota command. However, the user that this information belongs to, is not displayed. To avoid confusion, specify only one user name.


  3. Specify the number of 1-Kbyte disk blocks, both soft and hard, and the number of inodes, both soft and hard.

  4. Verify that a user's UFS quota has been correctly changed.


    # quota -v username
    
    -v

    Displays user UFS quota information on all mounted file systems with quotas enabled.

    username

    Specifies the user name whose quota you want to check.


Example 7–9 Changing UFS Quotas for a User

The following example shows the contents of the temporary file opened by the edquota command. This temporary file is opened on a system where /files is the only mounted file system containing a quotas file in the file system's root directory.


fs /files blocks (soft = 0, hard = 0) inodes (soft = 0, hard = 0)

The following output shows the same temporary file after quotas have been changed.


fs /files blocks (soft = 0, hard = 500) inodes (soft = 0, hard = 100)


Example 7–10 Verifying That Hard UFS Quotas Have Been Changed

The following example shows how to verify that the hard quotas for user smith have been changed to 500 1-Kbyte blocks, and 100 inodes.


# quota -v smith
Disk quotas for smith (uid 12):
Filesystem  usage  quota  limit  timeleft  files  quota  limit  timeleft
 
  /files     1       0     500              1       0     100

ProcedureHow to Disable UFS Quotas for a User

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Use the quota editor to create a temporary file containing one line for each mounted file system that has a quotas file in its top-level directory.


    # edquota username
    

    Where username specifies the user name whose quota you want to disable.


    Caution – Caution –

    You can specify multiple users as arguments to the edquota command. However, the user that this information belongs to, is not displayed. To avoid confusion, specify only one user name.


  3. Change the number of 1-Kbyte disk blocks, both soft and hard, to 0.

  4. Change the number of inodes, both soft and hard, to 0.


    Note –

    Ensure that you change the values to zero. Do not delete the line from the text file.


  5. Verify that you have disabled a user's UFS quota.


    # quota -v username
    
    -v

    Displays user UFS quota information on all mounted file systems with quotas enabled.

    username

    Specifies the user name (UID) whose UFS quota you want to check.


Example 7–11 Disabling UFS Quotas for a User

The following example shows the contents of the temporary file opened by the edquota command on a system where /files is the only mounted file system that contains a quotas file in the file system's root directory.


fs /files blocks (soft = 50, hard = 60) inodes (soft = 90, hard = 100)

The following example shows the same temporary file after UFS quotas have been disabled.


fs /files blocks (soft = 0, hard = 0) inodes (soft = 0, hard = 0)

ProcedureHow to Turn Off UFS Quotas

  1. Become superuser or assume an equivalent role.

    Roles contain authorizations and privileged commands. For more information about roles, see Configuring RBAC (Task Map) in System Administration Guide: Security Services.

  2. Turn off file system quotas.


    # quotaoff [-v] -a filesystem ...
    
    -v

    Displays a message from each file system when UFS quotas are turned off.

    -a

    Turns off UFS quotas for all file systems.

    filesystem

    Turns off UFS quotas for one or more file systems that you specify. More than one file system is specified by separating each file system name with a space.


Example 7–12 Turning Off Quotas

The following example shows how to turn off the quotas for the /export/home file system.


# quotaoff -v /export/home
/export/home: quotas turned off