| United States-English |
|
|
|
![]() |
HP Servers and Workstations: Managing Systems and Workgroups > Chapter 6 Administering a System: Managing
Disks and FilesManaging Disks |
|
This section provides practical guidance in managing disks under HP-UX. It covers the following topics:
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.
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.
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”. To get a rough estimate of how big to make a logical volume which will contain your file system, do the following:
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.
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:
For more detailed information on this procedure, see “Extending a Logical Volume to a Specific Disk ”. 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 ”. 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. 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
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.
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.
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 ”. 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. Physical volumes are identified by their device file names, for example: /dev/dsk/cntndn 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:
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. 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. 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:
If you create a logical volume to contain raw data for a sales database, you might want to name it using a nondefault name:
After the logical volume in the above example has been created, it will have two device files:
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. SAM enables you to perform most, but not all, LVM management tasks. Tasks that can be performed with SAM include:
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. 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
Table 6-3 Commands Needed for Volume Group Management Tasks
Table 6-4 Commands Needed for Logical Volume Management Tasks
To create a logical volume, do the following procedure:
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 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:
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.
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.
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.
Continue by following these additional steps:
Once the root logical volume is created, you will need to create a file system (see “Creating a File System”). 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 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:
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. 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 and vgimport 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. 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.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||