How to Install and configure Logical Volume management in linux
ü Create a Physical Volume
[root@dlp ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
# input like below if you'd like to specify the amount
[root@dlp ~]# pvcreate --setphysicalvolumesize 50G /dev/sdb1
Physical volume "/dev/sdb1" successfully created
ü Display a status of Physical volumes
[root@dlp ~]#pvdisplay /dev/sdb1
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 50.00 GiB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID hPjJK2-tEgt-RztW-CLLH-NYR3-4t4a-hNt6qT
ü Change size of a Physical volume
# change size to 100G
[root@dlp ~]#pvresize --setphysicalvolumesize 100G /dev/sdb1
Physical volume "/dev/sdb1" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
[root@dlp ~]#pvdisplay /dev/sdb1
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 100.00 GB # changed
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID hPjJK2-tEgt-RztW-CLLH-NYR3-4t4a-hNt6qT
Output reports of Physical volumes
[root@dlp ~]#pvs /dev/sdb1
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 a- 100.00G 100.00G
Scan Physical volumes
[root@dlp ~]#pvscan /dev/sdb1
PV /dev/sda2 vg_dlp lvm2 [29.51 GiB / 0 free]
PV /dev/sdb1 lvm2 [100.00 GiB]
Total: 2 [44.51 GiB] / in use: 1 [29.51 GiB] / in no VG: 1 [100.00 GiB]
Remove a Physical volume
[root@dlp ~]#pvremove /dev/sdb1
Labels on physical volume "/dev/sdb1" successfully wiped
[root@dlp ~]#pvdisplay /dev/sdb1
No physical volume label read from /dev/sdb1 # none
Failed to read physical volume "/dev/sdb1"
Create a Volume Group
[root@dlp ~]#vgcreate vg_dlp /dev/sdb1 # create a Volume group 'vg_dlp'
Volume group "vg_dlp" successfully created
# insert a space like follows if you specify some devices
[root@dlp ~]#vgcreate vg_dlp /dev/sdb1 /dev/sdd1
Volume group "vg_dlp" successfully created
Display Volume Groups
[root@dlp ~]#vgdisplay
--- Volume group ---
VG Name vg_dlp
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 100.00 GiB
PE Size 4.00 MB
Total PE 25599
Alloc PE / Size 0 / 0
Free PE / Size 25599 / 100.00 GiB
VG UUID eoFugC-cEfQ-0qeq-xMuu-yynx-wZA0-qTMt3
Display Volume Groups
[root@dlp ~]# vgdisplay
Rename a Volume Group
[root@dlp ~]#vgrename vg_dlp vg_data # change name from 'vg_dlp' to new name 'vg_data-7'
[root@dlp ~]# vgdisplay
Output reports of Volume Groups
[root@dlp ~]# vgs
Scan Volume Groups
[root@dlp ~]#vgscan
Extend a Volume Group
[root@dlp ~]#vgextend vg_data /dev/sdc1 # add sdc1 in vg_data
[root@dlp ~]#vgdisplay
Reduce a Volume Group
[root@dlp ~]# vgreduce vg_data /dev/sdc1 # remove sdc1 from vg_data
Removed "/dev/sdd1" from volume group "vg_data"
[root@dlp ~]# vgdisplay
Remove a Volume Group
[root@dlp ~]#vgchange -a n vg_data # turn non-active first
0 logical volume(s) in volume group "vg_data" now active
[root@dlp ~]# vgremove vg_data # remove vg_data
Volume group "vg_data" successfully removed
Create a Logical Volume
# create a Logical Volumes 'lv_data' as 50G in volume group 'vg_data'
[root@dlp ~]# lvcreate -L 50G -n lv_data vg_data
Logical volume "lv_data" created
Display status of Logical Volumes
[root@dlp ~]# lvdisplay
Rename a Logical Volume
[root@dlp ~]#lvrename vg_data lv_data lv_storage # rename from "lv_data" to "lv_storage"
Renamed "lv_data" to "lv_storage" in volume group "vg_data"
[root@dlp ~]# lvdisplay
Output a report of Logical Volumes
[root@dlp ~]# lvs
Scan Logical Volumes
[root@dlp ~]# lvscan
No comments:
Post a Comment