Saturday, May 14, 2011

Linux LVM2 handson

[root@vmxdb02 ~]# vgcreate --help
vgcreate: Create a volume group

vgcreate
[-A|--autobackup {y|n}]
[--addtag Tag]
[--alloc AllocationPolicy]
[-c|--clustered {y|n}]
[-d|--debug]
[-h|--help]
[-l|--maxlogicalvolumes MaxLogicalVolumes]
[-M|--metadatatype 1|2]
[--[vg]metadatacopies #copies]
[-p|--maxphysicalvolumes MaxPhysicalVolumes]
[-s|--physicalextentsize PhysicalExtentSize[bBsSkKmMgGtTpPeE]]
[-t|--test]
[-v|--verbose]
[--version]
[ PHYSICAL DEVICE OPTIONS ]
VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]

[root@vmxdb02 ~]# vgcreate nasvg /dev/sdb1
No physical volume label read from /dev/sdb1
Physical volume "/dev/sdb1" successfully created
Volume group "nasvg" successfully created

[root@vmxdb02 ~]# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created
[root@vmxdb02 ~]# pvcreate /dev/sdb3
Physical volume "/dev/sdb3" successfully created
[root@vmxdb02 ~]# pvcreate /dev/sdb4
Physical volume "/dev/sdb4" successfully created

[root@vmxdb02 ~]# vgdisplay nasvg
--- Volume group ---
VG Name nasvg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.01 GiB
PE Size 4.00 MiB
Total PE 1282
Alloc PE / Size 0 / 0
Free PE / Size 1282 / 5.01 GiB
VG UUID YUDJG7-ss4e-lyL5-x8JX-dyh7-Acr1-UvtshP

[root@vmxdb02 ~]# vgdisplay nasvg -v
Using volume group(s) on command line
Finding volume group "nasvg"
--- Volume group ---
VG Name nasvg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.01 GiB
PE Size 4.00 MiB
Total PE 1282
Alloc PE / Size 0 / 0
Free PE / Size 1282 / 5.01 GiB
VG UUID YUDJG7-ss4e-lyL5-x8JX-dyh7-Acr1-UvtshP

--- Physical volumes ---
PV Name /dev/sdb1
PV UUID yGCo8E-hfmr-EAHh-y1zf-NxTW-Fl4b-xUVEZH
PV Status allocatable
Total PE / Free PE 1282 / 1282


[root@vmxdb02 ~]# vgextend nasvg /dev/sdb2
Volume group "nasvg" successfully extended

[root@vmxdb02 ~]# vgdisplay nasvg -v
Using volume group(s) on command line
Finding volume group "nasvg"
--- Volume group ---
VG Name nasvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 10.02 GiB
PE Size 4.00 MiB
Total PE 2564
Alloc PE / Size 0 / 0
Free PE / Size 2564 / 10.02 GiB
VG UUID YUDJG7-ss4e-lyL5-x8JX-dyh7-Acr1-UvtshP

--- Physical volumes ---
PV Name /dev/sdb1
PV UUID yGCo8E-hfmr-EAHh-y1zf-NxTW-Fl4b-xUVEZH
PV Status allocatable
Total PE / Free PE 1282 / 1282

PV Name /dev/sdb2
PV UUID OvB8d1-bzUA-wWma-YSVX-CXSt-jk6H-0OG1qO
PV Status allocatable
Total PE / Free PE 1282 / 1282

[root@vmxdb02 ~]# vgextend nasvg /dev/sdb3
Volume group "nasvg" successfully extended

[root@vmxdb02 ~]# vgextend nasvg /dev/sdb4
Volume group "nasvg" successfully extended

[root@vmxdb02 ~]# vgdisplay nasvg -v
Using volume group(s) on command line
Finding volume group "nasvg"
--- Volume group ---
VG Name nasvg
System ID
Format lvm2
Metadata Areas 4
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 4
Act PV 4
VG Size 19.98 GiB
PE Size 4.00 MiB
Total PE 5116
Alloc PE / Size 0 / 0
Free PE / Size 5116 / 19.98 GiB
VG UUID YUDJG7-ss4e-lyL5-x8JX-dyh7-Acr1-UvtshP

--- Physical volumes ---
PV Name /dev/sdb1
PV UUID yGCo8E-hfmr-EAHh-y1zf-NxTW-Fl4b-xUVEZH
PV Status allocatable
Total PE / Free PE 1282 / 1282

PV Name /dev/sdb2
PV UUID OvB8d1-bzUA-wWma-YSVX-CXSt-jk6H-0OG1qO
PV Status allocatable
Total PE / Free PE 1282 / 1282

PV Name /dev/sdb3
PV UUID 1vNH0I-rJiX-xjXD-BHqO-7FdR-PmsW-SiGimn
PV Status allocatable
Total PE / Free PE 1282 / 1282

PV Name /dev/sdb4
PV UUID sKgNx2-lsuK-TvgJ-wuLM-0a52-Ea3r-jhutuR
PV Status allocatable
Total PE / Free PE 1270 / 1270

[root@vmxdb02 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb1
VG Name nasvg
PV Size 5.01 GiB / not usable 2.10 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1282
Free PE 1282
Allocated PE 0
PV UUID yGCo8E-hfmr-EAHh-y1zf-NxTW-Fl4b-xUVEZH

--- Physical volume ---
PV Name /dev/sdb2
VG Name nasvg
PV Size 5.01 GiB / not usable 2.13 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1282
Free PE 1282
Allocated PE 0
PV UUID OvB8d1-bzUA-wWma-YSVX-CXSt-jk6H-0OG1qO

--- Physical volume ---
PV Name /dev/sdb3
VG Name nasvg
PV Size 5.01 GiB / not usable 2.13 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1282
Free PE 1282
Allocated PE 0
PV UUID 1vNH0I-rJiX-xjXD-BHqO-7FdR-PmsW-SiGimn

--- Physical volume ---
PV Name /dev/sdb4
VG Name nasvg
PV Size 4.96 GiB / not usable 3.07 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 1270
Free PE 1270
Allocated PE 0
PV UUID sKgNx2-lsuK-TvgJ-wuLM-0a52-Ea3r-jhutuR

--- Physical volume ---
PV Name /dev/sda2
VG Name vg_vmxdb02
PV Size 39.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 10114
Free PE 0
Allocated PE 10114
PV UUID CmtP40-bzhZ-smin-GBaU-EHX8-CNVi-Pii1FU

[root@vmxdb02 ~]# pvscan
PV /dev/sdb1 VG nasvg lvm2 [5.01 GiB / 5.01 GiB free]
PV /dev/sdb2 VG nasvg lvm2 [5.01 GiB / 5.01 GiB free]
PV /dev/sdb3 VG nasvg lvm2 [5.01 GiB / 5.01 GiB free]
PV /dev/sdb4 VG nasvg lvm2 [4.96 GiB / 4.96 GiB free]
PV /dev/sda2 VG vg_vmxdb02 lvm2 [39.51 GiB / 0 free]
Total: 5 [59.49 GiB] / in use: 5 [59.49 GiB] / in no VG: 0 [0 ]

[root@vmxdb02 ~]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "nasvg" using metadata type lvm2
Found volume group "vg_vmxdb02" using metadata type lvm2


[root@vmxdb02 ~]# lvcreate -L 1G -n ocrvote1 nasvg
Logical volume "ocrvote1" created
[root@vmxdb02 ~]# lvcreate -L 1G -n ocrvote2 nasvg
Logical volume "ocrvote2" created
[root@vmxdb02 ~]# lvcreate -L 1G -n ocrvote3 nasvg
Logical volume "ocrvote3" created
[root@vmxdb02 ~]# lvcreate -L 4G -n data1 nasvg
Logical volume "data1" created
[root@vmxdb02 ~]# lvcreate -L 4G -n data2 nasvg
Logical volume "data2" created
[root@vmxdb02 ~]# lvcreate -L 4G -n fra1 nasvg
Logical volume "fra1" created
[root@vmxdb02 ~]# lvcreate -L 4G -n fra2 nasvg
Logical volume "fra2" created

[root@vmxdb02 ~]# vgdisplay -v nasvg
Using volume group(s) on command line
Finding volume group "nasvg"
--- Volume group ---
VG Name nasvg
System ID
Format lvm2
Metadata Areas 4
Metadata Sequence No 11
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 7
Open LV 0
Max PV 0
Cur PV 4
Act PV 4
VG Size 19.98 GiB
PE Size 4.00 MiB
Total PE 5116
Alloc PE / Size 4864 / 19.00 GiB
Free PE / Size 252 / 1008.00 MiB
VG UUID YUDJG7-ss4e-lyL5-x8JX-dyh7-Acr1-UvtshP

--- Logical volume ---
LV Name /dev/nasvg/ocrvote1
VG Name nasvg
LV UUID Rl2gBi-NjEc-G32W-H9H0-6CXA-CcUD-YkT21U
LV Write Access read/write
LV Status available
# open 0
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2

--- Logical volume ---
LV Name /dev/nasvg/ocrvote2
VG Name nasvg
LV UUID 0319H9-2P34-13jw-Vbrr-XHJ9-f3Qo-Xoa4ft
LV Write Access read/write
LV Status available
# open 0
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3

--- Logical volume ---
LV Name /dev/nasvg/ocrvote3
VG Name nasvg
LV UUID EdumNk-tOIa-PRwz-o50t-ZVLs-hw9Q-69kKXO
LV Write Access read/write
LV Status available
# open 0
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:4

--- Logical volume ---
LV Name /dev/nasvg/data1
VG Name nasvg
LV UUID 3V9DTn-fxOJ-1CWk-XXcP-mHVA-e7Fb-8Ja81u
LV Write Access read/write
LV Status available
# open 0
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:5

--- Logical volume ---
LV Name /dev/nasvg/data2
VG Name nasvg
LV UUID f0pWEl-7Axa-uYiA-Skb3-iOCP-iTWP-gDuHua
LV Write Access read/write
LV Status available
# open 0
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:6

--- Logical volume ---
LV Name /dev/nasvg/fra1
VG Name nasvg
LV UUID zFlqfo-3pRl-iFpn-cYxS-BhSi-fEVD-nW25rN
LV Write Access read/write
LV Status available
# open 0
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:7

--- Logical volume ---
LV Name /dev/nasvg/fra2
VG Name nasvg
LV UUID JOl2Q9-GUdm-0xy1-YQ26-4uHE-dzsw-rPhLp1
LV Write Access read/write
LV Status available
# open 0
LV Size 4.00 GiB
Current LE 1024
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:8

--- Physical volumes ---
PV Name /dev/sdb1
PV UUID yGCo8E-hfmr-EAHh-y1zf-NxTW-Fl4b-xUVEZH
PV Status allocatable
Total PE / Free PE 1282 / 0

PV Name /dev/sdb2
PV UUID OvB8d1-bzUA-wWma-YSVX-CXSt-jk6H-0OG1qO
PV Status allocatable
Total PE / Free PE 1282 / 0

PV Name /dev/sdb3
PV UUID 1vNH0I-rJiX-xjXD-BHqO-7FdR-PmsW-SiGimn
PV Status allocatable
Total PE / Free PE 1282 / 6

PV Name /dev/sdb4
PV UUID sKgNx2-lsuK-TvgJ-wuLM-0a52-Ea3r-jhutuR
PV Status allocatable
Total PE / Free PE 1270 / 246