| United States-English |
|
|
|
![]() |
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 |
|
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. 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:
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.
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. 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.
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.
Continue by following these additional steps:
Once the root logical volume is created, you will need to create a file system (see Chapter 4). It is important that volume group configuration information be saved whenever you make any change to the configuration such as:
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:
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(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:
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. 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:
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:
Refer to vgcfgrestore(1M) for information on command options. There are occasions when you might need to:
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. To move the disks in a volume group to different hardware locations on a system, follow these steps:
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:
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
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:
To move all data off disk /dev/dsk/c0t0d0 and let LVM transfer the data to available space within the volume group, enter:
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. You might want to reduce the size of a logical volume for several reasons:
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.
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:
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:
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
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:
The current links to a physical volume can be viewed using vgdisplay with the -v option. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||