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-UX System Administration Tasks: HP 9000 > Chapter 3 Managing Disks Using the Logical Volume Manager (LVM)

Tasks That You Can Perform Only with HP-UX Commands

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

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

  • Extending a logical volume to a specific disk.

  • Creating the root volume group and a root logical volume.

  • Backing up and restoring a volume group configuration.

  • Moving and reconfiguring your disks.

  • Moving data from one LVM disk to another.

  • Reducing the size of a logical volume.

  • Setting up alternate cables to a physical volume.

How to do each of these tasks is shown next.

Extending a Logical Volume to a Specific Disk

Suppose you want to create a 300MB logical volume and put 100MB on your first disk, another 100MB on your second disk, and 100MB 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 275MB logical volume that resides on only one of the disks. You want to extend the logical volume size to 400MB, making sure the 125MB 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 the Root Volume Group and a Root Logical Volume

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 swap logical volume, and one or more dump logical volumes. (Additionally, there could be other logical volumes which might be used for user data.) The root logical volume is the logical volume that is used to boot the system. The root logical volume must be contained on a single disk. See Chapter 6 for more information on the swap and dump logical volumes.

When you boot from a particular physical volume that comprises your root logical volume, that disk must contain a special area called a boot area. The boot area contains the programs and information necessary to locate, load, and run the HP-UX kernel, including the secondary loader program, ISL. The root logical volume also contains the operating system software.

If you newly install your 10.01 system and choose the LVM configuration, a root volume group is automatically configured. If you later 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 modifications, if you need to modify an existing root logical volume, including increasing its size. 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. Also see "Converting Your Current Root Disk by Using a Spare Disk" later in the chapter.

  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 the extended "Example" under "Managing Logical Volumes 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 (52.3.0;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. The root logical volume must be the first logical volume found on the bootable LVM disk. 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 Chapter 4).

Backing Up and Restoring Your 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 non-partitioned 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 Chapter 9 for this.) 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

lvreduce

pvmove

lvcreate

lvremove

vgcreate

lvextend

lvrmboot

vgextend

lvlnboot

lvsplit

vgreduce

lvmerge

pvchange

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

Running vgcfgbackup

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(1M) 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 non-default volume group configuration file, be sure to take note of and retain its location. Refer to vgcfgbackup(1M) for information on command options.

Running vgcfgrestore

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

NOTE: Moving a disk which is part of your root volume group is not supported.

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(1M) and vgimport(1M) to reconfigure the volume groups. This results in the configuration changes being recorded in the /etc/lvmtab file.

Moving Disks Within Your 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 a 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; for information, see Chapter 4. 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 Chapter 6.)

    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 mapfile 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 mapfile 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. 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.

  4. 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
  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.

Also see "Moving a Mirrored Logical Volume from One Disk to Another" in Chapter 7 for an additional example involving mirroring.

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 purpose 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" in Chapter 4.

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 Chapter 4, 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" later in this chapter for more information.

It is not a simple task to reduce the size of a given file system once it has been created. See "Replacing an Existing File System with a Smaller One" in Chapter 4 for more information.

Setting Up Alternate Links to a Physical Volume

Alternate links to a physical volume were described earlier in the chapter. 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.

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