 |
» |
|
|
 |
This section describes the main steps for setting up and turning
on disk quotas. Step 1: Mount the File System |  |
Mount the file system for which you will use disk quotas.
For example, suppose you want to implement quotas on /home,
which is accessed via the device file /dev/vg00/lvol3.
This file system will have already been mounted at bootup if it
is listed in your /etc/fstab
file. If the system is not mounted, enter: mount /dev/vg00/lvol3 /home |
For detailed information about mounting file systems, see
Chapter 4, "Working with HP-UX File Systems" and mount(1M). Step 2: Create the quotas File |  |
Using the cpset
command, create an empty file named quotas
in the root directory (the directory at the uppermost level of your
file system). The file quotas
will contain, in binary form, the limits and usage statistics for
each user whose home directory is within the file system. For example,
to install the quotas
file for the /home
file system (/home
must be mounted), enter: cpset /dev/null /home/quotas 600 root bin |
In this example, /dev/null
specifies that the file created is empty, /home/quotas
specifies that the file quotas
is to be at the root of the file system mounted on /home,
and 600 root bin
is the mode, owner, and group of the file. For details, see cpset(1M). The file quotas
will contain file system usage information based on user ID numbers.
The quotas file
can become large if users on a file system have large user IDs (the
largest possible user ID is 60,000) because the quotas
file reserves space for the number of possible
users. This could result in a "sparse" file with wasted space if
there are only a few users. To control the size of the quotas
file, refrain from using large user IDs. This is not a concern if
you use SAM to add users because SAM selects the user IDs in order. Step 3: Set User Quotas |  |
Use the /usr/sbin/edquota
command to set, convert, and modify quotas of individual users.
The edquota utility
converts binary data from a quotas
file into a text representation, creates a temporary file, invokes
an editor, and converts the edited text back to binary form before
storing the data back to the quotas
file. By default, edquota
will invoke vi
if you have not specified an EDITOR
environment variable. For details, see edquota(1M). Defining Limits For Multiple Users To set uniform limits for users in a file system, create limits
for one or more initial users, then apply those limits to the remaining
users. For example, the following shows how to assign limits for
a typical user whose home directory is within the file system /home
and then implement those limits to other users. For this example,
assume these limits: a soft limit of 10,000 blocks, a hard limit
of 12,000 blocks, a soft limit of 250 files, and a hard limit of
300 files. Set the limits for a prototype user, patrick. Invoke the quota editor: To input the limits, type the following: fs /home blocks (soft = 10000, hard = 12000) inodes (soft = 250, hard = 300) |
There must be one such line for every file system with a quotas
file. Be sure to type the line as shown with the correct spacing
between items. Bad formatting and typographical errors may cause
incorrect setting of quotas. Save the file (saving the text file updates the
quotas file)
and exit the editor.
Apply the prototype user's limits to other users
of the /home
file system: edquota -p patrick alice ellis dallas |
This assigns the limits of the prototype user, patrick,
to the other users, alice,
ellis, and dallas.
Note that you can include more than one user on the command line.
Soft time limits specify how long users have to reduce the
numbers of blocks or the numbers of files below their soft limits.
You can set soft time limits with the -t
option of the /usr/sbin/edquota
command. Unlike space limits on files and blocks, time limits apply
uniformly to all users of a file system. For example, to edit the
quotas file and
set soft time limits of 10 days for file system blocks and 15 days
for files in the file system /home,
follow these steps: Invoke the quota editor: When you are in the editor, type this line: fs /home blocks time limit = 10.00 days,files time limit = 15.00 days |
Be sure to type the line as shown with the correct spacing
between items. Bad formatting and typographical errors may cause
incorrect setting of quotas. Save the file (saving the text file updates the
quotas file)
and exit the editor.
The default time limit for both file system blocks and files
is seven days. You can specify the default time limits by entering
zeros in fields where you would specify the limits. For example,
to implement default limits for the root
file system, enter this line: fs / blocks time limit = 0, files time limit = 0 |
Step 4: Turn On the Disk Quotas |  |
After setting up the disk quotas, you need to start them.
You can start them in the following ways: Turn on disk quotas when
rebooting If you want disk quotas to be turned on automatically when
the system starts up, add the quota
option to the file system entry in the /etc/fstab
file. For example, suppose you have this line in /etc/fstab
for the /home
file system: /dev/vg00/lvol3 /home hfs rw,suid 0 2 |
Modify the line to include the quota
option, separating the options with commas and no blank spaces: /dev/vg00/lvol3 /home hfs rw,suid,quota 0 2 |
The system will enable quotas
for this file system when the system reboots. Turn on disk quotas by mounting the file
system
Disk quotas can be turned on when you mount a file system
with the quota
option of the mount
command. To do this, you must first unmount and then re-mount the
file system. For example: mount -o quota /dev/vg00/lvol3 /home |
Note that if you have already added the quota
option to the /etc/fstab
file (see above), you do not need to specify the quota
option to the mount
command. Instead, simply specify one of the following commands: or After remounting the file system, you must run quotacheck
on the file system to update the quotas
file. See “Checking Consistency of File System
Usage Data ” later
in this chapter for information on quotacheck.
Turn on disk quotas using the
quotaon command If you want to enable quotas on a file system, but are unable
to unmount the file system (perhaps because it is being used), do
the following steps. (These steps will also work for the root (/)
file system.) Use the /usr/sbin/quotaon
command to turn on disk quotas for a mounted file system for which
disk quotas are set up, but not currently turned on. The file quotas
must exist in the root directory of the file system. For example,
issuing the command starts quotas
on the /home
file system. The -v
(verbose) option generates a message to the screen listing each
file system affected. This command has no effect on a file system
for which quotas are already turned on. You can also specify the -a
option, which turns on disk quotas for all mounted file systems
listed in the file /etc/fstab
that include the quota
option. See quotaon(1M) for more information. Check the file system for consistency. For example: quotacheck /dev/vg00/lvol3 |
See “Checking Consistency of File System
Usage Data ” later
in this chapter for a description of quotacheck.
|