Académique Documents
Professionnel Documents
Culture Documents
LOGICAL
VOLUME
MANAGER
(LVM)
Logical Volume Manager:-The set of operating system commands, library subroutines, and
other tools that allow you to establish and control logical volume storage is called the Logical
Volume Manager (LVM).Managing large hard disk farms by letting you add disks, replace
disks, copy and share contents from one disk to another without disrupting service (hot
swapping).One can think of LVMas a thin software layer on top of the hard disks and
partitions, which creates an illusion of continuity and ease-of-use for managing hard-drive
replacement, repartitioning, and backup.The LVM controls disk resources by mapping data
between a more simple and flexible logical view of storage space and the actual physical
disks. The LVMdoes this using a layer of device-driver code that runs above traditional disk
device drivers.Logical volume storage concepts:-The five basic logical storage concepts
are: Physical volumes, volume groups,physical partitions, logical volumes, and logical
partitions.
All physical volumes belong to one volume group (VG) named rootvg.
All of the physical volumes in a volume group are divided into physical partitions
(PPs) of the same size.
Within each volume group, one or more logical volumes (LVs) are defined.
Before you can start using Logical Volume Manager you must understand the basic
mechanics and terminology.
The vary-on process is one of the mechanisms that the LVM uses to ensure that a volume
group is ready to use and contains the most up-to-date data. The varyonvg and varyoffvg
commands activate or deactivate a volume group that you have defined to the system.
If the vary-on operation cannot access one or more of the physical volumes defined in the
volume group, the command displays the names of all physical volumes defined for that
volume group and their status. This helps you decide whether to vary-off this volume group.
Two important thing you should know:/var/adm/ras/lvmcfg.log lvm log file shows what lvm commands were used
(alog -ot lvmcfg)
alog -ot lvmt shows lvm commands and libs
There are limitations that you have to be aware of, which are listed in table-
VG type
Maximum PPsper VG
Normal VG
Big VG
Scalable VG
32
32
1024
32512 (1016*32)
130048(1016*128)
2097152
256
128
4096
Maximum PP
size
1 GB
1 GB
128 GB
They are used by LVM commands and external applications such as HACMP.
eg:# lsvg -p rootvg ( displays all PVs that are contained in rootvg.)
# lsvg -M <hdiskname> ( displays the map of all physical partitions located on
<hdiskname>.)
# lsvg -M <hdiskname> ( shows that all partitions of <hdiskname> are not allocated.)
# migratepv <hdiskname> <hdiskname>( migrates the data from <hdiskname> to
<hdiskname>)
# lspv -M <hdiskname> ( confirms that <hdiskname> has all partitions free.)
# chpv -c <hdiskname> ( clears the boot record from <hdiskname>.)
# lspv -M <hdiskname> ( confirms that all physical partitions have been migrated to
<hdiskname>.)
Migrating partitions# migratelp testlv/1/2 <hdiskname>/123 ( migrates the data from the second copy of the
logical partition number 1 of logical volume to <hdiskname> on physical partition 123.)
Finding the LTG size# lquerypv -M hdisk0 ( Logical track group (LTG) size is the maximum allowed transfer size
for an I/O disk operation.)
O/p 256
Volume Groups (VG):
When the operating system is installed, one volume group named rootvg is created by default.
Additional volume groups can be created on the system using one or more physical volumes
that have not been allocated to other volume groups yet and are in an available state. All
physical volumes will be divided in physical partitions having the same size. The size of the
physical partitions cannot be changed after the volume group is created.
Basic Commands for VG:
# lsvg
# lsvg -o
# lsattr -El hdiskn
Creating an original volume group :-
Note : if any error came in vg command do check the Limitations for BIG, NORMAL and
SCALABLE.
Changing volume group characteristics:Varyon flag:Command changes the volume group testvg to be activated automatically the next time the
system is restarted.
# chvg -ay newvg
Command changes the volume group testvg to not be activated automatically next time the
system is restarted.
# chvg -an newvg
Quorum:The quorum is one of the mechanisms that the LVM uses to ensure that a volume group is
ready to use and contains the most up-to-date data.
Nonquoram Volume Group:The Logical Volume Manager (LVM) automatically deactivates the volume group when it
lacks a quorum of Volume Group Descriptor Areas (VGDAs) or Volume Group Status Areas
(VGSAs). However, you can choose an option that allows the group to stay online as long as
there is one VGDA/VGSA pair intact. This option produces a nonquorum volume group.
To turn off the quorum, use the command:
#chvg -Qn testvg
To turn on the quorum, use the command:
# chvg -Qy testvg
Changing a volume group format:You can change the format of an original volume group to either big or scalable. Once the
volume group has been converted to a scalable format, it cannot be changed into a different
format.Type
# varyoffvg xyz
# chvg -G xyz
The chvg -G command is use to change the format of the volume group tttt from original to
scalable.
# varyonvg xyz
Changing LTG size:volume groups in AIX 5L Version 5.3 are created with a variable logical track group size. For
volume groups created to be compatible with a previous version of AIX 5L, you can change
the LTG size to 0, 128, 256, 512, or 1024. The new LTG size should be less than or equal to
the smallest of the maximum transfer size of all disks in the volume group. You can change
the LTG size for the testvg volume group using the following command.
# chvg -L 128 testvg
Changing the hot spare policy:To improve data availability, one or more disks from a volume group can be designated as hot
spares. Physical volumes that are to be used as a hot spare must have all physical partitions
free. All logical volumes from the volume group that contain hot spare disks must be
mirrored
# chpv -hy hdiskn( tries to designate <hdiskname> as a hot spare)
# chvg -hy test1v( changes the hot spare policy of the volume group to migrate data from a
failing disk to one spare disk)
options -Y ( changes the hot spare policy of the volume group to migrate data from a
failing disk to the entire pool of spare disks)
-n ( disables the hot spare policy of the volume group)
-sy (Changing synchronization policy of a volume group)
-P ( the -P option in chvg command to change the maximum number of physical partitions
within a volume group)
-v ( the -v option in chvg command to change the maximum number of logical volumes
within a volume group)
-u( You can remove the lock using -u option)
# lsvg -p test1vg ( displays physical volumes that are part of test1vg)
Extending a volume group:You can increase the space available in a volume group by adding new physical volumes
using the extendvg command. Before adding a new disk, you have to ensure that the disk is in
an available state. If the disk has one VGDA corresponding to another already varied on
volume group, the command exits. If the VGDA belongs to a volume group that is varied
off, the system will prompt the user for confirmation in continuing with command execution.
If the user says yes, the old VGDA is erased and all previous data on that disk will be
unavailable.
How to Extend VG:# extendvg test1vg <hdiskname> (lets suppose x is the disk which you have added)
O/p 0516-1254 extendvg: Changing the PVID in the ODM.
Assigns an PVID to <hdiskname>and adds it to the volume group test1vg.
Options- -f ( forcibly adds hdisk to volume group )
Reducing a volume group:The volume group must be varied on. When you remove the last physical volume from the
volume group, the VG will also be removed. For volume groups created on AIX 5L Version
5.3 and varied on without using varyonvg -M reducevg will dynamically raise the LTG size
if the remaining disks permit it.
# reducevg -f testvg <hdiskname> ( prompts the user for confirmation, deletes the data
located on physical volume <hdiskname>, and removes the disk definition from the testvg
volume group. lets y is any number of disk)
Note: if We close logical volumes lv1, lv2, and loglv01 by unmounting the corresponding file
systems.reducevg testvg <hdiskname>still does not work. Only -f option will work .
Resynchronizing the device configuration database:# synclvodm testvg
Exporting a volume group & Importing a volume groupThere are situations when all data from a volume group needs to be moved from one system
to another system. You will need to delete any reference to that data from the originating
system
The exportvg command only removes volume group definition from the ODM and does not
delete any data from the physical disks. It clears the stanzas from /etc/filesystem
Importing a volume group means recreating the reference to the volume group data and
making that data available. The importvg command reads the VGDA of one the physical
volumes that are part of the volume group. It uses redefinevg to find all other disks that
belong tothe volume group.It will add corresponding entries into the ODM database and
update /etc/filesystems.
To export the volume group testvg, use the command
# exportvg testvg
To import the volume group testvg, use the command
The reorgvg command is used to reorganize physical partitions within a volume group.
To reorganize only logical volumes lv1 and lv1 from volume group testvg, use:
# reorgvg testvg lv1 lv2
To reorganize only partitions located on physical volumes <hdiskname> and <hdiskname>
that belong to logical volumes lv1 and lv2 from volume group testvg, use:
echo <hdiskname> <hdiskname> | reorgvg -i testvg lv1 lv2
Synchronizing a volume group:The syncvg command is used to synchronize stale physical partitions. It acceptsnames of
logical volumes, physical volumes, or volume groups as parameters.The synchronization
process can be time consuming, depending on the hardware characteristics and the total
amount of data.
To synchronize the copies located on physical volumes <hdiskname> and <hdiskname>, use:
#syncvg -p <hdiskname> <hdiskname>
To synchronize the all physical partitions from volume group testvg, use:
#syncvg -v testvg
Note: When the -f flag is used, synchronization is forced and an uncorrupted physical copy is
chosen and propagated to all other copies of the logical partition, whether or not they are
stale.
Mirroring a volume group:You can use the mirrorvg command to mirror all logical volumes within a volume group.
# extendvg rootvg hdiskA
# mirrorvg rootvg
Op 0516-1124 mirrorvg: Quorum requirement turned off, reboot system for thisto take
effect for rootvg.
0516-1126 mirrorvg: rootvg successfully mirrored, user should perform
bosboot of system to initialize boot records. Then, user must modify
bootlist to include: hdisk0 <hdiskname>.
# bosboot -ad /dev/hdiskA
# bootlist -m normal hdiskA hdiskB
# lsvg -l rootvg
Logical Volumes (LV):
Logical volumes provide applications with the ability to access data as though it was stored
contiguously. A logical volume consists of a sequence of one or more numbered logical
partitions. Each logical partition has at least one and a maximum of three corresponding
physical partitions that can be located on different physical volumes. The location on the
disk for physical partitions is determined by intra-physical and inter-physical allocation
policies.
Notes: When the system is installed, the root volume group (rootvg) is created. This is where
the AIX operating system files will be contained. Additional disks can either be added to
rootvg or a new volume group can be created for them. There can be up to 255 VGs per
system.
If you have external disks, it is recommended that they be placed in a separate volume
group. By maintaining the user file systems and the operating system files in distinct volume
groups, the user files are not jeopardized during operating system updates, reinstallations, and
crash recoveries.
Maintenance is easier because you can update or reinstall the operating system without
having to restore user data. For security, you can make the volume group unavailable using
varyoffvg.
Logical Volume types:
1. log logical volume: used by jfs/jfs2
2.dump logical volume: used by system dump, to copy selected areas of kernel data when a
unexpected syszem halt occurs
3. boot logical volume: contains the initial information required to start the system
4. paging logical volume: used by the virtual memory manager to swap out pages of
memory users and appl.-s will use these lvs:
5. raw logical volumes: these will be controlled by the appl. (it will nit use jfs/jfs2)
6. journaled filesystems:
Striped logical volumes:-Helps I/O capacity of the physical volumes to be used in parallel to
access the data.
LVCB (Logical Volume Control Block):-He LVCB stores the attributes of the LV. Jfs does
not access this area.Traditionally it was the fs boot block of 512 bytes.
# getlvcb -AT <lvname>
Creating a new log logical volume:
You can create logical volumes using the mklv command.
# mklv -y lv3 -t jfs2 -a lvname vgname 1 pvname (creates the log lv)
# logform -V jfs2 /dev/lvname (used to create logfile )