The fundamental concept used by lvm are
1.physical volume
2.volume group
3. physical partition
4.logical volume
5.logical partitions
6. filesystems
7. raw devices
each individual disk drive is named as physical volume such as hdisk0,hdisk1.
one or more pv's can make up a volume group(VG). a pv can belong to maximum of one vg
you can't assign a fraction of pv to one VG
physical volumes can be assigned to the same VG even though they are of different type such as SCSI or SSA.
The storage space from physical volume is divided into physical partitions(PP's)
the size of PP's are identical on all disks belonging to the same VG.
Within each VG ,one or more logical volume(LV) can be defined.
Data stored on logical volumes appears to be contiguous from user point of view ,but can be spread on different pv from the same VG.
Each LV consists of one or more logical partitions(LP's). Each logical partitions corresponds to atleast one
physical partition(PP).
If mirroring is specified for the logical volume,additional pp's are allocated to store the additional copies of each logical partitions.
LOGICAL VOLUME MANAGER
the set of operating system commands,library subroutines and other tools that allows you to eastablish and control logical volume storage is called the logical volume manager(LVM).
LVM controls disk resources by mapping data between a more simple and flexible logical view of storage space and the actual physical disks
.
LVM CONFIGURATION DATA
The data that describes the components of the LVM is kept in several places:
1. ODM database
2.Volume Group Descriptor Area(VGDA)
3.Volume group Status Area(VGSA)
4. Logical Volume control block
1.ODM DATABASE
The ODM database is the place where most of the aix system configuration data is kept.
the ODM database contains information about all
PV
LV
VG
this information mirrors the information found in the VGDA.
the process of importing a VGDA involves automatically copying the VGDA data for the imported VG into ODM.
when the VG is exported ,the data held in the ODM about the VG is removed from ODM database.
ODM data also mirrors the information held in the logical volume control block(LVCB).
2. VOLUME GROUP DESCRIPTOR AREA(VGDA)
TheVGDA located at the beginning of each pv ,contains the information that describes
1. all logical volumes that belongs tp that particular VG
2. all physical volumes that belongs to particular VG
VGDA makes each VG self-describing.
An AIX system can read the VGDA kept on the disk and can determine which PV and LV are partof that particular VG.
Each disk has atleast one VGDA
VGDA is allocated when the disk is assigned as a PV(mkdev command). This reserves a space for the VGDA at the start of the disk.
Actual volume group information is placed in the VGDA when the PV is assigned to the VG.
3.VOLUME GROUP STATUS AREA(VGSA)
the VGSA contains state information about physical partitions and physical volumes.
VGSA knows if one PV in a VG is unavailable.
Both the VGDA and VGSA have beginning and ending timestamps. these timestamps enables the LVM to identify the most recent copy of the VGSA and VGDA .
LOGICAL VOLUME CONTROL BLOCK(LVCB)
LVCB is located at the start of every logical volume .it contains information about the logical volume and uses a few hundred bytes.
"getlvcb" command displays the information held in LVCB
#getlvcb -AT hd2
DISK QUORUM.
each physical disk in a VG has atleast one VGDA/VGSA.
the no. of VGDA'S contained on a single disk varies according to the no. of disks in the VG.
1. single disk in a VG ---------- Two VGDA on one disk
2. Two PV in a VG -------------- two VGDA on the first disk , one on the second disk.
3. three or more PV in a VG -------- one VGDA on each disk.
A QUORUM is a state in which 51% or more of the PV in a VG are accessible.
it is a vote of a no. of VGDA and VGSA that are active.
quorum ensures data integrity in the event of disk failure.
when quorum is lost,the VG varies off itself so that the disks are no longer accessible by the LVM.
this prevent further disk I/O to the volume group so that data is not lost or assumed to be written when there is physical problems.
also as the result of varyoff,the user is notified in the errorlog that a hardware error has occured and service must be performed.
PHYSICAL VOLUME
when a disk is initially added to the system,it seems to be simple device. that disk is not yet accessible for LVM operations.
to be made accessible ,it has to be assigned to the volume group.
For each disk , two device drivers will be created under the /dev directory
1. one block device driver
2. one character device driver.
each disk drive is assigned a 32-bit unique identifier that is called PVID.
PVID are stored on ODM.
change the available disk device to the PV by assigning a PVID
#chdev -l hdisk7 -a pv=yes
to clear the PVID from physical volume
#chdev -l hdisk7 -a pv=clear
listing information about physival volume
#lspv ----list all PV'S ,there PVID ,VG and the status of VG of which the disk is the member.
#lspv hdisk2 ---to list the attributes of that particular PV
# lspv hdisk2
PHYSICAL VOLUME: hdisk2 VOLUME GROUP: testvg
PV IDENTIFIER: 00c478de09caf37f VG IDENTIFIER 00c478de00004c00000001078fc3497d
PV STATE: active STALE PARTITIONS: 0
ALLOCATABLE: yes PP SIZE: 128 megabyte(s)
LOGICAL VOLUMES: 1 TOTAL PPs: 546 (69888 megabytes)
VG DESCRIPTORS: 2 FREE PPs: 542 (69376 megabytes)
HOT SPARE: no USED PPs: 4 (512 megabytes)
MAX REQUEST: 256 kilobytes
FREE DISTRIBUTION: 110..105..109..109..109
USED DISTRIBUTION: 00..04..00..00..00
the important parameters that we can change in above outputs:
1.allocatable
2. pv state
3. hot spare
#lspv -l hdisk0 --- to display the names of all logical volumes that have atleast one partitions located on hdisk0
# lspv -l hdisk0
hdisk0:
LV NAME LPs PPs DISTRIBUTION MOUNT POINT
hd3 1 1 00..00..01..00..00 /tmp
hd10opt 1 1 00..00..01..00..00 /opt
hd5 1 1 01..00..00..00..00 N/A
hd8 1 1 00..00..01..00..00 N/A
hd6 11 11 00..00..11..00..00 N/A
hd2 8 8 00..00..08..00..00 /usr
hd9var 1 1 00..00..01..00..00 /var
hd1 1 1 00..00..01..00..00 /home
hd4 1 1 00..00..01..00..00 /
#lspv -p hdisk1 ------to display the pp range ,state and the LV that corresponds tp that PP'S and there mountpoints.
# lspv -p hdisk0
hdisk0:
PP RANGE STATE REGION LV NAME TYPE MOUNT POINT
1-1 used outer edge hd5 boot N/A
2-110 free outer edge
111-219 free outer middle
220-220 used center hd8 jfs2log N/A
221-221 used center hd2 jfs2 /usr
222-222 used center hd3 jfs2 /tmp
223-223 used center hd10opt jfs2 /opt
224-230 used center hd2 jfs2 /usr
231-241 used center hd6 paging N/A
242-328 free center
329-437 free inner middle
438-546 free inner edge
#lspv -M hdisk0
to display a detailed map of the disk and to display the relationship between each PP and LP.
# lspv -M hdisk0|more
hdisk0:1 hd5:1
hdisk0:2-110
hdisk0:111 lv1:1:1
hdisk0:112 lv1:2:1
hdisk0:113 lv1:3:1
hdisk0:114 lv1:4:1
hdisk0:115 lv1:5:1
hdisk0:116 lv1:6:1
hdisk0:117 lv1:7:1
hdisk0:118 lv1:8:1
hdisk0:119 lv1:9:1
hdisk0:120 lv1:10:1
hdisk0:121 lv1:11:1
CHANGING THE CHARACTERSTICS OF PV
1.changing the allocation permissions for PV
the allocation policy for a PV determines whether the free PP'S on that PV can be further allocated to logical volume or not.
to disable the partition allocation for a PV
#chpv -an hdisk2
check for the line in output
allocatable = no
to enable the allocation permission for a PV
#chpv -ay hdisk
check for line in output
allocatable=yes
2. changing the availability of PV
availability of a PV defines whether any logical I/O operations can be performed to a specific PV.
#chpv -vr hdisk3 ------to make disk unavailable
output
check
pv state = removed.
#chpv -vy hdisk3 -----------to make disk available
check the output
PV state = active
#chpv -c hdisk1 ----------for clearing the boot record from disk.
3. Declaring a PV hotspare
if you are assigning a disk as hotspare ,the allocation permission will also get disabled for that particular PV
#chpv -hy hdisk3 ---------defines hdisk3 as hotspare
#chpv -hn hdisk3 --------------to remove hdisk3 from hotspare pool.
MIGRATING DATA FROM PV
physical partitions located on a PV can be moved to one or another PV contained in the same VG.
here we are moving data from hdisk1 to hdisk5
step 1.. check that that PV belongs to which VG
# lspv hdisk2
check the parameter VG
#lsvg -p <vg-name> ---------it will list the PV's in that particular VG .
step2 check the mapping of all pp's on both the disks
#lsvg -M hdisk1
and
#lsvg -M hdisk5
step 3 -- check the used pp in hdisk1 and free pp,s in hdisk5
*the free pp's on hdisk5 must be greater than used pp's in hdisk1 then only data migration is possible.for that use commands
#lspv hdisk1
check in output for used pp's here
#lspv hdisk5
check in output for free pp's here .
step 4 ----if everything os ok till now then use "migratepv" to migrate the data from hdisk1 to hdisk5.
#migratepv hdisk1 hdisk5
:--- it is possible to migrate only data from partitions that belongs to a specific logical volume.
#migratepv -l testlv hdisk1 hdisk5
here we are migrating the data of LV testlv from hdisk1 to hdisk5.
VOLUME GROUP
when the AIX operating system is installed , one volume group named"
rootvg" is created by default.
* All PV will be divided in PP'S having same size.the size of PP'S can't be changed after the VG is created.
CREATING A VOLUME GROUP
volume group can be created using "mkvg" command.
Each volume group is assigned an volume group identifier
(VGID).
#mkvg -y vg1 hdisk4
this command creates a vg named "vg1" on physical volume "hdisk4".
#mkvg -y vg2 -s 64 -V99 hdisk5
this command creates a VG named "vg" with PP size=64mb and having major number 99 using hdisk5.
mkvg command by default creates a VG that can accommodate
255 LV'S
32 PV'S
VG is of three types
1. normal vg
2. big vg
3. scalable vg
vg type max. lv max. pv max. pp size
normal vg 256 32 1GB
big vg 512 128 1 GB
scalable VG 1024 4096 128 GB
creating a big vg
#mkvg -B -y bigvg -s 128 -V101 hdisk2 hdisk3
here , -B option is used to create big vg
creating a scalable vg
#mkvg -S -y scalvg -s 1G -f hdisk1 hdisk2 hdisk3 hdisk4
here -S option is used to create scalable vg.
listing information about VG
"lsvg" command list the information about the vg
#lsvg ------displays all known vg's
#lsvg -o ----------lists the active vg's
#lsvg testvg -------list the attributes of testvg
#lsvg -l rootvg --------displays all logical volumes in rootvg
#lsvg -p rootvg ---------displays all physical volumes in rootvg
#lsvg -M rootvg -------- shows mapping of PP's in rootvg
Changing the characteristics of VG
1
. auto varyon flag
to change the VG to be activated automatically the next time the system is restarted
#chvg -ay newvg
#chvg -an newvg ---to disable autovaryon flag
.
Quorum
#chvg -Qn newvg ----- to disable quorum
#chvg -Qy testvg ------- to enable quorum
3
.changing the hotspare policy
to improve data availability one or more disk can be assigned as hotspare
#chvg -hy testvg ----enabling the hotspare policy
#chvg -hn testvg --disabling the hot spare policy
we can use this hotspare disk for migrating the data from the failing disk.
4. changing the synchronization policy
synchronization policy controls the automatic synchronization of stale partitions within the VG.
#chvg -sy testvg ----- enabling the synchronization policy
check in output the parameter
auto-sync=yes
#chvg -sn testvg ----- disabling the synchronization policy
after running this command check whether the policy has been set. using
#lsvg testvg
check in the output the parameter
auto-sync =no
5. changing the max. number of logical volume
#chvg -v 4096 testvg
if i am giving this command for normal vg it will through error since max. LV in normal VG is 256.but if testvg is scalable this command will work.
so kindly check the type of the VG and the max LV that can be created in that VG.
6. unlocking a VG
A volume group can become locked after an abnormal termination of LVM commands
to remove the lock
#chvg -u testvg
EXTENDING A VG
you can increase the space available in a VG by adding a new physical disk.
Before adding the disk ,ensure that disk is in available state
the PV which is going to be added shouldn't be member of other VG.
#extendvg testvg hdisk2
this command adds hdisk2 to the vg "testvg"
if you are getting any error try with forcefully "-f" flag
#extendvg -f testvg hdisk2
REDUCING A VG
reducevg command is used to remove a physical disk from a volume group.
VG should be varied on .
when you remove the last physical volume from the vg , the vg will automatically be removed.
#reducevg testvg hdisk7
#reducevg -f testvg hdisk3
here -f is for forcefully
#reducevg -d testvg hdisk4
RESYNCHRONIZING THE ODM
the "synclvodm" command can be used to synchronize or rebuild information from ODM,device files and LVM metadata structure such as VGDA OR LVCB.
#synclvodm testvg
EXPORTING A VG
there are situations when all data from a VG needs to moved from one system to another system.
"exportvg" command will only remove VG definition from the ODM and doesn't delete any data from physical disks.
it clears the stanza from"/etc/filesystems" .
you can't export a VG that contains an active paging space.
#varyoffvg testvg
#exportvg testvg
IMPORTING A VG
Importing a disk means recreating the reference to the VG data and making data available.
#importvg -y testvg hdisk4
An imported VG is automatically varied on.
you can also change the VG name also while importing
suppose i want to rename testvg as abhivg while importing testvg
#importvg -y abhivg hdisk3
SYNCHRONIZING A VG
"
syncvg" command is used to synchronize the stale partitions
#syncvg -vf testvg --- it synchronizes the testvg
#syncvg -p hdisk4 hdisk5 --- itsynchronizes the physical disk hdisk4 and hdisk5.
MIRRORING ROOTVG
step 1
check how many disk is there in rootvg
#lsvg -p rootvg
output :
hdisk0
step2
add another physical disk to rootvg. kindly check the size and pp size . that should be same for both disk.
#extendvg rootvg hdisk1
step3
use the mirrorvg command to mirror the vg
#mirrorvg rootvg
step4
to make the disk bootable ,create the bootable image using bosboot command.
#bosboot -ad /dev/hdisk1
step5
modiffy the bootlist so that if system is not able to boot using hdisk0 it will boot using hdisk1
#bootlist -m normal hdisk0 hdisk1
to check whether the vg has been mirrored or not, run
#lsvg -l rootvg
here in output pp's are double of lp's then Vg is mirriroed.
important point
Disk mirroring can improve the read performance of a system, but at a cost to the write performance.
Of the two mirroring strategies, parallel and sequential, parallel is the better of the two in terms of disk i/o.
how exportvg command works
exportvg command is that is mostly a pure ODM related command. It does not affect the physical VGDA that sits on a disk platter. When running exportvg, it first checks to make sure the volume group has been varied off. If the volume group is not varied off first, the exportvg will fail.
When an exportvg is
run, First, exportvg finds all the disks associated with a volume group. Next, it finds all the logical volumes associated with that volume group. After the logical volumes are discovered, the potential mount points associated with the logical volumes are noted.
exportvg first deletes /etc/filesystems entries associated with logical volumes with filesystems. After this is done, the /dev special files are removed, and then the ODM has all entries associated with the volume group deleted from the ODM database.
note that during this time, there was no action upon the volume group and the disk platters that make up the volume group.