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 Disks

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

This section provides practical guidance in managing disks under HP-UX. It covers the following topics:

NOTE: This section describes HP’s Logical Volume Manager and how a logical volume manager works. However, the VERITAS Volume Manager provides alternative online disk management to the HP Logical Volume Manager and HP MirrorDisk/UX products. The VERITAS Volume Manager is included on the HP-UX 11i Application CD and, as of the September 2002 release of HP-UX 11i version 1, VxVM 3.5 is included in the operating environments enabling VxVM rootability. For more detailed information and tasks, read HP-UX 11i Installation and Update Guide and the VERITAS Volume Manager 3.5 documents.
  • VERITAS Volume Manager 3.5 Installation Guide

  • VERITAS Volume Manager 3.5 Migration Guide

  • VERITAS Volume Manager 3.5 Release Notes

  • VERITAS Volume Manager 3.5 Administrator’s Guide

  • VERITAS Volume Manager 3.5 Hardware Notes

  • VERITAS Volume Manager 3.5 Troubleshooting Guide

  • VERITAS Volume Manager 3.5 User’s Guide - VERITAS Enterprise Administrator

The “VERITAS Volume Manager and File System” neighborhood at HP’s HP-UX documentation web site provides information on other versions of VERITAS Volume Manager:

http://docs.hp.com/hpux/os/11i/index.html#VERITAS%20Volume%20Manager%20and%20File%20System

For a book-length view of these topics, we recommend Disk and File Management Tasks on HP-UX, published by Prentice Hall PTR, 1997. You will notice some references to this book in the text that follows.

Current Disk Management Facts

  • On HP-UX, disks are managed identically on servers and workstations.

  • On both servers and workstations, using logical volumes is recommended as the preferred method for managing disks.

  • Existing hard partitioned disks from servers and nonpartitioned disks from workstations continue to be supported.

  • You will not be able to use a partitioned disk for your root disk. You will only be able to use a nonpartitioned disk, LVM, or VxVM disk for this purpose.

  • Although the use of logical volumes is encouraged, disks on both servers and workstations can also be managed as nonpartitioned disks, or with hard partitions for those disk models that support hard partitions.

  • Existing disks that are nonpartitioned or that have hard partitions can be converted to use logical volumes.

  • Both LVM disks and non-LVM disks can exist simultaneously on your system, but a given disk must be managed entirely by either LVM or non-LVM methods. That is, you cannot combine these techniques for use with a single disk.

  • You should note that although hard disk drives and disk arrays support the use of logical volumes, floppy disks, optical disks, and CD-ROMs do not.

The Logical Volume Manager (LVM)

Useful Facts About LVM

  • To use LVM, a disk must be first initialized into a physical volume (also called an LVM disk).

  • Once you have initialized one or more physical volumes, you assign them into one or more volume groups. If you think of all of your physical volumes as forming a storage pool, then a subset of disks from the pool can be joined together into a volume group.

  • A given disk can only belong to one volume group. The maximum number of volume groups that can be created is determined by the configurable parameter maxvgs. See “Reconfiguring the Kernel
    (Prior to HP-UX 11i Version 2)”
    for information on modifying system parameters.

  • A volume group can contain from one to 255 physical volumes.

  • Disk space from the volume group is allocated into a logical volume, a distinct unit of usable disk space. A volume group can contain up to 255 logical volumes.

  • A logical volume can exist on only one disk or can reside on portions of many disks.

  • The disk space within a logical volume can be used for swap, dump, raw data, or you can create a file system on it.

    In Figure 6-1 “Disk Space Partitioned into Logical Volumes”, logical volume /dev/vg01/lvol1 might contain a file system, /dev/vg01/lvol2 might contain swap space, and /dev/vg01/lvol3 might contain raw data. As the figure illustrates, a file system, swap space, or raw data area may exist within a logical volume that resides on more than one disk.

    Figure 6-1 Disk Space Partitioned into Logical Volumes

    Disk Space Partitioned into Logical Volumes
  • If a logical volume spans multiple physical volumes, it is not required that each disk be of the same interface type except in the case of HP-IB disks; however, having the same interface type will result in better performance. See “Using Disk I/O Interfaces” for more information on interface types and limitations.

How LVM Works

  • LVM divides each physical disk into addressable units called physical extents. Extents are allocated to disks sequentially starting from the beginning of the disk with address zero, and incrementing the address by one for each unit. Physical extent size is configurable at the time you form a volume group and applies to all disks in the volume group. By default, each physical extent has a size of 4 megabytes (MB). This value can be changed when you create the volume group to a value between 1MB and 256MB.

  • The basic allocation unit for a logical volume is called a logical extent. A logical extent is mapped to a physical extent; thus, if the physical extent size is 4MB, so will be the logical extent size. The size of a logical volume is determined by the number of logical extents configured.

  • When LVM allocates disk space to a logical volume, it automatically creates a mapping of the physical extents to logical extents. Logical extents are also allocated sequentially, starting at zero, for each logical volume. Therefore, regardless of where the actual physical data resides for a logical volume within a volume group, LVM will use this mapping to access the data. Commands are provided for you to examine this mapping; see pvdisplay(1M) and lvdisplay(1M).

  • Except for mirrored or striped logical volumes, each logical extent is mapped to one physical extent. For mirrored logical volumes, either two or three physical extents are mapped for each logical extent depending upon whether you are using single or double mirroring. For example, if one mirror copy exists, then each logical extent maps to two physical extents, one extent for the original and one for the mirror copy. See “Managing Mirrored File Systems” for more information on mirroring. For information on striped logical volumes, see “Setting Up Disk Striping”. See also the book Disk and File Management Tasks on HP-UX.

    Figure 6-2 “Physical Extents and Logical Extents” shows an example of several types of mapping available between physical extents and logical extents within a volume group.

    Figure 6-2 Physical Extents and Logical Extents

    Physical Extents and Logical Extents

    As can be seen in Figure 6-2 “Physical Extents and Logical Extents”, the contents of the first logical volume are contained on all three physical volumes in the volume group. Since the second logical volume is mirrored, each logical extent is mapped to more than one physical extent. In this case, there are two physical extents containing the data, each on both the second and third disks within the volume group.

  • By default, LVM assigns physical extents to logical volumes by selecting available physical extents from disks in the order you added physical volumes to the volume group. As a system administrator, you can bypass this default assignment and control which disks are used by a logical volume (see “Extending a Logical Volume to a Specific Disk ”).

  • If a logical volume is to be used for root, boot, primary swap, or dump, the physical extents must be contiguous. This means that the physical extents must be allocated with no gaps on a single physical volume. On non-root disks, physical extents that correspond to contiguous logical extents within a logical volume can be noncontiguous on a physical volume or reside on entirely different disks. As a result, it becomes possible for a file system created within one logical volume to reside on more than one disk.

Planning for the Use of Logical Volumes

Using logical volumes requires some planning. Some of the issues you should consider for planning purposes are listed below and discussed in the remainder of this section. You should consider these issues before setting up or modifying logical volumes on your system.

Setting Up Logical Volumes for File Systems

File systems reside in a logical volume just as they do within disk sections or nonpartitioned disks. As of 10.10, the maximum size of HFS and JFS (VxFS) file systems increased from 4GB to 128GB. However, your root or boot logical volume is limited to either 2GB or 4GB, depending on your processor. (For more information on HFS and JFS, refer to “Determining What Type of File System to Use”.)

You can consider the space required by a file system as having three major components, as depicted in Figure 6-3 “File System Space Components”.

Figure 6-3 File System Space Components

File System Space Components

To get a rough estimate of how big to make a logical volume which will contain your file system, do the following:

  1. Estimate how much disk space users will need for their data out into the future. Allow for any anticipated changes which are usually in the direction of additional growth. (Use the du command to see how much disk space is currently being used.)

  2. Add 10% to the above amount for a “minfree” area; this area is reserved to maintain performance.

  3. Add another 5% for file system overhead; this includes all data structures required to maintain the file system.

  4. Round up to the next integer multiple of the logical extent size used in this logical volume to find the size in logical extents. (Unlike the previous steps, this step is performed automatically for you when you create a logical volume.)

For example, suppose a group of users will require 60MB space for file system data; this estimate allows for expected growth. You then add 6MB for the “minfree” space and arrive at 66MB. Then you add another 3MB for file system overhead and arrive at a grand total estimate of 69MB required by the file system, and by consequence, for the logical volume that contains the file system. If you are creating the logical volume in a volume group that has an extent size of 4MB, 69 gets rounded up to 72 to make it divisible by 4MB. That is, LVM will create your logical volumes in multiples of the logical extent size.

Although estimates are not precise, they suffice for planning how big to make a file system. You want your file system to be large enough for some useful time before having to increase its size. On the other hand, a contiguous logical volume such as the root logical volume cannot be readily increased in size. Here, it is especially important to try to choose an estimate that will allow for all subsequent growth to such logical volumes.

Suppose as suggested above, your users have outgrown the space originally allocated for the file system. You can increase the size of a file system by first enlarging the logical volume it resides in and then using extendfs(1M). (More information can be found under “Extending the Size of a File System Within a Logical Volume ”).

You cannot decrease the size of a file system once it has been created. However, you can create a new smaller file system to take its place.

NOTE: Because increasing the size of a file system is usually much easier than reducing its size, you might benefit by being conservative in estimating how large to create a file system.

However, an exception to this would be the root file system since it is difficult to extend it.

Whenever possible, if you plan to have a file system span disks, have the logical volume span identical disk interface types. (See “Using Disk I/O Interfaces”.)

Normally, by default, LVM will create logical volumes on available disks, not necessarily with regard for best performance. It is possible to have a file system span two disks with different characteristics, in which case the file system performance could possibly be impaired.

As a system administrator, you can exercise control over which physical volumes will contain the physical extents of a logical volume. You can do this by using the following two steps:

  1. Create a logical volume without specifying a size using lvcreate(1M) or SAM. When you do not specify a size, by default, no physical extents are allocated for the logical volume.

  2. Now extend the logical volume (that is, allocate space) to the specific physical volumes you wish to contain the file system using lvextend(1M).

For more detailed information on this procedure, see “Extending a Logical Volume to a Specific Disk ”.

Setting Up Logical Volumes for Swap

When you enable a swap area within a logical volume, HP-UX determines how large the area is and it will use no more space than that. If your disk has enough remaining contiguous space, you can subsequently increase the size of your primary swap area by using the lvextend command (or SAM) to enlarge the logical volume and then reboot the system. This allows HP-UX to use the extra space that you have provided.

If you plan device swap areas in addition to primary swap, you will attain the best performance when the device swap areas are on different physical volumes (disks). This allows for the interleaving of I/O to the physical volumes when swapping occurs.

You set up this swapping configuration by creating multiple logical volumes for swap, each logical volume on a separate disk. You must use HP-UX commands to help you obtain this configuration; SAM does not allow you to create a logical volume on a specific disk. See “Extending a Logical Volume to a Specific Disk ”.

Setting Up Logical Volumes for Raw Data Storage

You can optimize raw I/O performance by planning your logical volumes specifically for raw data storage. To create a raw data logical volume (such as for a database), you will need to consider how large to create the logical volume and how such a logical volume is distributed over your disks.

Typically, you specify the size of a logical volume in megabytes. However, a logical volume’s size must be a multiple of the extent size used in the volume group. By default, the size of each logical extent is 4 MB.

So, for example, if a database partition requires 33MB and the default logical extent size is 4 MB, LVM will create a logical volume that is 36MB (or 9 logical extents).

The maximum supported size for a raw data device is 4 GB.

If you plan to use logical volumes heavily for raw data storage (such as for setting up database partitions), you should consider how the logical volumes are distributed over your disks.

By default, LVM will assign disk space for a logical volume from one disk, use up the space on this disk entirely, and then assign space from each successive disk in the same manner. LVM uses the disks in the order in which they were added to the volume group. This means that a logical volume’s data may not turn out to be evenly distributed over all the disks within your volume group.

As a result, when I/O access to the logical volumes occurs, one or more disks within the volume group may be heavily used, while the others may be lightly used, or not even used at all. This arrangement does not provide optimum I/O performance.

As a better alternative, you can set up your logical volume on specific disks in an interleaved manner, thus balancing the I/O access and optimizing performance. (See “Extending a Logical Volume to a Specific Disk ”.)

Because there are no HP-UX commands that will identify that the contents of a logical volume are being used for raw data, it is a good idea to name the logical volumes you create for raw data with easily recognizable names. In this way, you can recognize the contents of such a logical volume. See “Naming Logical Volumes” for more information.

Using Disk I/O Interfaces

LVM supports disks that use SCSI, HP-FL, and, to a limited extent, HP-IB I/O interface types, as shown in Table 6-1 “Disk Interface Types and LVM Support ”.

Table 6-1 Disk Interface Types and LVM Support

SCSI

HP-FL

HP-IB

Support mixing of disks with other interface types within the same volume group?

Yes

Yes

No

Support bad block relocation?

Yes

Yes

No

Support LVM mirroring?

Yes

Yes

No

 

Although the table shows that mixed HP-FL and SCSI disks can belong to the same volume group, for best performance, you should keep them in separate groups, each containing identical model disks; that is, each should have the same characteristics such as size and rotational speed. HP-IB disks cannot be mixed with the other types.

NOTE: LVM can be used on all Series 700 and 800 supported disks.

HP-IB disks are not supported on Series 700 systems.

Bad Block Relocation

If as a result of a defect on the disk, LVM is unable to store data, a mechanism is provided to store it at the end of the disk. If your disk supports automatic bad block relocation (usually known as “hardware sparing”), then LVM’s bad block relocation mechanism is unnecessary.

Bad block relocation is in effect by default when a logical volume is created. You can use the -r n option of lvcreate(1M) to disable the bad block relocation feature.

NOTE: Bad block relocation is not supported for root, swap, or dump logical volumes, or on physical volumes larger than 256GB.

As of HP-UX 11i version 2, LVM no longer performs bad block relocation in software, but defers to the hardware bad block relocation implemented within modern disks and disk arrays. LVM recognizes and honors software relocation entries created by previous releases, but will not create new ones. Enabling or disabling bad block relocation via lvchange has no effect.

The -r option of lvcreate cannot be used with HP-IB devices.

Increasing Availability with Alternate Links

Your hardware may provide the capability for dual cabling (dual controllers) to the same physical volume. This will be true if your organization has purchased an HP High Availability Disk Array or the MC/ServiceGuard product. If so, LVM can be configured with multiple paths to the same physical volume. If the primary link fails, an automatic switch to an alternate link will occur. Using alternate links will increase availability. See “Setting Up Alternate Links to a Physical Volume ”.

LVM Naming Conventions

By default, HP-UX uses certain naming conventions for physical volumes, volume groups, and logical volumes. You need to refer to LVM devices or volume groups by name when using them within SAM, with HP-UX commands, or when viewing information about them.

Naming Physical Volumes

Physical volumes are identified by their device file names, for example:

/dev/dsk/cntndn
/dev/dsk/cntndns2
/dev/rdsk/cntndn
/dev/rdsk/cntndns2

Note that each disk has a block device file and a character or raw device file, the latter identified by the r. Which name you use depends on what task you are doing with the disk. In the notation above, the first two names represent block device files while the second two are raw device files.

On HP Integrity Servers, make sure to use the device file with the s2 suffix, as that represents the HP-UX partition on the disk. On HP 9000 (PA-RISC) systems, use the device file without a partition number.

Use a physical volume’s raw device file for these two tasks only:

  • When creating a physical volume. Here, you use the device file for the disk. For example, this might be /dev/rdsk/c3t2d0 if the disk were at card instance 3, target address 2, and device number 0. (The absence of a section number beginning with s indicates you are referring to the entire disk.)

  • When restoring your volume group configuration.

For all other tasks, use the block device file. For example, when you add a physical volume to a volume group, you use the disk’s block device file for the disk, such as /dev/dsk/c5t3d0.

For more information on device file names, see Configuring HP-UX for Peripherals.

All disk device files are created automatically when you boot the system, after you have physically added the disk. Refer to insf(1M) for more information.

Naming Volume Groups

When choosing a name for a volume group, the name must be identical to the name of a directory you have created under /dev. (See Steps 3 and 4 under “Example: Creating a Logical Volume Using HP-UX Commands”.) The name can have up to 255 characters.

Each volume group must have a unique name. For example, typical volume group names could be vg01, vgroot, or vg_sales. Although the name does not have to start with vg, this is highly encouraged. Often, these names take the form: /dev/vgnn. When assigned by default, the number nn starts at 00 and proceeds 01, 02, and so on, in the order that volume groups are created. By default, your root volume group will be vg00 although this name is not required; see “Creating Root Volume Group and Root and Boot Logical Volumes ” later for more information on the root volume group.

Naming Logical Volumes

Logical volumes are identified by their device file names which can either be assigned by you or assigned by default when you create a logical volume using lvcreate(1M).

When assigned by you, you can choose whatever name you wish up to 255 characters.

When assigned by default, these names take the form: /dev/vgnn/lvolN (the block device file form) and /dev/vgnn/rlvolN (the character device file form). The number N starts at 1 and proceeds 2, 3, and so on, in the order that logical volumes are created within each volume group.

When LVM creates a logical volume, it creates both block and character device files. LVM then places the device files for a logical volume in the appropriate volume group directory.

For example, the default block name for the first logical volume created in volume group vg01 would have the full path name:

/dev/vg01/lvol1

If you create a logical volume to contain raw data for a sales database, you might want to name it using a nondefault name:

/dev/vg01/sales_db_lv

After the logical volume in the above example has been created, it will have two device files:

/dev/vg01/sales_db_lv    block device file
/dev/vg01/rsales_db_lv   character, or raw, device file

Naming Physical Volume Groups

Physical volume groups are useful for mirroring and are discussed under “Managing Mirrored File Systems”. The only naming restriction in this case is that within a volume group, each physical volume group must have its own unique name. For example, the volume group /dev/vg02 might have two physical volume groups called /dev/vg02/pvg1 and /dev/vg02/pvg2.

Managing Logical Volumes Using SAM

SAM enables you to perform most, but not all, LVM management tasks. Tasks that can be performed with SAM include:

  • Creating or removing volume groups

  • Adding or removing disks within volume groups

  • Creating, removing, or modifying logical volumes

  • Increasing the size of logical volumes

  • Activating and deactivating volume groups

  • Creating or increasing the size of a file system in a logical volume (see “Managing File Systems”)

  • Setting up and modifying swap and dump logical volumes (see “Managing Swap and Dump”)

  • Creating and modifying mirrored logical volumes (see “Managing Mirrored File Systems”)

These tasks can also be performed with HP-UX commands. (See the section below as well as the specific sections referred to above.)

To use SAM, enter sam.

For help using SAM, consult SAM’s online help.

Managing Logical Volumes Using HP-UX Commands

As stated above, all disk management tasks performed by SAM can also be done using HP-UX commands.

The following tables give you general information on the commands you will need to use to perform a given task. Refer to the HP-UX Reference for detailed information.

Table 6-2 Commands Needed for Physical Volume Management Tasks

Task

Commands Needed

Changing the characteristics of a physical volume in a volume group.

pvchange(1M)

Creating a physical volume for use in a volume group.

pvcreate(1M)

Displaying information about physical volumes in a volume group.

pvdisplay(1M)

Moving data from one physical volume to another.

pvmove(1M)

Removing a physical volume from LVM control.

pvremove(1M)

 

Table 6-3 Commands Needed for Volume Group Management Tasks

Task

Commands Needed

Creating a volume group.

vgcreate(1M) [1] [2]

Removing volume group.

vgremove(1M) [3]

Activating, deactivating, or changing the characteristics of a volume group.

vgchange(1M)

Backing up volume group configuration information.

vgcfgbackup (1M) [4]

Restoring volume group configuration from a configuration file.

vgcfgrestore(1M)

Displaying information about volume group.

vgdisplay(1M)

Exporting a volume group and its associated logical volumes.

vgexport(1M)

Importing a volume group onto the system; also adds an existing volume group back into /etc/lvmtab.

vgimport(1M) [5]

Scan all physical volumes looking for logical volumes and volume groups; allows for recovery of the LVM configuration file, /etc/lvmtab.

vgscan(1M)

Adding disk to volume group.

vgextend(1M) [6]

Removing disk from volume group.

vgreduce(1M)

[1] Before executing command, one or more physical volumes must have been created with pvcreate.

[2] You also need to create a directory for the volume group and a group device file in the directory. See “Example: Creating a Logical Volume Using HP-UX Commands”, or lvm(7) for more information.

[3] If logical volumes exist within the volume group, they must first be removed using lvremove. Also, the volume group must not contain more than one physical volume. If it does, use vgreduce first.

[4] Invoked automatically whenever a configuration change is made.

[5] You also need to create a directory for the volume group and a group device file in the directory. See “Example: Creating a Logical Volume Using HP-UX Commands”, or lvm(7) for more information.

[6] Before executing command, one or more physical volumes must have been created with pvcreate.

 

Table 6-4 Commands Needed for Logical Volume Management Tasks

Task

Commands Needed

Creating a logical volume.

lvcreate(1M)

Modifying a logical volume.

lvchange(1M)

Displaying information about logical volumes.

lvdisplay(1M)

Increasing the size of logical volume by allocating disk space.

lvextend(1M)

Decreasing the size of a logical volume.

lvreduce(1M) [1]

Removing the allocation of disk space for one or more logical volumes within a volume group.

lvremove(1M)

Preparing a logical volume to be a root, primary swap, or dump volume.

lvlnboot(1M) [2]

Removing link that makes a logical volume a root, primary swap, or dump volume.

lvrmboot(1M)

Increasing the size of a file system up to the capacity of logical volume.

extendfs(1M) [3]

Splitting a mirrored logical volume into two logical volumes.

lvsplit(1M) [4]

Merging two logical volumes into one logical volume.

lvmerge(1M)[5]

[1] To prevent data loss and possible file system corruption, back up contents first.

[2] Invoked automatically whenever the configuration of the root volume group is affected by one of the following commands: lvextend, lvmerge, lvreduce, lvsplit, pvmove, lvremove, vgextend, or vgreduce.

[3] You will first need to unmount the file system and then increase the size of the logical volume that contains the file system using lvextend. If you are using JFS (VxFS) and have the OnLineJFS product, you can do online resizing with fsadm(1M). (See Disk and File Management Tasks on HP-UX for additional information.)

[4] Requires optional HP MirrorDisk/UX software.

[5] Requires optional HP MirrorDisk/UX software.

 

Example: Creating a Logical Volume Using HP-UX Commands

To create a logical volume, do the following procedure:

  1. Select one or more disks. ioscan(1M) shows the disks attached to the system and their device file names.

  2. Initialize each disk as an LVM disk by using the pvcreate command. For example, enter:

    pvcreate /dev/rdsk/c0t0d0

    Note that using pvcreate will result in the loss of any existing data currently on the physical volume.

    You use the character device file for the disk.

    This example shows the device file name for an HP 9000 (PA-RISC) System; on an HP Integrity Server, make sure that the device file specifies the HP-UX partition number. For example, enter:

    pvcreate /dev/rdsk/c3t1d0s2

    Once a disk is initialized, it is called a physical volume.

  3. Pool the physical volumes into a volume group. To complete this step:

    1. Create a directory for the volume group. For example:

      mkdir /dev/vgnn

    2. Create a device file named group in the above directory with the mknod command.

      mknod /dev/vgnn/group c 64 0xNN0000

      The c following the device file name specifies that group is a character device file.

      The 64 is the major number for the group device file; it will always be 64.

      The 0xNN0000 is the minor number for the group file in hexadecimal. Note that each particular NN must be a unique number across all volume groups.

      For more information on mknod, see mknod(1M); for more information on major numbers and minor numbers, see Configuring HP-UX for Peripherals.

    3. Create the volume group specifying each physical volume to be included using vgcreate. For example:

      vgcreate /dev/vgnn /dev/dsk/c0t0d0

      Use the block device file to include each disk in your volume group. You can assign all the physical volumes to the volume group with one command. No physical volume can already be part of an existing volume group.

  4. Once you have created a volume group, you can now create a logical volume using lvcreate. For example:

    lvcreate /dev/vgnn

    Using the above command creates the logical volume /dev/vgnn/lvoln with LVM automatically assigning the n in lvoln.

    When LVM creates the logical volume, it creates the block and character device files and places them in the directory /dev/vgnn.

Tasks That You Can Perform Only with HP-UX Commands

The following tasks can be done only using HP-UX commands. You can not do them with SAM.

How to do each of these tasks is shown next.

Extending a Logical Volume to a Specific Disk

Suppose you want to create a 300 MB logical volume and put 100 MB on your first disk, another 100 MB on your second disk, and 100 MB on your third disk. To do so, follow these steps:

  1. After making the disks physical volumes and creating your volume group, create a logical volume named lvol1 of size 0.

    lvcreate -n lvol1 /dev/vg01

  2. Now allocate a total of 25 extents to the logical volume on the first physical volume. (We are assuming in this example that each physical extent is 4MB, the default value.)

    lvextend -l 25 /dev/vg01/lvol1 /dev/dsk/c1t0d0

  3. Then increase the total number of physical extents allocated to the logical volume for the remaining physical volumes by 25. In each case, the additional 25 extents are allocated to the disk specified.

    lvextend -l 50 /dev/vg01/lvol1 /dev/dsk/c2t0d0

    lvextend -l 75 /dev/vg01/lvol1 /dev/dsk/c3t0d0

Note that when you use the -l option (lowercase L) of lvextend, you specify space in logical extents.

Now suppose you have two disks in a volume group, both identical models. You currently have a 275 MB logical volume that resides on only one of the disks. You want to extend the logical volume size to 400 MB, making sure the 125 MB increase is allocated to the other disk.

Again you extend the logical volume to a specific disk.

lvextend -L 400 /dev/vg01/lvol2 /dev/dsk/c2t0d0

Here, when you use the -L option (uppercase), you are specifying space in megabytes, not logical extents.

See lvextend(1M) for complete information on command options.

Creating Root Volume Group and Root and Boot Logical Volumes

NOTE:

VERITAS Volume Manager (VXVM).  The VERITAS Volume Manager included in the operating environments as of the September 2002 release of HP-UX 11i version (B.11.11) enables rootability. With VxVM rootability, you can choose to configure your root volume during installation with Ignite-UX, or you can use the conversion tools installed with VxVM to configure your root volume at a later time. For more information, read the VERITAS Volume Manager 3.5 Installation Guide for more details.

Before you consider setting your root volume to VxVM, be sure to read the VERITAS Volume Manager 3.5 Release Notes and the VERITAS Volume Manager 3.5 Migration Guide on http://docs.hp.com for more detailed information about VxVM and rootability.

Please note that there can be newer versions of these documents available on the documentation website.

With non-LVM disks, a single root disk contained all the attributes needed for boot up as well as your system files, primary swap, and dump. Using LVM, a single root disk is replaced by a pool of disks, a root volume group, which contains all of the same elements but allowing a root logical volume, a boot logical volume, a swap logical volume, and one or more dump logical volumes. Each of these types of logical volumes must be contiguous, that is, contained on a single disk. (Additionally, there can be other noncontiguous logical volumes which might be used for user data.) See “Managing Swap and Dump” for more information on the swap and dump logical volumes.

The root logical volume contains the operating system software. You have the option of using a separate boot logical volume instead of combining root and boot operations within a single logical volume. When you configure both a root and boot logical volume, you store information that enables the system to locate the kernel in two locations rather than only one which is the case with using just the root logical volume. As a result, you will still be able to boot the system even if the LABEL file, normally essential to a system boot, becomes corrupt.

Whether you use a single “combined” root-boot logical volume, or separate root and boot logical volumes, the logical volume used to boot the system must be the first logical volume on its physical volume. If the root logical volume is not the first logical volume on its physical volume, then you must also configure a boot logical volume. Both a root logical volume and a boot logical volume must be contiguous with bad block relocation disabled.

If you newly install your 11.00 system and choose the LVM configuration, a root volume group is automatically configured, as are separate root and boot logical volumes. If you currently have a combined root and boot logical volume and you wish to reconfigure to separate root and boot logical volumes, after creating the boot logical volume, you will need to use the lvlnboot(1M) command with the -b option to define the boot logical volume to the system, taking effect the next time the system is booted. For example:

lvlnboot -b /dev/vgroot/bootlv

If you decide you want to create a root volume group “from scratch” that will contain an alternate boot disk, you can follow the steps below. You can also use these steps, with some minor changes, if you need to modify an existing root logical volume, including increasing its size, or perhaps changing your configuration to a combined root-boot logical volume. When modifying an existing root logical volume, be sure to back up your current root logical volume before proceeding and then copy it back to the new file system upon completion.

  1. Create a physical volume using pvcreate with the -B option. -B creates an area on the disk for a LIF volume, boot utilities, and a BDRA (Boot Data Reserved Area).

    NOTE: The BDRA must exist on each bootable disk within the root volume group. The BDRA maintains the information that the kernel requires about the logical volume that contains the root, as well as those that contain primary swap and dump.

    See lif(4) for more information on LIF volumes.

    For example:

    pvcreate -B /dev/rdsk/c0t3d0

  2. Create a directory for the volume group using mkdir.

  3. Create a device file named group in the above directory with the mknod command. (See “Example: Creating a Logical Volume Using HP-UX Commands” for details.)

  4. Create the root volume group specifying each physical volume to be included using vgcreate. For example:

    vgcreate /dev/vgroot /dev/dsk/c0t3d0

  5. Use mkboot(1M)to place boot utilities in the boot area:

    mkboot /dev/rdsk/c0t3d0

  6. Use mkboot -a to add an AUTO file in boot LIF area:

    mkboot -a "hpux (;0)/stand/vmunix" /dev/rdsk/c0t3d0

Now you are ready to create a logical volume that you intend to use for root. You usually want to place this logical volume on a specific physical volume. If you are configuring a combined root-boot logical volume, the root logical volume must be the first logical volume found on the bootable LVM disk. In this case, this means that the root logical volume must begin at physical extent 0000. This is important in the event it is necessary to boot the system in maintenance mode. A disk that will contain a root logical volume should not have non-root data in the region following the boot area.

NOTE: You can use pvmove(1M) to move the data from an existing logical volume to another disk, if it’s necessary to make room for the root logical volume.

Continue by following these additional steps:

  1. Create the root logical volume. You must specify contiguous extents (-C y) with bad block relocation disabled (-r n). For example, to create a logical volume called root in the volume group /dev/vgroot, enter:

    lvcreate -C y -r n -n root /dev/vgroot

  2. Extend the root logical volume to the disk you’ve added. For example:

    lvextend -L 160 /dev/vgroot/root /dev/dsk/c0t3d0

  3. Specify that logical volume be used as the root logical volume:

    lvlnboot -r /dev/vgroot/root

Once the root logical volume is created, you will need to create a file system (see “Creating a File System”).

Backing Up and Restoring Volume Group Configuration

It is important that volume group configuration information be saved whenever you make any change to the configuration such as:

  • adding or removing disks to a volume group

  • changing the disks in a root volume group

  • creating or removing logical volumes

  • extending or reducing logical volumes

This is because unlike with fixed disk sections or nonpartitioned disks that begin and end at known locations on a given disk, each volume group configuration is unique, changes at times, and may use space on several disks.

As a result of your volume group configuration having been saved, you will be able to restore a corrupted or lost LVM configuration in the event of a disk failure or if your LVM configuration information is destroyed (for example, through the accidental or incorrect use of commands such as newfs or dd).

The vgcfgbackup command is used to create or update a backup file containing the volume group’s configuration. (vgcfgbackup does not back up the data within your logical volumes; use the backup procedures described in “Backing Up Data”). To simplify the backup process, vgcfgbackup is invoked automatically by default whenever you make a configuration change as a result of using any of the following commands:

  • lvchange

  • lvcreate

  • lvextend

  • lvlnboot

  • lvmerge

  • lvreduce

  • lvremove

  • lvrmboot

  • lvsplit

  • pvchange

  • pvmove

  • vgcreate

  • vgreduce

  • vgextend

You can display LVM configuration information previously backed up with vgcfgbackup or restore it using vgcfgrestore.

By default, vgcfgbackup saves the configuration of a volume group to the file /etc/lvmconf/volume_group_name.conf.

If you choose, you can run vgcfgbackup at the command line, saving the backup file in any directory you indicate. If you do, first run vgdisplay with the -v option to make sure that the all logical volumes in the volume group are shown as available/syncd; if so, then run:

vgcfgbackup -f pathname/filename volume_group_name

If you use a nondefault volume group configuration file, be sure to take note of and retain its location. Refer to vgcfgbackup(1M) for information on command options.

Before running vgcfgrestore, you need to deactivate the volume group with vgchange(1M).

For example, to restore volume group configuration data for /dev/dsk/c4t0d0, a disk in the volume group /dev/vgsales, enter:

vgchange -a n /dev/vgsales

vgcfgrestore -n /dev/vgsales /dev/rdsk/c4t0d0

This restores the LVM configuration to the disk from the default backup location in /etc/lvmconf/vgsales.conf.

To activate the volume group, run vgchange again:

vgchange -a y /dev/vgsales

Refer to vgcfgrestore(1M) for information on command options.

Moving and Reconfiguring Your Disks

There are occasions when you might need to:

  • move the disks in a volume group to different hardware locations on a system

  • move entire volume groups of disks from one system to another

CAUTION: Moving a disk which is part of your root volume group is not recommended. See Configuring HP-UX for Peripherals for more information.

The file /etc/lvmtab contains information about the mapping of LVM disks on a system to volume groups, that is, volume group names and lists of the physical volumes included in volume groups. When you do either of the above tasks, the LVM configuration file, /etc/lvmtab, must be changed to reflect the new hardware locations and device files for the disks. However, you cannot edit this file directly, since it is not a text file. Instead, you must use vgexport and vgimport to reconfigure the volume groups. This results in the configuration changes being recorded in the /etc/lvmtab file.

Moving Disks Within the System

To move the disks in a volume group to different hardware locations on a system, follow these steps:

  1. Make sure that you have an up-to-date backup for both the data within the volume group and the volume group configuration.

  2. Deactivate the volume group by entering:

    vgchange -a n /dev/vol_group_name
  3. Remove the volume group entry from /etc/lvmtab and the associated device files from the system by entering:

    vgexport /dev/vol_group_name
  4. Next, physically move your disks to their desired new locations.

  5. To view the new locations, enter:

    vgscan -v

  6. Now re-add the volume group entry back to /etc/lvmtab and the associated device files back to the system:

    1. Create a new directory for the volume groups with mkdir.

    2. Create a group file in the above directory with mknod.

    3. Issue the vgimport command:

      vgimport /dev/vol_group_name physical_volume1_path

  7. Activate the newly imported volume group:

    vgchange -a y /dev/vol_group_name

  8. Back up the volume group configuration:

    vgcfgbackup /dev/vol_group_name

Moving Disks Across Systems

The procedure for moving the disks in a volume group to different hardware locations on a different system is illustrated in the following example.

Suppose you want to move the three disks in the volume group /dev/vg_planning to another system. Follow these steps:

  1. Make the volume group and its associated logical volumes unavailable to users. (If any of the logical volumes contain a file system, the file system must be unmounted. If any of the logical volumes are used as secondary swap, you will need to disable swap and reboot the system; for information on secondary swap, see “Primary and Secondary Swap ”.)

    vgchange -a n /dev/vg_planning

  2. Use vgexport(1M) to remove the volume group information from the /etc/lvmtab file. You can first preview the actions of vgexport with the -p option.

    vgexport -p -v -m plan_map vg_planning

    With the -m option, you can specify the name of a map file that will hold the information that is removed from the /etc/lvmtab file. This file is important because it will contain the names of all logical volumes in the volume group.

    You will use this map file when you set up the volume group on the new system.

    If the preview is satisfactory, run the command without -p.

    vgexport -v -m plan_map vg_planning

    Now vgexport actually removes the volume group from the system. It then creates the plan_map file.

    Once the /etc/lvmtab file no longer has the vg_planning volume group configured, you can shut down the system, disconnect the disks, and connect the disks on the new system. Transfer the file plan_map to the / directory on the new system.

  3. On the new system, create a new volume group directory and group file.

    cd /
    mkdir /dev/vg_planning
    cd /dev/vg_planning

    When you create the group file, specify a minor number that reflects the volume group number. (Volume group numbering starts at 00; the volume group number for the fifth volume group, for example, is 04.)

    mknod /dev/vg_planning/group c 64 0x040000

  4. Add the disks to the new system.

    Once you have the disks installed on the new system, type

    ioscan -fun -C disk

    to get device file information for them.

  5. Now, issue the vgimport command. To preview, use the -p option.

    vgimport -p -v -m plan_map /dev/vg_planning \
      /dev/dsk/c6t0d0 /dev/dsk/c6t1d0 /dev/dsk/c6t2d0

    To actually import the volume group, re-issue the command omitting the -p.

  6. Finally, activate the newly imported volume group:

    vgchange -a y /dev/vg_planning

Moving Data to a Different Physical Volume

You can use pvmove to move data contained in logical volumes from one disk to another disk or to move data between disks within a volume group.

For example, you might want to move only the data from a specific logical volume from one disk to another to use the vacated space on the first disk for some other purpose. To move the data in logical volume /dev/vg01/markets from the disk /dev/dsk/c0t0d0 to the disk /dev/dsk/c1t0d0, enter

pvmove -n /dev/vg01/markets /dev/dsk/c0t0d0 \
  /dev/dsk/c1t0d0

On the other hand, you might prefer to move all the data contained on one disk, regardless of which logical volume it is associated with, to another disk within the same volume group. You might want to do this, for example, so you can remove a disk from a volume group. You can use pvmove to move the data to other specific disks you choose or let LVM move the data to appropriate available space within the volume group.

To move all data off disk /dev/dsk/c0t0d0 and relocate it at the destination disk /dev/dsk/c1t0d0, enter:

pvmove /dev/dsk/c0t0d0 /dev/dsk/c1t0d0

To move all data off disk /dev/dsk/c0t0d0 and let LVM transfer the data to available space within the volume group, enter:

pvmove /dev/dsk/c0t0d0

In each of the above instances, if space doesn’t exist on the destination disk, the pvmove command will not succeed.

Reducing the Size of a Logical Volume

You might want to reduce the size of a logical volume for several reasons:

  • Perhaps you want to use the logical volume for purposes other than the one you originally created it for and that will require less space. That is, you wish to convert the logical volume to an entirely different, smaller logical volume.

  • Another possibility is that since you have limited disk space, you might want to free up disk space for another logical volume on a disk by reducing the size of one that is bigger than you currently need.

  • Finally, if you want to reduce the size of a file system within a logical volume, you will first need to reduce the size of the logical volume. See “Replacing an Existing File System with a Smaller One ”.

You reduce the size of a logical volume using the lvreduce command.

If you are using the disk space for a new purpose and do not need the data contained in the logical volume, no backup is necessary. If, however, you want to retain the data that will go into the smaller logical volume, you must back it up first and then restore it once the smaller logical volume has been created.

As an alternate to using lvreduce, you can also use the lvremove command instead to remove the logical volume followed by lvcreate to create a new one.

CAUTION: Reduce the size of a logical volume ONLY if you no longer need its current contents, or if you have safely backed up the contents to tape or to another logical volume.

After reducing the size of a logical volume to a size smaller than a file system contained within the logical volume, you must re-create the file system as described in “Creating a File System”, and restore the files. Thus, it is critical to be aware of the size of the contents of a logical volume when you plan to reduce the size of the logical volume. See “Problems After Reducing the Size of a Logical Volume” for more information.

It is not a simple task to reduce the size of a given file system once it has been created. See “Reducing a Logical Volume” and “Replacing an Existing File System with a Smaller One ” for more information.

Setting Up Alternate Links to a Physical Volume

Alternate links to a physical volume were described earlier under “Increasing Availability with Alternate Links”. To use an alternate link, you can create a volume group with vgcreate specifying both the primary link and the alternate link device file names. Both must represent paths to the same physical volume. (Do not run pvcreate on the alternate link; it must already be the same physical volume as the primary link.) When you indicate two device file names both referring to the same disk using vgcreate, LVM configures the first one as the primary link and the second one as the alternate link.

For example, if a disk has two cables and you want to make one the primary link and the other an alternate link, enter:

vgcreate /dev/vg01 /dev/dsk/c3t0d0 /dev/dsk/c5t0d0

To add an alternate link to a physical volume that is already part of a volume group, use vgextend to indicate the new link to the physical volume. For example, if /dev/dsk/c2t0d0 is already part of your volume group but you wish to add another connection to the physical volume, enter:

vgextend /dev/vg02 /dev/dsk/c4t0d0

If the primary link fails, LVM will automatically switch from the primary controller to the alternate controller. However, you can also tell LVM to switch to a different controller at any time by entering, for example

pvchange -s /dev/dsk/c2t1d0

After the primary link has recovered, LVM will automatically switch back from the alternate controller to the original controller unless you previously instructed it not to by using pvchange as illustrated below:

pvchange -S n /dev/dsk/c2t2d0

The current links to a physical volume can be viewed using vgdisplay with the -v option.

Temporarily Detaching a Link to a Physical Volume

You can temporarily disable one or all of the physical paths, or links, to a physical volume using the pvchange command. Disabling a link, also known as detaching the link, causes LVM to close that path to the device and stop using it; this can be useful if you want to guarantee that a link is idle, such as when you are running diagnostics on an I/O card, replacing an I/O card, or replacing the disk containing the physical volume.

Detaching a link to a physical volume is intended to be a temporary operation, not a permanent one. If you want to permanently remove a link or physical volume from the volume group, use vgreduce instead.

To detach a link to a physical volume, use the -a option to pvchange. For example, to disable the link through the device /dev/dsk/c5t0d0, enter:

pvchange -a n /dev/dsk/c5t0d0

To detach all links to a physical volume, use N as the argument to the -a option:

pvchange -a N /dev/dsk/c5t0d0

Detaching one or more links to a physical volume will not necessarily cause LVM to stop using that physical volume entirely. If the detached link is the primary path to the device, LVM will begin using any available alternate link to it. LVM will only stop using the physical volume when all the links to it are detached.

If all the links to a device are detached, the associated physical volume will be unavailable to the volume group. The links remain associated with the volume group but no I/O requests will be queued to it by LVM until it is reattached. This means that the data on that physical volume will be temporarily unavailable; consequently, you as the adminstrator must make sure that any availability requirements for that data can be satisfied, by mirroring if necessary, before you make the device unavailable by detaching it.

Detaching a link does not disable sparing. That is, if all links to a physical volume are detached, and a suitable spare physical volume is available in the volume group, LVM will use it to reconstruct the detached disk. For more information on sparing, see “Maintaining High Availability in the Event of Disk Failure”.

You can view the status of all links to a physical volume using vgdisplay with the -v option.

Restoring a Detached Link to a Physical Volume

Restoring a detached link to a physical volume, or reattaching it, makes that link available to the volume group. LVM may begin using that link as necessary to access the disk.

To reattach a specific path to a physical volume, use the pvchange command with the -a option. For example, enter:

pvchange -a y /dev/dsk/c5t0d0

Because detaching a link to a physical volume is meant to be temporary, all detached links in a volume group are reattached when the volume group is activated, either at boot time or with an explicit vgchange command, such as:

vgchange -a y /dev/vg02

Setting Up Disk Striping

When you use disk striping, you create a logical volume that spans multiple disks, allowing successive blocks of data to go to logical extents on different disks. For example, a three-way striped logical volume has data allocated on three disks, with each disk storing every third block of data. The size of each of these blocks is referred to as the stripe size of the logical volume.

Disk striping can increase the performance of applications that read and write large, sequentially accessed files. Data access is performed over the multiple disks simultaneously, resulting in a decreased amount of required time as compared to the same operation on a single disk. If all of the striped disks have their own controllers, each can process data simultaneously.

You can use familiar, standard commands to manage your striped disks. For example, lvcreate(1M), diskinfo(1M), newfs(1M), fsck(1M), and mount(1M) will all work with striped disks.

The following guidelines, most of which apply to LVM disk usage in general, apply especially to striped logical volumes for performance reasons:

  • Best performance results from a striped logical volume that spans similar disks. The more closely you match the striped disks in terms of speed, capacity, and interface type, the better the performance you can expect. So, for example, when striping across several disks of varying speeds, performance will be no faster than that of the slowest disk.

  • If you have more than one interface card or bus to which you can connect disks, distribute the disks as evenly as possible among them. That is, each interface card or bus should have roughly the same number of disks attached to it. You will achieve the best I/O performance when you use more than one bus and interleave the stripes of the logical volume. For example, if you have two buses with two disks on each bus, the disks should be ordered so that disk 1 is on bus 1, disk 2 is on bus 2, disk 3 is on bus 1, and disk 4 is on bus 2, as depicted in Figure 6-4 “Interleaving Disks Among Buses”.

    Figure 6-4 Interleaving Disks Among Buses

    Interleaving Disks Among Buses
  • Increasing the number of disks may not necessarily improve performance. This is because the maximum efficiency that can be achieved by combining disks in a striped logical volume is limited by the maximum throughput of the file system itself and of the buses to which the disks are attached.

Follow these steps to create a a striped logical volume:

  1. Make the disks LVM disks using pvcreate.

  2. Put the disks in a new or existing volume group using vgcreate or vgextend.

  3. Create the striped logical volume, defining its striping characteristics using -i and -I options of lvcreate. The number of stripes must be in the range 2 up to the maximum number of disks in the volume group. The stripe size, the size of each of the blocks of data that make up the stripe in kilobytes, must be one of the following: 4, 8, 16, 32, or 64. If you plan to use the striped logical volume for a JFS (VxFS) file system, then using a block size of 64KB is recommended.

    So, suppose you wish to stripe across three disks. You decide on a stripe size of 32 kilobytes. Your logical volume size is 24 megabytes. To create the striped logical volume, you would enter:

    lvcreate -i 3 -I 32 -L 24 -n lvol1 /dev/vg01

    lvcreate automatically rounds up the size of the logical volume to a multiple of the number of disks times the extent size.

    For example, if you have three disks you wish to stripe across and choose the default of 4MB extents, even though you indicate a logical volume size of 200 (-L 200), lvcreate will create a 204MB logical volume since 200 is not a multiple of 12.

    NOTE: When you stripe across multiple disks, the striped volume size cannot exceed the capacity of the smallest disk multiplied by the number of disks used in the striping.

    For guidelines on determining an optimum stripe size, see “Determining Optimum Stripe Size”.

Determining Optimum Stripe Size

The logical volume’s stripe size identifies the size of each of the blocks of data that make up the stripe. You can set the stripe size to four, eight, 16, 32, or 64 kilobytes (KB) (the default is eight KB).

NOTE: The stripe size of a logical volume is not related to the physical sector size of a disk, which is typically 512 bytes.

How you intend to use the striped logical volume determines what stripe size you assign to it.

For best results:

  • If you plan to use the striped logical volume for an HFS file system:

    Select the stripe size that most closely reflects the block size of the file system. The newfs command lets you specify a block size when you build the file system and provides a default block size of eight KB for HFS.

  • If you plan to use the striped logical volume for a JFS (VxFS) file system:

    Use the largest available size, 64KB. For I/O purposes, JFS combines blocks into extents, which are variable in size and may be very large. The configured block size, 1KB by default (which in any case governs only direct blocks), is not significant in this context. See “Frequently Asked Questions about the Journaled File System” for more information.

  • If you plan to use the striped logical volume as swap space:

    Set the stripe size to 16KB for best performance. See “Setting Up Logical Volumes for Swap” and “Configuring Primary and Secondary Swap ” for information on configuring swap.

  • If you plan to use the striped logical volume as a raw data partition (for example, for a database application that uses the device directly):

    The stripe size should be the same as the primary I/O size for the application.

You may need to experiment to determine the optimum stripe size for your particular situation. To change the stripe size, you will need to re-create the logical volume.

LVM Troubleshooting

If You Can’t Boot From a Logical Volume

If you cannot boot from a logical volume, a number of things might be responsible for this situation. In addition to the same kinds of problems associated with boots from non-LVM disks, any of the following could cause an LVM-based system not to boot:

  • With LVM disks, there are pointers to the root file system, primary swap area, and dump area located within the BDRA at the beginning of each bootable LVM disk, along with information about the size of each of these areas. These LVM pointers may have become corrupted, not current, or just no longer present. Because of the importance of maintaining up-to-date information within the BDRA, remember to use the lvrmboot and/or lvlnboot commands whenever you make a change that affects the location of the root, boot, primary swap, or dump logical volumes.

  • The system thinks it is trying to configure a root, swap, or dump area on a logical volume, but the disk it is attempting to use is not an LVM disk.

  • The system tries to boot from a disk partition that has LVM information on it.

  • Not enough disks are present in the root volume group to make a quorum. At boot time, you will see a message indicating that not enough physical volumes are available.

The first and last of these items will now be discussed in further detail.

Booting When LVM Data Structures Are Lost

When critical LVM data structures have been lost, you will need to use the recovery portion of the Support Media included in the HP-UX product kit to restore the corrupted disk image from your backup tape. For more information, see Appendix B of the Support Media User’s Manual.

After you have made the LVM disk minimally bootable, the system can be booted in maintenance mode using the -lm option of the hpux command at the ISL> prompt. This causes the system to boot to single-user state without LVM or dump but with access to the root file system.

Maintenance mode is a special way to boot your system that bypasses the normal LVM structures. It should be used only for problems that prevent the system from otherwise booting. It is similar to single-user state in that many of the processes that normally get started are not started, nor are many of the system checks that are normally performed. It is intended to allow you to boot your system long enough for you to repair damage to your system’s LVM data structures typically using vgcfgrestore which should then allow you to boot your system normally.

The system must not be brought to multiuser state (that is, run-level 2 or greater) when in LVM maintenance mode. Also, do not activate the root volume group. Corruption of the root file system might result.

To exit LVM maintenance mode, use reboot -n.

When a Volume Group Will Not Activate

Normally, volume groups are automatically activated during system startup. Unless you intentionally deactivate a volume group using vgchange, you will probably not need to activate a volume group. However, LVM does require that a quorum of disks in a volume group be available. During bootup, LVM needs a quorum of more than half of the disks that are included in the root volume group for activation of that volume group; this means the majority of these disks must be online and in service. Thus, if there are two disks in the root volume group, the more than half requirement means that both will need to be available. To successfully boot the system, LVM will require a quorum of one more than half of the disks in the root volume group.

Another possible problem pertaining to activation of a volume group is a missing or corrupted /etc/lvmtab file. You can use the vgscan(1M) command to re-create the /etc/lvmtab file.

During run time, once a volume group is already active, if a disk fails or is taken off line, quorum may become lost. This will occur if less than half of the physical volumes defined for the volume group now remain available. For example, if there are two disks in the volume group, the loss of one would not cause a loss of quorum, as is the case when booting; rather, both disks would need to become unavailable. If this happened, your volume group will still remain active; however, a message will be printed to the console indicating that the volume group has lost quorum. Until the quorum is restored (at least one of the LVM disks in the volume group in the above example is once again available), LVM will not allow you to complete most commands that affect the volume group configuration. Further, some of the I/O accesses to the logical volumes for that volume group may hang because the underlying disks are not accessible. Also, until quorum is restored, the Mirror Write Cache (MWC) will not be updated because LVM cannot guarantee the consistency (integrity) of the LVM information.

Even when allowed by LVM, it is recommended that you do not make changes to the LVM configuration for active volume groups that do not have a quorum of disks present.

There are ways to override quorum requirements at volume group activation time, or at boot time. These will be discussed in the following two sections. However, the recommended way to correct this problem is to return the unavailable disks to service.

Quorum Problems with a Non-Root Volume Group

If you attempt to activate a nonroot volume group when not enough disks are present to establish a quorum, you will see error messages similar to the following:

vgchange -a y /dev/vg01
vgchange: Warning: Couldn't attach to the volume group
physical volume "/dev/dsk/c1t0d2":
The path of the physical volume refers to a device that does not exist, or is not configured into the kernel.
vgchange: Couldn't activate volume group "/dev/vg01":
Either no physical volumes are attached or no valid VGDAs were found on the physical volumes.

If a nonroot volume group does not get activated because of a failure to meet quorum, try the following:

  1. Check the power and data connections of all the disks that are part of the volume group that you cannot activate. Return all disks (or, at least enough to make a quorum) to service. Then, use the vgchange command to try to activate the volume group again.

  2. If there is no other way to make a quorum available, the -q option of the vgchange command will override the quorum requirement.

    vgchange -a y -q n /dev/vg01

    As a result, the volume group will activate without a quorum being present. You might get messages about not being able to access certain logical volumes. This is because part or all of a logical volume might be located on one of the disks that is not present.

    Whenever you override a quorum requirement, you run the risk of using data that are not current. Be sure to check the data on the logical volumes in the activated volume group as well as the size and locations of the logical volumes to ensure that they are up-to-date.

    You should attempt to return the disabled disks to the volume group as soon as possible. When you return a disk to service that was not online when you originally activated the volume group, you should once again use vgchange.

    vgchange -a y /dev/vg01
Quorum Problems with Your Root Volume Group

Your root volume group might also have a quorum problem. If there are not enough disks present in the root volume group to constitute a quorum, a message indicating that not enough physical volumes are present will be displayed during the boot sequence. This might occur if you have physically removed a disk from your system because you no longer intended to use it with the system, but did not remove the physical volume from the volume group using vgreduce. Although you should never remove an LVM disk from a system without first removing it from its volume group, you can probably recover from this situation by booting your system with the quorum override option, hpux -lq.

Problems After Reducing the Size of a Logical Volume

When a file system is first created within a logical volume, it is made as large as the logical volume will permit.

If you extend the logical volume without extending its file system, you can subsequently safely reduce the logical volume’s size as long as it remains as big as its file system. (Use bdf(1M) to determine the size of your file system.) Once you use the extendfs command to expand the file system, you can no longer safely reduce the size of the associated logical volume.

If you reduce the size of a logical volume containing a file system to a size smaller than that of a file system within it using the lvreduce command, you will corrupt the file system. If you subsequently attempt to mount the corrupt file system, you may crash your system. If this occurs:

  1. Reboot your system in single-user state.

  2. If you already have a good current backup of the data in the now corrupt file system, skip this step.

    Only if you do not have such backup data and if those data are critical, you may want to try to recover whatever part of the data that may remain intact by attempting to back up the files on that file system in your usual way.

    Before you attempt any current backup, you need to be aware of two things:

    • When your backup program accesses the corrupt part of the file system, your system will crash again. You will need to reboot your system again to continue with the next step.

    • There is no guarantee that all (or any) of your data on that file system will be intact or recoverable. This is merely an attempt to save as much as possible. That is, any data successfully backed up in this step will be recoverable, but some or all of your data may not allow for successful backup because of file corruption.

  3. Immediately unmount the corrupted file system, if it is mounted.

  4. You can now use the logical volume for swap space or raw data storage, or use SAM or the newfs command to create a new file system in the logical volume. This new file system will now match the current reduced size of the logical volume.

  5. If you have created a new file system on the logical volume, you can now do one of the following:

    • If you have a good prior backup (NOT the backup from step 2), restore its contents. Because the new file system in the smaller logical volume will be smaller than the original file system, you may not have enough space to restore all your original files.

    • If you do not have a good prior backup, attempt to restore as many files as possible from any backup you made in step 2. Again, there is no guarantee that complete data will be recoverable from this backup.

    • Use the new file system for creating and storing a new set of files (not for trying to restore the original files).

Handling I/O Errors within LVM

When a device driver returns an error to LVM on an I/O request, LVM classifies the error as either non-recoverable or recoverable. How those errors are handled determines your course of action.

Non-Recoverable Errors

Non-recoverable errors are considered fatal; there’s no expectation that retrying the operation could work. LVM considers two specific situations as non-recoverable:

  • If an I/O request fails because of a media error — LVM will log a message to the console when the error occurs.

  • If the device associated with the I/O was not present when the volume group was activated — LVM will print an error message to the user’s terminal and log it to the console, but only when the volume group is activated.

If you have a current copy of the data on a separate, functioning mirror, then LVM directs reads and writes to a mirror copy. As far as the application accessing the logical volume is concerned, the I/O operation completes successfully.

However, if you have no other copies of the data — that is, the only copy of the data is on that physical volume — then LVM returns an error to whatever subsystem is accessing the logical volume. This means that any application directly accessing a logical volume should be prepared for I/O requests to fail. File systems such as VxFS and most database applications are designed to recover from error situations; for example, if VxFS encounters an I/O error, it may disable access to a file system or a subset of the files in it.

Dealing with Non-Recoverable Errors

How you deal with a non-recoverable error depends on what kind of problem LVM encountered. For a media error, you’ll have to replace the disk; for a procedure to do that, see “Replacing a Mirrored Disk”. For a device that wasn’t present at activation time, either locate the disk and restore it to service, or replace it using the same procedure, then activate the volume group again.

Recoverable Errors

When LVM encounters a recoverable, or “correctable” error, it will internally retry the failed operation, under the assumption that the error will correct itself, or that you as system administrator can take steps to correct it. Examples of recoverable errors are device power failure, a disk that goes missing after the volume group is activated, or a loose disk cable — which can manifest itself as a missing disk. In these cases, LVM will log an error message to the console, but it will not return an error to the application accessing the logical volume.

If you have a current copy of the data on a separate, functioning mirror, then LVM directs the I/O to a mirror copy, much as it would for a non-recoverable error. Applications accessing the logical volume will not see any error. (To preserve data synchronization between its mirrors, LVM will retry recoverable write requests to a problematic disk, even if there’s a current copy elsewhere; however, this is managed by a daemon internal to LVM, and has no impact on user access to the logical volume.)

If, however, the device in question holds the only copy of the data, LVM will retry the I/O request until it succeeds — that is, until the device responds or the system is rebooted. Any application performing I/O to the logical volume may block, waiting for the device to recover. In this case, your application or file system may appear to be “hung,” and may be unresponsive.

Dealing with Recoverable Errors

By default, LVM will retry I/O requests with recoverable errors until they succeed or the system is rebooted. Therefore, if an application or file system hangs, your troubleshooting should include checking the console log for problems with your disk drives, and taking action to restore the failing devices to service.

If for some reason retrying the I/O request will never succeed — such as if the disk was physically removed and taken away — your application or file system may block indefinitely. If your application is not responding, you may have to reboot your system.

As an alternative to rebooting, you can control how long LVM will retry a recoverable error before treating it as non-recoverable, by setting a timeout on the logical volume.

Logical Volume Timeouts

The -t option to the lvchange command sets the timeout value in seconds for a logical volume. For example, to set the timeout for /dev/vg01/lvol1 to one minute, enter:

lvchange -t 60 /dev/vg01/lvol1

This command sets the maximum length of time that LVM will retry an I/O request. If the device fails to respond within that time, LVM will return an I/O error to the caller. The timeout value is normally zero, which is interpreted as an infinite timeout; thus, by default no I/O request will return to the caller until it completes successfully.

If you want to enable a timeout on a logical volume, you should set it to an integral multiple of any timeout assigned to the underlying physical volume(s). Otherwise, the actual duration of the I/O request may exceed the logical volume’s timeout. See pvchange(1M) for details on how to change the I/O timeout value on a physical volume.

You can view the timeout value for a logical volume using the lvdisplay command.

CAUTION: Setting a timeout on a logical volume increases the likelihood of transient errors being treated as non-recoverable errors, so any application that reads or writes to the logical volume may experience I/O errors. If your application is not prepared to handle such errors, keep an infinite logical volume timeout.

No Response or Program Output from a Disk

You might occasionally see long periods of apparent inactivity by programs that are accessing disks. Such programs may be “hung”, waiting for access to a currently inaccessible disk. Messages indicating the disk is offline will also appear on your system console.

If the logical volume is mirrored on to another disk, LVM marks the disk as offline and continues the operation on any remaining mirror disk. If the logical volume is not mirrored, or if the mirror copies of the logical volume are also not available, the program will remain hung until a disk becomes accessible. Therefore, if your program hangs, you should check for problems with your disk drives and, if necessary, restore them to service as soon as possible.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997-2006 Hewlett-Packard Development Company, L.P.