Volume Groups
•
Portability of volume groups
•
Mix and Match disks
•
Volume Group Descriptor Area
•
Volume Group Status Area
•
Quorum
•
VGID
•
A Graphical View of VGDA expansion
Portability of volume groups
The one great attribute of LVM is the ability of the user to take a disk or sets of disks that make up a volume group and take it to another system and introduce the information created on another machine onto the second machine.This ability is provided through the Volume Group Descriptor Area (VGDA) and the logical volume control block (lvcb). The design of LVM also allows for accidental duplication of volume group and logical volume names. If on the new machine,the volume group or logical volume names being imported already exist, then LVM will generate a distinct volume group or logical volume name.
Mix and Match disks
LVM allows the user to attach disks to volume group, regardless of what type of physical device it true is or what type of device driver is used to operate the device. Thus, RAID systems, serial dasd drives, and the plain SCSI drives can all make up one volume group that may reside across several adapters. The physical location of each drive and the true nature of the drive doesn’t matter to LVM as long as the disk device drivers follow a certain format required by LVM in order to create logical volumes on those drives
Volume Group Descriptor Area
The VGDA is an area at the front of each disk which contains information about the volume group, the logical volumes that reside on the volume group and disks that make up the volume group. For each disk in a volume group, there exists a VGDA concerning that volume group. This VGDA area is also used in quorum voting. The VGDA contains information about what other disks make up the volume group. This information is what allows the user to just specify one of the disks in the volume group when they are using the “importvg” command to import a volume group into an AIX system. The importvg will go to that disk, read the VGDA and find out what other disks (by PVID) make up the volume group and automatically import those disks into the system (and its) ODM as well. The information about neighboring disks can sometimes be useful in data recovery. For the logical volumes that exist on that disk, the VGDA gives information about
that logical volume so anytime some change is done to the status of the logical volume (creation, extension, or deletion), then the VGDA on that disk and the others in the volume group must be updated.
Volume Group Status Area
The Volume Group Status Area (VGSA) is comprised of 127 bytes, where each bit in the bytes represents up to 1016 Physical Partitions that reside on each disk. The bits of the VGSA are used as a quick bit-mask to determine which Physical Partitions, if any, have become stale. This is only important in the case of mirroring where there exists more than one copy of the Physical Partition. Stale partitions are flagged by the VGSA. Unlike the VGDA, the VGSA’s are specific only to the drives which they exist. They do not contain information about the status of partitions on other drives in the same volume group. The VGSA is also the bit masked used to determine which physical partitions must undergo data resyncing when mirror copy resolution is performed.
Quorum
Quorum is a sort of “sanity” check that LVM uses to resolve possible data confliction and prevent data corruption. Quorum is a method by which 51% or more quorum votes must be available to a volume group before LVM actions can continue.
Quorum is issued to a disk in a volume group according to how the disk was created within the volume group. When a volume group consists of one disk, there are two VGDA’s on that disk. Thus, this single disk volume group has a quorum vote of 2. When another disk is added to the volume group with an “extendvg”, then this new disk gets one VGDA, but the original, first disk still retains the two VGDA’s. When the volume group has been extended to three disks, the third disk gets the spare VGDA sitting on the first disk and then each disk has a quorum vote of 1. Every disk after the third disk is automatically given one VGDA, and thus one vote.
VGID
Just as the PVID is a soft serial number for a disk, the VGID is the soft serial number for the volume group. It is this serial number, not the volume group’s ascii name, which all low level LVM commands reference. Additionally, it is the basis for the LVIDs created on that VGID.
A Graphical View of VGDA Expansion
This shows how the VGDA grows from one disk to another and how information is carried in the VGDA which crossreferences information among the disks in a volume group.
In these examples, you see how the VGDA is used to monitor disks and logical volumes that belong to a volume group. InCase A, the volume group, samplevg, contains only hdisk0. The example also shows how the VGDA holds the map forthe logical volume lv00. There is no VGDA represented on hdisk1 since it is not part of the samplevg. However, it may bethe case that hdisk1 contains some long-forgotten VGDA from a previous volume group. But since the VGDA forsamplevg has no record of hdisk1 belonging to the volume group, hdisk1 is ignored in samplevg’s eyes.
Case B is an example of the aftermath of an extendvg of samplevg into hdisk1. A copy of the VGDA from hdisk0 is placed onto hdisk1. But, notice that the VGDA has also been updated on hdisk0 to reflect the inclusion of a new disk into the volume group. Although lv00 does not exist on hdisk1, the VGDA on hdisk1 will have a record of the lv00 mapping sitting on another disk since it’s part of the same volume group.
Case C shows the result of the creation of two logical volumes, lv01 and lv02, onto hdisk1. This is to show how the VGDA sitting on hdisk0 is updated with the activity that is being conducted on another disk in the volume group.
One critical point from this information is that since the VGDA on each disk in a volume group “knows its neighbors" business”, then sometimes this information about neighboring disks can be used to recover logical volumes residing on other the other drives. This usually happens works if the VGDA on a disk is missing or corrupted. However, this is invalid in the cases where the disk is truly dead or if the volume group is only made up of one disk.
Volume group related commands
********************************
#smitty vg
Listing volume group characteristics
#lsvg rootvg
List the volume groups in the system
#lsvg
List of all volume groups that are currently active (varied on)
#lsvg –o
Information about all of the PV’s with in the volume group
#lsvg –p rootvg
Information about the entire LV’s with in the volume group
#lsvg –l rootvg
To list the physical volume status within a volume group
#lsvg –p rootvg
To create a volume group
#smitty mkvg or mkvg –s 2 –t 2 –y newvg hdisk1
To remove a physical volume from a VG, if it is the last PV, the VG will be removed.
#reducevg –d rootvg hdisk1
To add a new PV to an existing VG
#extendvg –f rootvg hdisk1
To change the startup characteristics of a VG
#smitty chvg
To activate VG (make it available for use)
#varyon –f datavg
To deactivate a VG (make it unavailable for use)
#varyoffvg datavg
Unlocking a Volume Group
A volume group can become locked when an LVM command terminates abnormally, due to a system crash while an LVM operation was being performed on the system.
To unlock the datavg volume group
#chvg –u datavg
Logical Track Group Size (LTG)
Flexible LTG size for better disk I/O performance.
The logical track group size corresponds to the maximum allowed transfer size for disk I/O. To take advantage of these larger transfer sizes and achieves better disk I/O performance.
The supported LTG size was 128 KB, the accepted values are 128, 256, 512, 1024 KB.
To find the LTG size
#/usr/sbin/lquerypv –M hdisk0
256
To set the LTG size
#mkvg or chvg
To change the LTG size, the volume group must be varied on, the logical volumes must be closed, and file systems must be unmounted.
Hot Spare
A hot spare is a disk or group of disks used to replace failing disk. LVM marks a physical volume missing due to write failures. It then starts the migration of data to the hot spare disk.
Minimum hot spare requirements are
Spares are allocated and used by volume group
Logical volumes must be mirrored
All logical partitions on hot spare disks must be unallocated
Hot spare disks must have at least equal capacity to the smallest disk already in the volume group.
Hot spare policy and synchronization policy are applied using chpv and chvg commands.
Examples:
It marks hdisk1 as a hot spare disk
#chpv –hy hdisk1
The following command sets an automatic migration which uses the smallest hot spare that is large enough to replace the failing disk, and automatically tries to synchronize stale partitions
#chvg –hy –sy testvg
How to set up hot sparing
Step1: Decide which volume groups with mirrored logical volumes require high availability.
Step2: Decide how many hot spare disks are required and how large the hot spare disks must be, based on the existing disks in the volume group.
Step3: Add the hot spares to the volume groups which they are to protect by using extendvg command.
Step4: Decide which hot spare policy will be most effective for your volume groups.
Step5: Designate the selected disks as hot spares by using chpv command.
Step6: Decide which synchronization policy meets the business needs and set the policy by using chvg command.
Importing and exporting a volume group
If you have a volume group on one or more removable disks that you want to access on another system, you must first export the volume group from the current system using the exportvg command. This removes any information about the volume group from the system. To export a volume group it must be inactive.
To access an exported volume group on a system, it must be imported to the system using the importvg command. Do not attempt to import a rootvg.
Note: To remove the system definition of a volume group from the ODM database, the volume group needs to be exported using the exportvg command. This command will not remove any user data in the volume group, but will only remove its definition from the ODM database. Similarly, when a volume group is moved, the target system needs to add he definition of the new volume group. This can be achieved by importing the volume group by using the importvg command, which will add an entry to the ODM Database.
To export a volume group
#exportvg datavg or smitty exportvg
To import a volume group
#importvg datavg or smitty importvg
Note: It is also possible that some logical volume names may also conflict with those already on the system. The importvg command will automatically reassign these with system default names.
Steps:
#lspv
#varyoffvg datavg
#exportvg datavg
#importvg datavg
#varyonvg datavg
#lspv
Note: If you imported a volume group that contains file systems or if you activated the volume group through smitty importvg, it is highly recommended that you run the fsck command before you mount the file systems.
Note: The smitty exportvg command deletes references to file systems in /etc/filesystems, but it leaves the mount points on the system.
Reorganizing a volume group
The reorgvg command is used to reorganize the physical partition allocation for a volume group according to the allocation characteristics of each logical volume. The volume group must be varied on and must have free partitions before you can use the reorgvg command.
Examples:
To reorganizes the logical volumes lv03, lv04 and lv07 on VG datavg
#reorgvg datavg lv03 lv04 lv07
To reorganize the partitions located on physical volumes hdisk04 and hdisk06 that belong to the logical volumes lv04 and lv06
#echo “hdisk04 hdisk06”
reorgvg –i datavg lv04 lv06
Synchronizing a Volume group
The syncvg command is used to synchronize logical volume copies that are not current (stale). The syncvg command synchronizes the physical partitions which are copies of the original physical partition that are not current. The syncvg command can be used with logical volumes, physical volumes or volume groups. Unless disabled the copies within a volume group are synchronized automatically when the volume group is activated by the varyonvg command.
Examples:
To synchronize the copies on hysical volumes hdisk04 and hdisk05
#syncvg –p hdisk04 hdisk05
To synchronize the copies on volume groups datavg and sapvg
#syncvg –v datavg sapvg