Tuesday 6 December 2016

Redhat Linux – LVM Volume Attributes



Redhat Linux’s Logical volume Manager has many attributes which are available for controlling the behavior LVM objects or to changing the default values of LVM. We may not use those attributes very often in typical production environment but knowing is not a bad thing. As a Unix/Linux admin,we should have capability  to explain each and every field of commands output as most of the fields will reflect the attributes value.Here we will see some of LVM attributes.


Physical volume(PV) attributes:

To check the physical volume attributes,use “pvs” command.The forth column of pvs command output displays the physical volume attributes.

[root@test ~]# pvs
  PV         VG        Fmt  Attr PSize   PFree
  /dev/sda2  vg_test lvm2 a-    19.51g      0
  /dev/sdd1  uavg      lvm2 a-   508.00m 408.00m
  /dev/sde   uavg      lvm2 a-   508.00m 508.00m
  /dev/sdf   uavg      lvm2 a-     5.00g   5.00g

The above command output shows “a” in the attribute field which explains that physical volumes can be “allocated” to the volumes.


Export the volume group “uavg” and check pvs output.

[root@test ~]# vgexport uavg

  Volume group "uavg" successfully exported


[root@test ~]# pvs

  PV         VG        Fmt  Attr PSize   PFree
  /dev/sda2  vg_test lvm2 a-    19.51g      0
  /dev/sdd1  uavg      lvm2 ax   508.00m 408.00m
  /dev/sde   uavg      lvm2 ax   508.00m 508.00m
  /dev/sdf   uavg      lvm2 ax     5.00g   5.00g


In attributes field, you can see that “x”  is added now.This show that volume group is exported.

If the PV is missing, check the pvs output

unknown device actAPOTD1P_archivelog lvm2 axm 512.00g 0
unknown device actAPOTD1P_archivelog lvm2 axm 988.20g 0
unknown device actAPOTD1P_archivelog lvm2 axm 512.00g 0
unknown device actAPOTD1P_archivelog lvm2 axm 512.00g 0
unknown device actAPOTD1P_archivelog lvm2 axm 512.00g 0

In attributes field, you can see that “m”  is added now.This show that physical volume is missing.


We can stop the allocation to the disk by using pvchnage command.By disabling allocation,volume will not be extended using that specific physical volume.


[root@test ~]# pvchange -x n /dev/sdd1
  Physical volume "/dev/sdd1" changed
1 physical volume changed / 0 physical volumes not changed

[root@test ~]# pvs
  PV         VG        Fmt  Attr PSize   PFree
  /dev/sda2  vg_test lvm2 a-    19.51g      0
  /dev/sdd1  uavg      lvm2 --   508.00m 408.00m
  /dev/sde   uavg      lvm2 a-   508.00m 508.00m
  /dev/sdf   uavg      lvm2 a-     5.00g   5.00g
[root@test ~]#


You can revert the change any time using below-mentioned command.

[root@test ~]#  pvchange -x y /dev/sdd1
  Physical volume "/dev/sdd1" changed
  1 physical volume changed / 0 physical volumes not changed

[root@test ~]# pvs
  PV         VG        Fmt  Attr PSize   PFree
  /dev/sda2  vg_test lvm2 a-    19.51g      0
  /dev/sdd1  uavg      lvm2 a-   508.00m 408.00m
  /dev/sde   uavg      lvm2 a-   508.00m 508.00m
  /dev/sdf   uavg      lvm2 a-     5.00g   5.00g



Some of the useful commands to get the details of physical volume.


1.To get the physical volumes with  “UID” , use “-v” option.

Note:You can also use “pvs -vv” to get more detailed information.

[root@test ~]# pvs -v
 Scanning for physical volume names
  PV      VG   Fmt Attr PSize   PFree  DevSize   PV UUID
/dev/sdd1 uavg lvm2 ax 508.00m 408.00m 511.98m tJ5YhP-VOZV-yfQ6-Uyye-WGT7-VLcl-7M3RMK
/dev/sde  uavg lvm2 ax 508.00m 508.00m 512.00m FadWLT-LjD8-v8VB-pboY-eZbK-vYpE-ZWq0i9
/dev/sdf  uavg lvm2 ax 5.00g   5.00g   5.00g GbvgWh-l0w3-wCA6-umkD-zfsS-8yAZ-GeOSKF


2.To get all the disks connected to the system ,use “pvs -a”


[root@test ~]# pvs -a
  PV                     VG        Fmt  Attr PSize   PFree
  /dev/root                             --        0       0
  /dev/sda1                             --        0       0
  /dev/sda2              vg_test lvm2 a-    19.51g      0
  /dev/sdb1                             --        0       0
  /dev/sdc1                             --        0       0
  /dev/sdd1              uavg      lvm2 ax   508.00m 408.00m
  /dev/sde               uavg      lvm2 ax   508.00m 508.00m
  /dev/sdf               uavg      lvm2 ax     5.00g   5.00g
  /dev/sdg                              --        0       0
  /dev/vg_test/lv_swap                --        0       0


/dev/sda1 is not part of LVM but you get the disk list in pvs command.

3.To get the segment wise output,use below command.

[root@test ~]# pvs --segments
  PV         VG        Fmt  Attr PSize   PFree   Start SSize
  /dev/sda2  vg_test lvm2 a-    19.51g      0      0  4234
  /dev/sda2  vg_test lvm2 a-    19.51g      0   4234   760
  /dev/sdd1  uavg      lvm2 ax   508.00m 408.00m     0    13
  /dev/sdd1  uavg      lvm2 ax   508.00m 408.00m    13    25
  /dev/sdd1  uavg      lvm2 ax   508.00m 408.00m    38    89
  /dev/sde   uavg      lvm2 ax   508.00m 508.00m     0   127
  /dev/sdf   uavg      lvm2 ax     5.00g   5.00g     0  1279


Volume Group(VG) Attributes:

You can see the volume group attributes using vgs command.


Attributes Description

r,w (r)ead & (w)rite permissions
z resi(z)eable
x e(x)ported
p (p)artial
c,n,a,i allocation policy (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
c (c)luster
m (m) missing

Here we will see sample vgs command output.

[root@test ~]# vgs
  VG        #PV #LV #SN Attr   VSize  VFree
  uavg        3   1   0 wz--n-  5.99g 5.89g
  vg_test   1   2   0 wz--n- 19.51g    0
[root@test ~]#
[root@test ~]# vgs -v
    Finding all volume groups
    Finding volume group "uavg"
    Finding volume group "vg_test"
VG        Attr   Ext   #PV #LV #SN VSize  VFree VG UUID
uavg      wz--n- 4.00m   3   1   0  5.99g 5.89g c87FyZ-5DND-oQ3n-iTh1-Vb1f-nBML-vUBUE9
vg_test wz--n- 4.00m   1   2   0 19.51g    0  dIgmLP-aoe3-anxY-WHYE-bBtX-u28M-WF6Ye5


There are some other volume group attributes which will be useful while creating the new volume group.

Attributes Description

-l maximum logical volumes
-p maximum physical volumes
-s physical extent size (default is 4MB)
-A autobackup

All the above mentioned attributes can be set while creating the volume group.You can not modify those values after that.In the below example,I have used most the  attributes with specific value to create new volume group.

[root@test ~]# vgcreate   -l 512 -p 256 -s 32M -Ay newvg /dev/sdf
  Volume group "newvg" successfully created
 vgs newvg
  VG    #PV #LV #SN Attr   VSize VFree
  newvg   1   0   0 wz--n- 4.97g 4.97g


You can see the newly set values in vgdisplay command output.

[root@test ~]# vgdisplay -v newvg

    Using volume group(s) on command line
    Finding volume group "newvg"
  --- Volume group ---
  VG Name               newvg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                512
  Cur LV                0
  Open LV               0
  Max PV                256
  Cur PV                1
  Act PV                1
  VG Size               4.97 GiB
  PE Size               32.00 MiB
  Total PE              159
  Alloc PE / Size       0 / 0
  Free  PE / Size       159 / 4.97 GiB
  VG UUID               Ny4xsv-uJ49-sZr9-lvfq-Oa7n-l5mH-1bPBbp

  --- Physical volumes ---
  PV Name               /dev/sdf
  PV UUID               GbvgWh-l0w3-wCA6-umkD-zfsS-8yAZ-GeOSKF
  PV Status             allocatable
  Total PE / Free PE    159 / 159


Logical Volume (LV) Attributes:

Knowing the logical volume attributes.

[root@test ~]# lvs
  LV      VG        Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  vol1    uavg      -wi-ao 100.00m
  lv_root vg_test -wi-ao  16.54g
  lv_swap vg_test -wi-ao   2.97g


The below tables covers the “lvs” command attributes.

Volume Type Attributes(First Field of Attr) Description
m (m)irrored
M (M)irrored without intial sync
o (o)rgin
p (p)vmove
s (s)napshot
S invalid (S)napshot
v (v)irtual
i mirror (i)mage
l mirror (I)mage without sync
c under (c)onstruction
Simple Volume


Attributes (second to sixth Field of Attr) Description

w,r (Second Feild) Permissions ‘(r)’ead ‘(w)’rite
c,I,n.a,I (Third Feild) Allocation policy (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
m (Fourth Feild) Fixed (m)inor
a,s,I (Fifth Feild) (a)ctive, (s)uspended, (I)nvalid snapshot,,
S (Fifth Feild) Invalid (S)uspended snapshot
I (Fifth Feild) Mapped device present with (i)nactive table
d (Fifth Feild) Mapped (d)evice present with-out tables
o (sixth Feild) device (o)pen (Volume is in active state or may be mounted )
a - allocated (a)
x - exported (x)
m - missing (m)

While creating the volume can provide various attributes like stripe size,no of extends
etc.These are already covered in volume creation.

Here we will see some of the useful “lvs” command options.

1.To display the logical volumes with underlying physical volumes use,

[root@test ~]# lvs -a -o +devices
LV      VG        Attr   LSize   Origin Snap%  Move Log Copy%  Convert Devices
vol1    uavg      -wi-ao 100.00m                                   /dev/sdd1(13)
lv_root vg_test -wi-ao  16.54g                                   /dev/sda2(0)
lv_swap vg_test -wi-ao   2.97g                                   /dev/sda2(4234)


2.To see the complete physical disks segmnets for logical volumes,

[root@test ~]# lvs -a -o +seg_pe_ranges --segments

  LV      VG        Attr   #Str Type   SSize   PE Ranges
  vol1    uavg      -wi-ao    1 linear 100.00m /dev/sdd1:13-37
  lv_root vg_test -wi-ao    1 linear  16.54g /dev/sda2:0-4233
  lv_swap vg_test -wi-ao    1 linear   2.97g /dev/sda2:4234-4993


3.For detailed logical volume information,

[root@test ~]# lvdisplay --maps /dev/uavg/vol1
  --- Logical volume ---
  LV Name                /dev/uavg/vol1
  VG Name                uavg
  LV UUID                XjMpRC-6f5k-FN9L-jz5v-f0Gj-wBpf-xc9GVD
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                100.00 MiB
  Current LE             25
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Segments ---
  Logical extent 0 to 24:
    Type                linear
    Physical volume     /dev/sdd1
    Physical extents    13 to 37


Hope this post is informative for you.Thank you for reading this article.Please leave a comment if you have any doubt.I will get back to you.


2 comments:

  1. Thanks for this blog. I have found some interesting blogs on google. You can check these blogs also which are related to technologies….

    Job Oriented Linux Training Institute in Delhi, NCR
    Job Oriented AWS Training Institute in Delhi, NCR

    ReplyDelete
  2. In the realm of business acumen, few stories shine as brightly as Mohan Kumar's, a visionary entrepreneur whose trajectory to success has been seamlessly guided by the precision of forseeshipping . Kumar's business empire stands as a testament to the symbiotic relationship between ambition and reliable logistics.

    ReplyDelete