About Will H. Stewart Expertise I have passed the Sun Solaris 7 Certified Systems Admninstrator exams and have experience with Sun hardware:4C,3/80,SPARCstation 1,5, IPC,Ultra 1,2,5,E250,E450,220R,e3000,e3500,e6500,Enterprise 2,5,6, SparcServer20; DLT 7000,DDS 2,3. I also can answer questions on Solaris 2.51-8 on al the fundamental systems admin. tasks and DNS,BIND,NFS,NIS,NIS+,inetd,TCP/UDP/IP,sed,awk,Perl;iPlanet,Netscape ,Web Logic,Tango,Oracle & Apache web servers,Veritas Filesystem, Volume Manager & NetBackup as well as Legato Networker & Amanda.
Experience
Past/Present clients Harvard Graduate School of Design, Clark University, W.T.Chen Co. at The Volpe Transportation Center, HarvardNet.com,ExcelerateNow.com, GII.com, ZDEvents.com, APC Inc., J.Baker,Inc.,Digital Equipment Corp.,
Katharine Gibbs School,Blue Cross/Blue Shield-Mass.,BankBoston,CMGI,
Community College of Rhode Island,Dept. of Corrections-Mass.,AccuSoft Corp.
Expert: Will H. Stewart Date: 3/13/2001 Subject: quotas
Question How to implement user quotas in Solaris 7?
OS : Solaris 7
Hard Ware : Sparc / Intel
Please give me step by step proscess.
Thank You.
Answer From Solaris 7 Systems Administration Guide,Volume II,
Managing Quotas (Tasks):
Using quotas enable system administrators to control the size of UFS file systems by limiting 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.
Once they are in place, quotas can be changed to adjust the amount of disk space or number of inodes that users can consume. Additionally, quotas can be added or removed as system needs change. See Changing and Removing Quotas for instructions on changing quotas or the amount of time that quotas can be exceeded, disabling individual quotas, or removing quotas from file systems.
In addition, quota status can be monitored. 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 Quotas.
Soft Limits vs. Hard Limits
You can set both soft and hard limits. The system will not allow a user to exceed his or her hard limit.
However, a system administrator may set a soft limit (sometimes referred to as a quota) which can be temporarily exceeded by the user. The soft limit must be less than the hard limit.
Once the user exceeds the soft limit a timer begins. While the 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 gets 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 seven days.
The value of the timer is shown by the timeleft field in the repquota and quota commands.
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 timer is also exceeded (more than seven days), the user will not be able to allocate more disk blocks on that file system until his or her usage drops below the soft limit.
Difference Between Disk Block and File Limits
There are two resources that a file system provides to the user: blocks (for data) and inodes (for files).
Each file consumes one inode. File data is stored in data blocks (usually made of up 1 kilobyte blocks.)
Assuming there are no directories, it is possible for a user to exceed his or her inode quota without using any blocks by creating all empty files. It is also possible for a user to use only one inode yet exceed his or her block quota by simply creating one file large enough to consume all the data blocks in the user's quota.
Setting Up Quotas
You can set up quotas to limit the amount of disk space and number of inodes (roughly equivalent to the number of files) available to users. These quotas are activated automatically each time a file system is mounted. This section describes how to configure file systems for quotas, and how to set up
and activate quotas.
Setting up quotas involves these general steps:
1.A series of commands prepares a file system to accept quotas, ensuring that quotas will be enforced each time the system is rebooted and the file system is mounted. Entries must be added to the /etc/vfstab file, and a quotas file must be created in the top-level directory of the file system.
2.After a quota is created for one user, it can be copied as a prototype to set up other user quotas.
3.Before quotas are actually turned on, another command checks for consistency by comparing the proposed quotas with the current disk usage to make sure that there are no conflicts.
4.Finally, a command turns the quotas on for one or more entire file systems.
These steps ensure that quotas are automatically activated on a file system each time it is mounted.
For specific information about these procedures, see Setting Up Quotas Task Map.
Table 66 describes the commands you use to set up disk quotas.
Table 66 - Commands for Setting Up Quotas
Command
Enables You To ...
edquota(1M)
Set the hard and soft limits on the number of inodes and disk space for each
user.
quotacheck(1M) Examine each mounted UFS file system, comparing against information stored in the file system's disk quota file, and resolve inconsistencies.
quotaon(1M) Activate the quotas for the specified file systems.
quota(1M) Display user's quotas on mounted file systems to verify that quotas have been correctly set up.
Guidelines for Setting Up Quotas
Before you set up quotas, you need to determine how much space and how many inodes to allocate to each user. If you want to be sure 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. In environments where
not all users are likely to push their limits, you may 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.
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.
After you have configured UFS file systems for quotas and established quotas for each user, run the
quotacheck command to check consistency between current disk usage and quota files before you
actually turn quotas on. Also, if systems are rebooted infrequently, it is a good idea to periodically run
quotacheck.
The quotas you set up with edquota are not enforced until you turn them on by using the quotaon
command. If you have properly configured the quota files, quotas will be turned on automatically each
time a system is rebooted and the file system is mounted.
Setting Up Quotas Task Map
Table 67 - Setting Up Quotas Task Map
Task
Description
For Instructions, Go To
1. Configure a File
System for Quotas
Edit /etc/vfstab so that quotas are
activated each time the file system is
mounted, and create a quotas file.
How to Configure File
Systems for Quotas
2. Set Up Quotas for a User
Use the edquota command to create
disk and inode quotas for a single user
account.
How to Set Up Quotas for a User
3. Set Up Quotas for
Multiple Users
Optional. Use edquota to apply
prototype quotas to other user accounts.
How to Set Up Quotas for
Multiple Users
4. Check for
Consistency
Use the quotacheck command to
compare quotas to current disk usage
for consistency on one or more file
systems.
How to Check Quota
Consistency
5. Turn Quotas On
Use the quotaon command to initate
quotas on one or more file systems.
How to Turn Quotas On
How to Configure File Systems for Quotas
1.Become superuser.
2.Edit the /etc/vfstab file by using the editor of your choice. Add rq to the mount options
field for each UFS file system that will have quotas.
3.Exit the file, saving the changes.
4.Change directory to the top of the file system that will have quotas.
5.Create a file named quotas.
# touch quotas
6.Change permissions to read/write for root only.
# chmod 600 quotas
Examples--Configuring File Systems for Quotas
The following example from /etc/vfstab shows that the /export/home directory from the system
pluto is mounted as an NFS file system on the local system with quotas enabled.
#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 /etc/vfstab shows that the local (UFS)/work directory is
mounted with quotas enabled.
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#
2.Use the quota editor to create a temporary file containing one line of quota information for each
mounted UFS file system that has a quotas file in its top-level directory.
# edquota username
username
User for whom you want to set up quotas.
3.Change the number of 1-Kbyte disk blocks, both soft and hard, and the number of inodes, both
soft and hard, from 0 (the default) to the quotas you specify for each file system.
4.Exit the editor, saving your changes.
5.Verify the user's quota by using the quota command.
# quota -v username
-v
Display's user's quota information on all mounted file systems where quotas exist.
username
Specifies user name to view quota limits.
Examples--Setting Up 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 containing a quotas file in its top-level 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)
How to Set Up Quotas for Multiple Users
1.Become superuser.
2.Use the quota editor to apply the quotas you already established for a prototype user to the
additional users you specify.
# edquota -p prototype-user username ...
prototype-user
User name of the account for which you have set up quotas.
username ...
Specifies one or more user names of additional accounts.
Example--Setting Up Prototype Quotas for Multiple Users
The following example applies the quotas established for user bob to users mary and john.
# edquota -p bob mary john
How to Check Quota Consistency
Note:
To ensure accurate disk data, the file systems being checked should be quiescent when you
run the quotacheck command manually. The quotacheck command is run automatically
when a system is rebooted.
1.Become superuser.
2.Run a consistency check on UFS file systems. See the quotacheck.
# quotacheck [ -v ] -a | 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 a file system to check.
Example--Checking Quota Consistency
The following example checks 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)
How to Turn Quotas On
1.Become superuser.
2.Turn file system quotas on by using the quotaon command.
# quotaon [-v] -a | filesystem ...]
-v
(Optional) Verbose option.
-a
Turns quotas on for all file systems with an rq entry in the /etc/vfstab file.
filesystem ...
Turns quotas on for one or more file systems that you specify.
Example--Turning Quotas On
The following example turns quotas on for the file systems on the /dev/dsk/c0t4d0s2 and
/dev/dsk/c0t3d0s2 slices.
# quotaon -v /dev/dsk/c0t4d0s2 /dev/dsk/c0t3d0s2
/dev/dsk/c0t4d0s2: quotas turned on
/dev/dsk/c0t3d0s2: quotas turned on
Checking Quotas
After you have set up and turned on disk and inode quotas, you can check for users who exceed their
quotas. In addition, you can check quota information for entire file systems.
Table 68 describes the commands you use to check quotas.
Table 68 - Commands for Checking Quotas
Command
Task
quota(1M)
Display user quotas and current disk use, and information about users who are
exceeding their quotas.
repquota(1M)
Display quotas, files, and amount of space owned for specified file systems.
How to Check for Exceeded Quotas
You can display the quotas and disk use for individual users on file systems on which quotas have
been activated by using the quota command.
1.Become superuser.
2.Display user quotas for mounted file systems where quotas are enabled.
# quota [-v] username
-v
(Optional) Displays users' quotas on all mounted file systems that have quotas.
username
Is the login name or UID of a user's account.
Example--Checking for Exceeded Quotas
The following example shows that the user account identified by UID 301 has a quota of one Kbyte
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 time (in days) left on the quota timer.
How to Check Quotas on a File System
Display the quotas and disk use for all users on one or more file systems by using the repquota
command.
1.Become superuser.
2.Display all quotas for one or all file systems, even if there is no usage.
# repquota [-v] -a | filesystem
-v
(Optional) Reports on quotas for all users-even those who do not consume
resources. (Verbose mode).
-a
Reports on all file systems.
filesystem
(Reports on the specified file system.
Example--Checking 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
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
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 Quotas
You can change quotas to adjust the amount of disk space or number of inodes users can consume.
You can also remove quotas for individual users or from entire file systems as needed.
Table 69 describes the commands you use to change or remove quotas.
Table 69 - Commands for Changing and Removing Quotas
Command
Task
edquota(1M)
Change the hard and soft limits on the number of inodes or disk space for each
user. Also, change the soft quota time limit for each file system with a quota.
quotaoff(1M)
Turn off quotas for specified file systems.
How to Change the Soft Time Limit Default
Users can exceed the soft time limits for their quotas for one week, by default. This means that after
a week of repeated violations of the soft time limits of either disk space or inode quotas, the system
prevents users from using any more inodes or disk blocks.
You can change the length of time that users may exceed their disk space or inode quotas by using
the edquota command.
1.Become superuser.
2.Use the quota editor to create a temporary file containing soft time limits.
# edquota -t
3.Change the time limits from 0 (the default) to the time limits you specify by numbers and the
keywords month, week, day, hour, min, or sec.
4.Exit the editor, saving your changes.
Note:
This procedure doesn't affect current quota violators.
Examples--Changing the Soft Time Limit Default
The following example shows the contents of the temporary file opened by edquota on a system
where /export/home is the only mounted file system with quotas. The 0 (default) value 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 one week, and the time limit for exceeding the number of files has been
changed to ten days.
fs /export/home blocks time limit = 2 weeks, files time limit = 16 days
How to Change Quotas for a User
1.Become superuser.
2.Use the quota editor to open a temporary file containing one line for each mounted file system
that has a quotas file in its top-level directory.
# edquota username
username
User name whose quota will be modified.
Caution -
Although you can specify multiple users as arguments to the edquota command,
the information displayed does not show which user it belongs to, which could create
some confusion.
3.Enter the number of 1-Kbyte disk blocks, both soft and hard, and the number of inodes, both soft
and hard.
4.Exit the editor, saving your changes.
5.Verify that a user's quota has been correctly changed by using the quota command.
# quota -v username
-v
Displays user quota information on all mounted file systems with quotas enabled.
username
User name whose quota you want to check.
Examples--Changing 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 containing a quotas file in its top-level directory.
fs /files blocks (soft = 0, hard = 0) inodes (soft = 0, hard = 0)
The following example shows the same temporary file after quotas have been changed.
fs /files blocks (soft = 0, hard = 500) inodes (soft = 0, hard = 100)
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
How to Disable Quotas for a User
1.Become superuser.
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
username
User name whose quota will be disabled.
Caution -
Although you can specify multiple users as arguments to the edquota command,
the information displayed does not show which user it belongs with, which could create
some confusion.
3.Change the number of 1-Kbyte disk blocks, both soft and hard, and the number of inodes, both
soft and hard, to 0 (zero).
Note:
Be sure you change the values to zero. Do not delete the line from the text file.
4.Exit the editor, saving your changes.
5.Verify that you have disabled a user's quota by using the quota command.
# quota -v username
-v
Displays user quota information on all mounted file systems with quotas enabled.
username
User name (UID) whose quota you want to check.
Examples--Disabling 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 containing a quotas file in its top-level directory.
fs /files blocks (soft = 50, hard = 60) inodes (soft = 90, hard = 100)
The following example shows the same temporary file after quotas have been disabled.
fs /files blocks (soft = 0, hard = 0) inodes (soft = 0, hard = 10)
How to Turn Quotas Off
1.Become superuser.
2.Turn file system quotas off.
# quotaoff [ -v ] -a | filesystem ...
-v
(Optional) Verbose option.
-a
Turns quotas off for all file systems.
filesystem1, 2, 3 ...
Turns quotas off for one or more file systems you specify.
Example--Turning Quotas Off
The following example turns the quotas off for the /export/home file system.
# quotaoff -v /export/home
/export/home: quotas turned off