Saturday 11 January 2014

Practical Guide to AIX "Logical Volume (LV)" Management

Contents:

Logical Volume Types:

    - journaled file systems: (jfs/jfs2)
    - log logical volume: used by jfs/jfs2
    - dump logical volume: used by system dump, to copy selected areas of kernel data when a unexpected system halt occurs
    - boot logical volume: contains the initial information required to start the system
    - paging logical volume: used by the virtual memory manager to swap out pages of memory
    - raw logical volumes: these will be controlled by the appl. (it will not use jfs/jfs2)

1) Logical Volume Creation:

mklv <vg> <# of PP's> <pv>
mklv -y <lv name> <vg> <# of PP's> <pv>
## Create a mirrored named logical volume
mklv -y <lv> -c <copies 2 or 3> <vg> <# of PP's> <pv>
## create a JFSlog logical Volume
mklv -y <lv name> -t jfslog <vg> <# of PP's> <pv>

2)List/Display Logical Volume:

lslv lvname       displays information about the logical volume
lslv -l lvname    displays on which physical volumes is the lv resides
lslv -p <hdisk>   displays the logical volume allocation map for the disk (shows used, free, stale for each physical partition)
lslv -p <hdisk> <lv> displays the same as above, just the given lv's partitions will be showed by numbers

    Open          Indicates active if LV contains a file system  
    Closed        Indicates inactive if LV contains a file system  
    Syncd         Indicates that all copies are identical  
    Stale         Indicates that copies are not identical  
lsvg  -l rootvg                              Display info about all LVs in rootvg
lsvg -o |lsvg -il                            Display info about all LVs in all VGs
lslv -m lvname    displays the logical partitions (LP) and their corresponding physical partitions (PP)

  • MAX Lps: If LV created is larger than 512 MB (128 * 4), then this field needs to be upped by the following formula: (LV size in megabytes) / PP size = MAX LP count 900 MB / 4 = 225 The command to change the LP count to 225 for an LV named pick is: chlv -x 225 pick
  • COPIES:
    • value is 1= original copy
    • value is 2= first mirrored copy
    • value is 3 = second mirrored copy
  • STALE PPs: If COPIES > 1 and STALE PPs > 0, means that a mirrored LP is not available or current with other LPs.
  • INTER-POLICY:
    • If set to MIN, an LV will only reside on 1 drive
    • If set to MAX, an LV can span multiple LVs. Distributes an LV among more than 1 PV.
  • INTRA-POLICY: Has 3 values (edge, middle, center). When an LV is created, it will be assigned 1 of the 3 allocation strategies listed above.
  • EFFICENCY: Represents the efficency with which PPs are allocated based on the 3 possible states of the intra-policy.
  • RELOCATABLE : If yes, then the 'reorgvg' command is allowed to move the LV to a new position on the current PV or be placed on another PV.
  • SCHEDULING POLICY: If set to PARALLEL, insures writes to mirrored copies are performed to seperate PVs in parallel.
  • WRITE-VERIFY: If set to NO, will not perform a follow-up read to each write for verification.
  • MIRROR WRITE CONSISTENCY: When enabled, suffer a 20% performance penality. Use the syncvg -v command to resync disk drives in a VG that loses a PV.

3) Changing Logical Volume:

"chlv" is the command to do any changes to existing logical volume.

# Enable the bad-block relocation policy
chlv -b [y|n] <lv>
To change the type of logical volume lv03, enter:
chlv   -t copy  lv03
(i)Extend/Increase Logical Volume:
extendlv <lv> <additonal # of PP's>
extendlv <lv> <size of volume in B||M|G>

 (ii)Reduce Logical Volumes:
There is no direct command , you can use file system command "chfs" to reduce the lv indirectly.

4)Move/Migrate Logical Volume:

migratepv -l <lv> <old pv> <new pv>  ==> Moving lp to pp mappings to one pv to another pv
migratelp testlv/1/2 hdisk5/123   ==> migrates testlv's data from the 1st lp's second copy to hdisk5 on pp 123
         (output of lspv -M hdiskx can be used:lvname:lpnumber:copy, this sequence is needed)
         (if it is not mirrorred than easier this way: migratelp testlv/1 hdisk3)
         (if it is mirrorres and we use the above commande, than 1st copy will be used: testlv/1/1...)

5)Adding a mirror copy to a un-mirrored LV:

mklvcopy -s n <lv> <copies 2 or 3> <pv>

6)Mirroring ALL logical Volumes in a VG:

mirrorvg <vg> <pv>

7)Removing a mirror copy to a un-mirrored LV:

  rmlvcopy <lv> <copies 1 or 2>
  rmlvcopy <lv> <copies 1 or 2> <pv>      (specified pv)
  unmirrorvg <vg> <pv>

8)Synchronize logical volume:

syncvg -p <pv>
syncvg -v <vg>
syncvg -l <lv>

9)Renaming logical volume:

chlv -n <new lv name> <old lv name>

Changes the name of LV from lv00 to informixlv. If there is a filesystem mounted on top of that LV, the file system must be unmounted and the LV must be in a closed state for this command to work.
For further detailed explanation , you may refer this link  "renaming logical volume" post.

10)Remove Logical Volume:

rmlv <lv>

11)Display the LVCB:

LVCB (Logical Volume Control Block)
First 512 byte of each logical volume in normal VGs (In big VGs it moved partially into the VGDA, and for scalable VGs completely.)(traditionally it was the fs boot block) The LVCB stores the attributes of the LV. Jfs does not access this area.
# getlvcb -AT <lvname>                  <--shows the LVCB of the lv

12)Changing Maximum Number of LPs in LV:

Sometimes you met situation where in when you try to increase file system or extending logical volume , you may get error like below.

Error Message:  0516-787 extendlv: Maximum allocation for logical volume <LV_Name> is 512.
Maximum number of LPs for the logical volume has been exceeded - must increase the allocation
Calculate the number of LPs needed = LV Size in MB / LP size in MB
chlv -x <new_max_lps> <logical_volume>

13)Copy Logical Volume:

Copy the contents from one LV to a new or existing LV
i)To copy the contents of logical volume fslv03 to a new logical volume, type:
cplv fslv03
The new logical volume is created, placed in the same volume group as fslv03, and named by the system.
ii) To copy the contents of logical volume fslv03 to a new logical volume in volume group vg02, type:  start of change
cplv  -v vg02 fslv03  where fslv03 is source logical volume name. It is mandatory field.
 The new logical volume is created, named, and added to volume group vg02.
iii)To copy the contents of logical volume lv02 to a smaller, existing logical volume, lvtest, without requiring user confirmation, type:
cplv  -e lvtest  -f lv02

14) Miscellaneous LV Commands:

Resynchronizing a logical volume:
1. root@umaix: / # lslv hd6 | grep IDENTIFIER
LV IDENTIFIER:      00c2a5b400004c0000000128f907d534.2
2. lresynclv -l 00c2a5b400004c0000000128f907d534.2

0 blogger-disqus:

Post a Comment