Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Servers and Workstations: Managing Systems and Workgroups > Chapter 6 Administering a System: Managing Disks and Files

Managing File Systems

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

This section presents information for managing file systems on a single system. The following topics are discussed:

Additional information is available for managing distributed file systems elsewhere; see:

For performance strategies helpful in making efficient use of file systems, see:

For advice about file system security, see:

Creating a File System

When creating either an HFS or JFS file system, you can use SAM or a sequence of HP-UX commands. Using SAM is quicker and simpler.

The following provides a checklist of subtasks for creating a file system which is useful primarily if you are not using SAM.

If you use SAM, you do not have to explicitly perform each distinct task below; rather, proceed from SAM’s “Disks and File Systems” area menu. SAM will perform all the necessary steps for you.

If you use HP-UX commands rather than SAM, many of the commands mentioned provide options not shown. Be sure to review the descriptions of the commands in the manpages to see the options available.

NOTE: Make sure the disk or disks containing the file system are connected to your computer and configured into HP-UX; refer to Configuring HP-UX for Peripherals if you need further information.

If you create a new file system of a type other than HFS, you might need to reconfigure the new type into the kernel. (Normally, JFS will already have been configured into the kernel as part of the default configuration. See “Reconfiguring the Kernel
(Prior to HP-UX 11i Version 2)”
if reconfiguration becomes necessary.)

Procedure 6-7 Creating a File System

You can create a file system either within a logical volume or on a non-LVM disk. However, using a logical volume is strongly encouraged.

If you decide not to use a logical volume when creating a file system, skip steps 1 through 4 below, which deal with logical volumes only. Refer to the book Disk and File Management Tasks on HP-UX for more information on creating a file system within a disk section or a whole disk.

  1. Estimate the Size Required for the Logical Volume

    To estimate the size needed for a logical volume that will contain a file system, see “Setting Up Logical Volumes for File Systems”.

  2. Determine If Sufficient Disk Space Is Available

    To determine if there is sufficient disk space available for the logical volume within its volume group, use the vgdisplay command to calculate this information. vgdisplay will output data on one or more volume groups, including the physical extent size (under PE Size (Mbytes)) and the number of available physical extents (under Free PE). By multiplying these two figures together, you will get the number of megabytes available within the volume group. See vgdisplay(1M) for more information.

  3. Add a Disk to a Volume Group

    If there is not enough space within a volume group, you will need to add a disk to a volume group.

    NOTE: For information on configuring the disk to your system and determining the physical address of the disk, see Configuring HP-UX for Peripherals.

    To add a disk to an existing volume group, use pvcreate(1M) and vgextend(1M). You can also add a disk by creating a new volume group with pvcreate(1M) and vgcreate(1M).

  4. Create the Logical Volume

    Use lvcreate to create a logical volume of a certain size in the above volume group. See lvcreate(1M) for details.

  5. Create the New File System

    Create a file system using the newfs command. Note the use of the character device file. For example:

    newfs -F hfs /dev/vg02/rlvol1

    If you do not use the -F FStype option, by default, newfs creates a file system based on the content of your /etc/fstab file. If there is no entry for the file system in /etc/fstab, then the file system type is determined from the file /etc/default/fs. For information on additional options, see newfs(1M).

    When creating a JFS file system, file names will automatically be long.

    For HFS, use the -S or -L option to specify a file system with short or long file names, respectively. By default, the length of file system names will be consistent with those of the root file system. Short file names are 14 characters maximum. Long file names allow up to 255 characters. Generally, you use long file names for flexibility; files created on other systems that use long file names can be moved to your system without being renamed.

    NOTE: Floppy disk drives are installed on some HP-UX systems. Unlike virtually all HP hard disks, which are initialized before shipping, you need to initialize floppy-disk media using mediainit(1) on the character device file.

    If you decide to put your file system on a floppy disk, invoke the diskinfo command with the character device file to identify the model number of the floppy disk drive; for more information, see diskinfo(1M). Then use the model number as input to the newfs command. (Floppy disk drives do not support the use of LVM.)

    Once you have created a file system, you will need to mount it in order for users to access it.

Mounting File Systems

This section includes:

See also:

Overview

The process of incorporating a file system into the existing directory structure is known as mounting the file system. The file system can be on a disk or disks connected directly to your system, that is, a local file system, or it can be on a disk on a remote system (see “Importing a File System (HP-UX to HP-UX)”) and it can be on either a logical volume or a non-LVM disk.

Mounting a file system associates it with a directory in the existing file system tree. Prior to mounting, the files, although present on the disk, are not accessible to users; once mounted, the file system becomes accessible.

The directory in the existing file system where the file is attached is known as the mount point or mount directory for the new file system, and the files in the added file system become part of the existing file system hierarchy.

The mount point should be an empty subdirectory on the existing file system. If you mount a file system to a directory that already has files in it, those files will be hidden and inaccessible until you unmount the file system. If you try to mount the file system to a directory whose files are in use, the mount will fail.

You can either use SAM or HP-UX commands to mount file systems.

If you are using SAM, proceed from SAM’s “Disks and File Systems” area menu. You can perform the necessary tasks as part of creating your file system, as already described. For help in mounting files using SAM, see SAM’s online help; instructions for using HP-UX commands follow.

Mounting File Systems Using HP-UX Commands

The mount command attaches a file system, on either a non-LVM disk or a logical volume, to an existing directory.

You can also use the mountall command or mount -a to mount all file systems listed in the file /etc/fstab. (See mount(1M), mountall(1M) and fstab(4) for details.)

Mounting Local File Systems

To mount a local file system:

  1. Choose an empty directory to serve as the mount point for the file system. Use the mkdir command to create the directory if it does not already exist. For example, enter:

    mkdir /joe

  2. Mount the file system using the mount command. Use the block device file name of the file system followed by the name of the mount point, as arguments to the mount command.

    For example, enter

    mount /dev/vg01/lvol1 /joe

Refer to mount(1M) for details and examples.

NOTE: If you are not using logical volumes, run ioscan -fn -H hw_path to determine the block device file name to use.

You can use lssf to display the location associated with the device file and compare it with the actual hardware address of the disk. You can also use ioscan to display the devices connected to your system and their hardware path.

If the block device file does not exist, create it using insf or mksf.

See Configuring HP-UX for Peripherals, lssf(1M), ioscan(1M), insf(1M), and mksf(1M) for more information on these commands.

Mounting File Systems Automatically at Bootup

To mount a file system automatically at bootup, list it in the /etc/fstab file. See the entry for fstab(4) for details on creating /etc/fstab entries.

Solving Mounting Problems

Here are some typical problems that are sometimes encountered when mounting a file system and the actions to take to correct the problem. See also “Troubleshooting NFS”.

Table 6-5 Solving Mounting Problems

Problem

Solution

The mount fails and you get an error message indicating Device busy.

Make sure that another file system is not already mounted to the directory (only one file system can be mounted to a single mount point.) You will also get this message if the mount directory is being used as someone’s working directory or if a user has an open file within the mount directory. (You can use fuser(1M) to check who has an open file within the mount directory.)

The mount fails with the message No such file or directory.

  • The device associated with the device file you’re trying to mount doesn’t exist, is not physically attached, or is not in a “ready” state. If you have never mounted this device before, check your block device file name to be sure that it has the proper characteristics.

  • Verify that the local directory exists on the client. If it does not exist, create it using mkdir. For example:

    mkdir /opt/adobe

/etc/mnttab is out-of-date with kernel data structures.

Update /etc/mnttab using the mount command without any options.

You get an error indicating /etc/mnttab does not exist or that mount had an “interrupted system call” when you try to mount a file system.

/etc/mnttab is normally created, if it does not already exist, within /sbin/init.d/localmount when you boot up your computer. If you get one of these messages, /etc/mnttab does not exist. Recreate it using the mount command without any options.

On a T-class system, after adding many file systems to /etc/fstab and executing mount -a, you get a message including the words table is full.

See “Reconfiguring the Kernel
(Prior to HP-UX 11i Version 2)”
.

 

Unmounting File Systems

When you unmount a file system, you make it temporarily inaccessible. Unmounting does not remove the file system from the disk; you can make it accessible again by remounting it.

Mounted file systems are automatically unmounted upon executing the shutdown command. See “Unmounting File Systems Automatically at Shutdown ”.

You can use either SAM or HP-UX commands to unmount file systems at other times.

For help in unmounting file systems using SAM, use SAM’s online help.

If you do not use SAM to unmount a file system, you must use the umount command. Refer to umount(1M) for details. You can also use the umountall command to unmount all file systems (except the root file system) or umount -a to unmount all file systems listed in the file /etc/mnttab. (See umount(1M) and mnttab(4) for details.)

Unmounting NFS File Systems

You can use either SAM or the umount command to unmount file systems located on an NFS remote system.

If the server unmounts, the file system disappears from the client; if the client unmounts, this does not affect access to the file system on the server.

For information on unmounting NFS file systems using SAM, see SAM’s online help.

For information on configuring and troubleshooting NFS mounts, see “Sharing Files and Applications via NFS and ftp.

Unmounting File Systems Automatically at Shutdown

When you execute the shutdown command, the system attempts to unmount all of your mounted files systems except for the root file system which cannot be unmounted. For more information on shutdown, refer to “Shutting Down Systems”.

Solving Unmounting Problems

If umount fails to unmount a file system, check the following:

  • Are all files closed on the particular file system to be unmounted? Attempting to unmount a file system that has open files (or that contains a user’s current working directory) causes umount to fail with a Device busy message.

    For example,

    fuser -cu /work

    displays process IDs and users with open files in /work, and whether it is anyone’s working directory.

    To kill the processes, enter

    fuser -ku /work

    You can also use ps -ef to check for processes currently being executed and map fuser output to a specific process.

    See fuser(1M) and ps(1) for more information.

  • Are you attempting to unmount the root (/) file system? You cannot do this.

  • Are you attempting to unmount a file system that has had file system swap enabled on that disk using SAM or swapon? You cannot do this either. To solve this problem, you will need to remove the file system swap and reboot. To display file system swap, run swapinfo and look under the column labeled Type for designation fs. Any entry labeled as such is file system swap, which must be removed before you can unmount the file system. See swapinfo(1M) or “Adding, Modifying, or Removing File System Swap ” for more information.

CAUTION: Always unmount file systems contained on a mass storage device before removing the device from the system. Removing a device containing mounted file systems (for example, disconnecting or turning off the power to a disk, or removing a disk pack from a mass storage device) will likely corrupt the file systems.

Extending the Size of a File System Within a Logical Volume

A file system can be expanded up to a maximum size of 128GB, except one designated for root or boot which is limited to either 2 or 4GB.

NOTE: If you are still using non-LVM disks, you should consider converting to logical volumes. Logical volumes allow you greater flexibility in dividing up and managing disk space.

Using SAM

If you use SAM to increase the size of a logical volume that contains a file system, SAM automatically runs extendfs for you. As a result, you can no longer safely reduce the size of a logical volume containing a file system once you extend it using SAM.

Using HP-UX Commands

When using lvextend to increase the size of the logical volume container, this does not automatically increase the size of its contents. When you first create a file system within a logical volume, the file system assumes the same size as the logical volume. If you later increase the size of the logical volume using the lvextend command, the file system within does not know that its container has been enlarged. You must explicitly tell it this using the extendfs command. (If you are using JFS, see the Note below.)

NOTE: If you are using JFS and you have the HP OnLineJFS product, run the fsadm command to increase the size of a file system. See fsadm_vxfs(1M) for information on syntax. Further information is also available in Disk and File Management Tasks on HP-UX.

If you are using JFS but do not have HP OnLineJFS, use the steps below, or, back up the file system and create a larger file system using newfs.

Sample Procedure to Increase the Size of a Logical Volume

Suppose the current size of a logical volume is 1024 MB (1 gigabyte). Assuming the users of the file system within this logical volume have consumed 95% of its current space and a new project is being added to their work load, the file system will need to be enlarged. To increase the size of the file system, follow these steps:

  1. Unmount the file system.

    umount /dev/vg01/lvol1
  2. Increase the size of the logical volume.

    /usr/sbin/lvextend -L 1200 /dev/vg01/lvol1

    Note that the -L 1200 represents the new logical volume size in MB, not the increment in size.

  3. Increase the file system capacity to the same size as the logical volume. Notice the use of the character device file name.

    extendfs /dev/vg01/rlvol1
  4. Remount the file system.

    mount /dev/vg01/lvol1 /project
  5. Run bdf to confirm that the file system capacity has been increased.

Copying a File System Across Devices

Suppose you want to copy a file system from one disk (or disk section) to another, or from one disk or logical volume to another logical volume. For example, you might need to copy a file system to a larger area. If so, here are the steps to follow:

  1. If you will be overwriting the existing file system, back up files from the current device onto tape.

  2. If necessary, add the new disk or create the new logical volume.

  3. Create one or more new file systems on your new disk, section, or logical volume.

  4. Create/Edit an entry in the /etc/fstab file to automatically mount each file system at bootup.

  5. Mount each new file system.

  6. If you backed up the files, restore them to the file systems on the new device. Otherwise, merely copy all files on the old file system to the new device using cp or cpio.

Dealing with File System Corruption

Hardware failures, accidental power loss, or improper shutdown procedures can cause corruption in otherwise reliable file systems.

CAUTION: To ensure file system integrity, always follow proper shutdown procedures as described in “Shutting Down Systems”.

Never take a system offline by merely shutting its power off or by disconnecting it.

Diagnosing a Corrupt File System

The following are symptomatic of a corrupt file system:

  • A file contains incorrect data (garbage).

  • A file has been truncated or has missing data.

  • Files disappear or change locations unexpectedly.

  • Error messages appear on a user’s terminal, the system console, or in the system log.

  • You are unable to change directories or list files.

  • The system fails to reboot, possibly as a result of one or more errors reported by the /sbin/bcheckrc script during bootup.

If you or other users cannot readily identify causes for the difficulties, check the file system for inconsistencies using fsck.

Locating and Correcting Corruption Using fsck

fsck, the file system checker, is the primary HP-UX tool for finding and correcting file system inconsistencies. fsck examines the HFS or JFS file system listed in /etc/fstab.

If the system fails, reboot the system and run fsck(1M). Additionally, if you suspect that a file system is corrupt, or to do periodic preventive maintenance, you should also check the file system.

Refer to fsck(1M), fsck_hfs(1M), and fsck_vxfs(1M) for more information.

Checking an HFS File System

To check an HFS file system, use the following procedure:

  1. Before running fsck, make sure that a lost+found directory is present and empty at the root for each file system you plan to examine. fsck places any problem files or directories it finds in lost+found.

    If lost+found is absent, rebuild it using mklost+found(1M).

  2. For mountable file systems, prepare to unmount the file system by terminating all processes running on it, closing any open files.

    For the root file system, execute shutdown (without -h or -r) to enter the single-user state. The root file system cannot be unmounted.

  3. Unmount the (mountable) file system using SAM or the umount command.

  4. Run fsck.

    NOTE: The -n or -N options run fsck in nondestructive mode, and are the safest options available. You can run them on a mounted file system as a precautionary measure when you suspect you might be having problems.

    The following text documents the traditional -p option in more detail.

    The -p option of fsck allows you to fix many file system problems, running noninteractively. (See fsck(1M) for information on syntax and options.) If fsck either finds no errors or finds correctable errors, it corrects any such errors and prints information about the file system it checked. If fsck encounters a problem it cannot correct while running with the -p option, it will terminate with an error message.

  5. Use the following table to determine what to do next based on three possible outcomes:

    Table 6-6 fsck Results

    If fsck reports...

    Proceed to...

    Then...

    No errors

    Step 6

    You are done

    Errors and corrects them all

    Step 7

    Step 10

    Any uncorrectable errors with an error message

    Step 8

    Step 9

     

  6. Check for other causes of the problem.

    If fsck runs without finding errors, the problem is not a corrupted file system. In this case, consider other possible causes of problems with files:

    • A user deleted, overwrote, moved, or truncated the file(s) in question.

    • A program/application deleted, overwrote, moved, or truncated the file(s).

    • The file system associated with a particular directory when a file was created might not be mounted to that directory at this time (if any are).

    • A file (or group of files) was placed in a directory that now has a file system mounted to it. The files that were in the directory before you mounted the current file system still exist, but won’t be accessible until you unmount the file system that is covering them.

    • The protection or ownership bits on the file prevent you from accessing it.

    Because your file system is not corrupt, do not continue with the remaining steps in this procedure.

  7. Restore any necessary files.

    Once fsck finds and corrects all errors it locates in the file system, you may assume that the file system is again structurally sound. If any necessary files were lost, restore them from a backup or from lost+found. Once fsck has repaired the damage, proceed to Step 10.

  8. Prepare to run fsck interactively.

    If fsck terminates without correcting all the errors it found, you must run fsck interactively.

    Before doing so, move any critical files on this file system that have not yet been backed up (and are still intact) to another file system or try saving them to tape.

    When you run fsck interactively, it may need to perform actions that could cause the loss of data or the removal of a file/file name (such as when two files claim ownership of the same data blocks). Because of this, any backups of this file system at this point are likely to fail. This is another reason you should back up your system regularly!

    IMPORTANT: Empty the lost+found directory before running fsck again.
  9. Run fsck interactively by reexecuting fsck without the -p or -P option.

    As fsck encounters errors, it will request permission to perform certain tasks. If you do not give fsck permission to perform the correction, it will bypass the operation, leaving the file system unrepaired.

    After running interactively, in many cases fsck will request you do a reboot -n. Failing to do so might re-corrupt your file system. (Note, do not use reboot -n for normal rebooting activities.)

  10. Examine files in the lost+found directory.

    Once fsck has repaired the file system, mount the file system and check its lost+found directory for any entries that might now be present. These are files, listed by inode number, that have lost their association with their original directories. Examine these files, determine their name, and return them to their proper location. To do this,

    • Use the file command to determine file type.

    • If they are ASCII text files, you can review them using cat or more to see what they contain.

    • If they are some other type, you will have to use a utility such as xd or od to examine their contents.

    • Run the commands what or strings to help you find the origin of your lost+found files.

Once you have returned the files in the lost+found directory to their proper locations, restore any files that are missing from your most recent backup.

IMPORTANT: The following message
CAN'T READ BLOCK ...

may indicate a media problem that mediainit(1) can resolve. Otherwise, hardware failure has probably occurred; in this case, contact your local sales and support office.

Checking a JFS File System

fsck checks a JFS file system by using an intent log to evaluate changes to the file system. The intent log records all pending changes to the file system structure; that is, all transactions the system intends to make to the file system prior to actually doing the changes. A “replay” of the intent log is very fast and may be no more time consuming for a large file system than a small one because it is dependent on file system activity rather than file system size. As a result, even in the event of a system failure, the system can be up and running again very quickly.

In cases of disk failure, scanning the JFS intent log is insufficient; in such instances, you will need to check the entire file system. Do this by using the -o full option of fsck. For further information, refer to fsck_vxfs(1M).

Differences between HFS and JFS File Checking

Although from an administrative perspective, using fsck to check and correct HFS and JFS file systems is similar, some important differences are summarized in Table 6-7 “HFS vs. JFS File Checking after System Failure ”.

Table 6-7 HFS vs. JFS File Checking after System Failure

Concern

HFS

JFS

What needs to be checked?

The entire file system. This can be time consuming. As the size of the file system increases, the time required for fsck will increase.

The intent log only. This may be no more time consuming for a large file system than a small one.

What assurance is there of file system integrity?

No assurance fsck can repair a file system after a crash, although it usually can; is sometimes unable to repair a file system that crashed before completing a file system operation. Even a repairable file system has no guarantee its structure will be preserved: fsck puts “orphan files” into the lost+found directory.

Complete assurance of file system integrity following a crash (excepting disk failure). JFS ensures any transaction pending when the system crashes will either be completed entirely or returned to its pre-transaction state.

What do I do in the event of a disk failure?

The file system must be scanned from beginning to end for inconsistencies, with no assurances of file system integrity.

As with HFS, the file system must be scanned from beginning to end for inconsistencies, with no assurances of file system integrity.

 

For more information on fsck, see Disk and File Management Tasks on HP-UX.

Replacing an Existing File System with a Smaller One

How to substitute a smaller file system for an existing larger one depends on the type of file system being used and whether or not you are using logical volumes.

If You Are Using JFS

If you have HP OnLineJFS, you can reduce the size of a file system using a single command (fsadm). (See fsadm_vxfs(1M) for syntax and also Disk and File Management Tasks on HP-UX for further information.)

If you do not have OnLineJFS, the steps are identical to those shown below for HFS and depend upon whether you are using logical volumes.

If You Are Not Using Logical Volumes

If an HFS file system is contained on a non-LVM disk, follow these steps to reduce its size:

  1. Back up the file system.

  2. Unmount the file system.

  3. Create the new smaller file system using newfs. Indicate the new smaller file system size using the -s size option of newfs.

  4. Re-mount the file system.

  5. Restore the backed up file system data to the newly created file system.

If You Are Using Logical Volumes

If an HFS file system is contained within a logical volume, the logical volume resembles a container with the file system as its contents.

Once a particular file system has been created, you cannot simply issue one command to reduce its size, as you can to extend the file system (described in “Extending the Size of a File System Within a Logical Volume ”). First, you must reduce the size of its logical volume. However, reducing the size of a container too much, that is, to a size smaller than its file system contents, will destroy part of the file system’s contents. Once the container is reduced, you must subsequently recreate a new file system within the container using newfs or SAM, or else if you attempt to access the original file system, you may crash your system. The steps you need to follow are shown below:

  1. Back up the file system.

  2. Unmount the file system.

  3. Use lvreduce to reduce the size of the logical volume to the same size desired for the smaller file system.

  4. Create the new smaller file system using newfs. How to do this is covered earlier in “Creating a File System”.

  5. Re-mount the file system.

  6. Restore the backed up file system data to the newly created file system. (Note that you may no longer have enough space to restore all your original files.)

Managing Disk Space Usage with Quotas

Using disk quotas allows the administrator to control disk space usage by limiting the number of files users can create and the total number of system blocks they can use.

You implement disk quotas on a local file system and its users by placing soft limits and hard limits on users’ file system usage. Soft limits are limits that can only be exceeded for a specified amount of time. A hard limit can never be exceeded. If users fail to reduce usage below soft limits before the specified time limit or reach a hard limit, they will be unable to create files or increase the size of existing files.

Typically, you will set disk quotas on file systems that would otherwise become full without limitations. For example, to prevent users from using /tmp or /var/tmp as storage, set the soft limits small and the time limits for remedial action short.

Because disk quota statistics reside in memory, using disk quotas rarely impairs performance. However, the time required to reboot a crashed system will take longer because of the time required to run /usr/sbin/quotacheck whenever the system is booted.

You cannot use SAM to perform disk quota tasks.

Setting Up and Turning On Disk Quotas

Here are the main steps for setting up and turning on disk quotas:

  1. Mount the file system.

    Suppose you want to implement quotas on /home, which is accessed via the device file /dev/vg00/lvol3. This file system will be mounted automatically at bootup if it is listed in your /etc/fstab file. If the file system is not mounted, enter:

    mount /dev/vg00/lvol3 /home
  2. Create a quotas file.

    Use the cpset command to create an empty file named quotas within the directory. This file will contain, in binary form, the limits and usage statistics for each user to be limited in creating files within the file system. For example, to install the quotas file for the mounted /home file system, 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 in /home directory, and 600 root bin is the mode, owner, and group of the file. For syntax, see cpset(1M).

    NOTE: To control the size of the quotas file, refrain from using large user identification numbers (UIDs). This will not be a concern if you use SAM to add users because SAM selects the UIDs in numerical order.
  3. Set the user quotas.

    Use the /usr/sbin/edquota command to set or subsequently modify quotas of individual users. The edquota utility creates a temporary file for a text representation of disk quotas for a user and invokes an editor. Once you enter the quotas and leave the editor, the text is converted to binary form for storing within the quotas file. For syntax, see edquota(1M).

    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.

    1. Set the limits for a prototype user, patrick.

      1. Invoke the quota editor:

        edquota patrick
      2. To input the disk-usage 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 exactly as shown in order to get the correct spacing between items. Bad formatting and/or typographical errors may cause incorrect setting of quotas.

      3. Save the file. This updates the quotas file. Exit the editor.

    2. 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: When removing a user from the system, run edquota and set the user’s limits to zero. Thus, when the user is removed from the system, there will be no entry for that user in the quotas file.
  4. Set time limits, unless you wish to apply default time limits of one week in which case no action is required.

    Use the edquota command with the -t option to set the time limit users will have to take corrective action when exceeding a soft limit. Unlike limits on files and blocks, a single time limit applies uniformly to all users of a file system.

    For example, to edit the quotas file and set a time limit of 10 days for file system blocks and 15 days for files in the file system /home, enter the following:

    1. Invoke the quota editor:

      edquota -t
    2. To input a time limit, type the following:

      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.

      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 /home file system, enter this line:

      fs /home blocks time limit = 0, files time limit = 0
    3. Save the file and exit the editor.

  5. Turn on quotas.

    Disk quotas can be enabled in any of 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:

      /dev/vg00/lvol3 /home hfs rw,suid,quota 0 2
    • Turn on disk quotas by re-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 the file system. For example:

      umount /dev/vg00/lvol3
      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:

      mount -a 

      or

      mount /home 

      After remounting the file system, you must run quotacheck on the file system to update usage information stored in the quotas file.

    • 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), follow these steps. (These steps will also work for the root (/) file system.)

      1. 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 mount directory of the file system. For example, issuing the command

        quotaon -v /home

        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.

      2. Check the file system for consistency. For example:

        quotacheck /dev/vg00/lvol3

        See quotacheck(1M) for syntax.

Turning Off Disk Quotas

When you unmount a file system, HP-UX automatically turns off disk quotas.

You can turn off disk quotas for a file system without unmounting that file system by using the /usr/sbin/quotaoff command. However, using this command is not recommended because once quotas are turned off, actual disk usage may become inconsistent with the usage information stored in the quotas file, thus requiring quotacheck when quotas are re-enabled. See quotaoff(1M) for more information.

What To Do When Exceeding a Soft Limit

After creating a file that causes a soft limit quota to be exceeded, a user on locally mounted file systems will see a message similar to this:

WARNING: disk quota (/home) exceeded

The user has a limited time to remove unnecessary files. The user will receive no further warnings until he attempts to exceed hard limits or allows the time to expire without reducing usage to normal levels. Once a user corrects his usage levels, the system removes any time constraints.

NOTE: Users of remote file systems (such as NFS mounts) will not receive soft limit warnings. Thus, users having quotas on remote file systems can reach hard limits without prior warning, so they should frequently check their usage levels using the /usr/bin/quota command. For details on checking levels, see quota(1). Only a user with superuser privileges can use the user option of the quota command to view specific usage and quota information about other users.

What To Do When Exceeding a Hard Limit

When users reach a hard limit or fail to reduce their usage below soft limits within the allotted time, an error message appears on their terminal. If a user reaches a block limit, the following message appears:

DISK LIMIT REACHED - WRITE FAILED

If he reaches a file limit, he sees:

FILE LIMIT REACHED - CREATE FAILED

How to recover from reaching a hard limit depends on whether or not the user was using an editor when the message was received. The next sections describe both cases.

When Not Using an Editor

When not using an editor, follow these steps:

  1. Abort the process or processes that are using the file system.

  2. Remove enough files to lower the number of files and/or file system blocks below the soft limits established in the quotas file.

    The quota command reports whether a user is above or below the limit in the specific file system. To determine the current number of blocks in files and directories, use the du or the find command (see du(1) and find(1) for details).

  3. Run the aborted processes again.

When Using an Editor

When using an editor, the user needs to remove files to a level below the quota limits and still preserve the recent changes made to the file being edited. If possible, a user can do this by opening a new window or by logging in from a remote node. This way, the user can get a shell prompt without aborting the editor. Alternatively, the user can follow these steps:

  1. Write the file to another file system (such as /var/tmp) where quotas are not exceeded.

  2. Exit the editor.

  3. Remove files until the remaining number is well below the file and/or file system block quotas determined by the soft limits.

  4. Move the file back into the original file system.

Or, when using a job-control shell:

  1. Go to the shell and type a “suspend” character (for example, pressing the CTRL and Z keys at the same time) to suspend the editor.

  2. Remove files until the number remaining is below the file and/or file system block quotas.

  3. Type fg at the shell prompt to return to the editor.

Managing Mirrored File Systems

Mirroring allows you to simultaneously maintain identical copies of a logical volume containing a file system. As a result, if a disk fails, or if media errors occur to part of a disk, you will still have access to the file system within the mirrored logical volume. It is also possible to mirror a logical volume containing raw data, such as from a database.

If you would like to learn more about basic mirroring tasks, it is suggested that you refer to the book Disk and File Management Tasks on HP-UX published by Prentice Hall PTR, 1997.

To use mirroring, you will need to purchase MirrorDisk/UX, product number B2491A, for servers. This software product is not bundled with HP-UX and is not supported on workstations. (Mirroring is not supported on HP-IB disks.)

Creating and Modifying Mirrored Logical Volumes

You can configure mirroring by using either SAM or HP-UX commands. Whenever possible, use SAM.

Using SAM

SAM will perform the following mirroring set-up and configuration tasks:

  • Creating or removing a mirrored logical volume.

  • Configuring or changing the characteristics of a logical volume’s mirrors. You can specify:

    • the number of mirror copies.

    • strict (including choice of using separate physical volume groups) vs. nonstrict allocation.

    • the Mirror Write Cache or the Mirror Consistency Recovery method.

    • parallel, sequential, or dynamic scheduling policy.

    • contiguous allocation vs. noncontiguous allocation.

NOTE: The logical volume feature in SAM related to mirroring will not function unless the MirrorDisk/UX subsystem has been added to the system.
Using HP-UX Commands

Table 6-8 “HP-UX Commands Needed to Create and Configure Mirroring ” summarizes the commands you will need to do mirror set-up and configuration tasks when you do not use SAM. Consult Section 1M of the HP-UX Reference for the appropriate command line options to use.

Table 6-8 HP-UX Commands Needed to Create and Configure Mirroring

Task

Commands and Options Needed

Creating a mirrored logical volume.

Subtasks:

Setting strict or nonstrict allocation.

Setting the Mirror Write Cache method.

Setting the Mirror Consistency Recovery method.

Setting parallel or sequential scheduling policy.

Setting contiguous allocation vs. noncontiguous allocation.

Creating a mirror copy within separate physical volume groups.

lvcreate -m

Add:

-s y or -s n

-M y or -M n

-c y or -c n

-d p or -d s

-C y or -C n

-s g

Removing a mirrored logical volume.