Linux – LVM Volume Attributes

Redhat Linux – LVM Volume Attributes

AUGUST 25, 2013 BY LINGESWARAN R 1 COMMENT


LVM

 

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@mylinz ~]# pvs

  PV         VG        Fmt  Attr PSize   PFree

  /dev/sda2  vg_mylinz 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

[root@mylinz ~]#

 

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@mylinz ~]# vgexport uavg

  Volume group "uavg" successfully exported

[root@mylinz ~]# pvs

  PV         VG        Fmt  Attr PSize   PFree

  /dev/sda2  vg_mylinz 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

[root@mylinz ~]#

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

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@mylinz ~]# pvchange -x n /dev/sdd1

  Physical volume "/dev/sdd1" changed

  1 physical volume changed / 0 physical volumes not changed

[root@mylinz ~]# pvs

  PV         VG        Fmt  Attr PSize   PFree

  /dev/sda2  vg_mylinz 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@mylinz ~]#

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

[root@mylinz ~]#  pvchange -x y /dev/sdd1

  Physical volume "/dev/sdd1" changed

  1 physical volume changed / 0 physical volumes not changed

[root@mylinz ~]# pvs

  PV         VG        Fmt  Attr PSize   PFree

  /dev/sda2  vg_mylinz 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

[root@mylinz ~]#

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@mylinz ~]# 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

[root@mylinz ~]#


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

[root@mylinz ~]# pvs -a

  PV                     VG        Fmt  Attr PSize   PFree

  /dev/root                             --        0       0

  /dev/sda1                             --        0       0

  /dev/sda2              vg_mylinz 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_mylinz/lv_swap                --        0       0

[root@mylinz ~]#

/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@mylinz ~]# pvs --segments

  PV         VG        Fmt  Attr PSize   PFree   Start SSize

  /dev/sda2  vg_mylinz lvm2 a-    19.51g      0      0  4234

  /dev/sda2  vg_mylinz 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

[root@mylinz ~]#


 

Volume Group(VG) Attributes:

You can see the volume group attributes using vgs command.
table.tableizer-table { border: 1px solid #CCC; font-family: Arial, Helvetica, sans-serif font-size: 12px; } .tableizer-table td { padding: 4px; margin: 3px; border: 1px solid #ccc; } .tableizer-table th { background-color: #104E8B; color: #FFF; font-weight: bold; }

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

Here we will see sample vgs command output.

[root@mylinz ~]# vgs

  VG        #PV #LV #SN Attr   VSize  VFree

  uavg        3   1   0 wz--n-  5.99g 5.89g

  vg_mylinz   1   2   0 wz--n- 19.51g    0

[root@mylinz ~]#

[root@mylinz ~]# vgs -v

    Finding all volume groups

    Finding volume group "uavg"

    Finding volume group "vg_mylinz"

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_mylinz wz--n- 4.00m   1   2   0 19.51g    0  dIgmLP-aoe3-anxY-WHYE-bBtX-u28M-WF6Ye5

[root@mylinz ~]#


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

table.tableizer-table { border: 1px solid #CCC; font-family: Arial, Helvetica, sans-serif font-size: 12px; } .tableizer-table td { padding: 4px; margin: 3px; border: 1px solid #ccc; } .tableizer-table th { background-color: #104E8B; color: #FFF; font-weight: bold; }

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@mylinz ~]# 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

[root@mylinz ~]#

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

[root@mylinz ~]# 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

 

[root@mylinz ~]#


 

Logical Volume (LV) Attributes:

Knowing the logical volume attributes.

[root@mylinz ~]# lvs

  LV      VG        Attr   LSize   Origin Snap%  Move Log Copy%  Convert

  vol1    uavg      -wi-ao 100.00m

  lv_root vg_mylinz -wi-ao  16.54g

  lv_swap vg_mylinz -wi-ao   2.97g

[root@mylinz ~]#

The below tables covers the “lvs” command attributes. table.tableizer-table { border: 1px solid #CCC; font-family: Arial, Helvetica, sans-serif font-size: 12px; } .tableizer-table td { padding: 4px; margin: 3px; border: 1px solid #ccc; } .tableizer-table th { background-color: #104E8B; color: #FFF; font-weight: bold; }

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

 

table.tableizer-table { border: 1px solid #CCC; font-family: Arial, Helvetica, sans-serif font-size: 12px; } .tableizer-table td { padding: 4px; margin: 3px; border: 1px solid #ccc; } .tableizer-table th { background-color: #104E8B; color: #FFF; font-weight: bold; }

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 )

 

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@mylinz ~]# 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_mylinz -wi-ao  16.54g                                   /dev/sda2(0)

lv_swap vg_mylinz -wi-ao   2.97g                                   /dev/sda2(4234)

[root@mylinz ~]#


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

[root@mylinz ~]# 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_mylinz -wi-ao    1 linear  16.54g /dev/sda2:0-4233

  lv_swap vg_mylinz -wi-ao    1 linear   2.97g /dev/sda2:4234-4993

[root@mylinz ~]#


3.For detailed logical volume information,

[root@mylinz ~]# 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

[root@mylinz ~]#


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.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值