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