LVM:logical volume manager(逻辑卷管理);LVM屏蔽了底层磁盘布局,方便于动态调整磁盘容量.
一、创建逻辑卷的步骤:
1)通过fdisk 工具将磁盘转换为linux分区
2)通过pvcreate命令将linux分区转换成物理卷(PV);
3)通过vgcreate命令将创建好的物理卷处理成卷组(VG);
4)通过lvcreate命令将卷组分成若干个逻辑卷(LV);
5)对逻辑卷进行格式化,挂载,动态调整逻辑卷的大小,并且该操作不会影响逻辑卷(Lv)上的数据.
二、物理卷(PV)创建及管理具体操作步骤:
1)先查看linux分区,将未使用空间转换为物理卷(先使用fdisk建立普通分区)
[root@RHEL5 ~]# fdisk -l /dev/sdb #查看linux分区情况
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 500 4016218 83 Linux
/dev/sdb2 501 1000 4016250 83 Linux
/dev/sdb3 1001 1500 4016250 83 Linux
/dev/sdb4 1501 2610 8916075 5 Extended
/dev/sdb5 1501 2610 8916043 83 Linux
备注:/dev/sdb是一块新增加的磁盘,上面没有任何数据,也未挂载
2)将linux物理分区转变为物理卷
[root@RHEL5 ~]# pvcreate /dev/sdb{1,2} #将物理分区/dev/sdb{1,2}转变为物理卷
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdb2" successfully created
3)#使用Pvscan查看物理卷信息
[root@RHEL5 ~]# pvscan #查看物理卷信息,会显示所有物理卷信息
PV /dev/sda2 VG VolGroup00 lvm2 [39.88 GB / 0 free]
PV /dev/sdb1 lvm2 [3.83 GB]
PV /dev/sdb2 lvm2 [3.83 GB]
Total: 3 [47.54 GB] / in use: 1 [39.88 GB] / in no VG: 2 [7.66 GB]
4)使用pvdisplay查看各物理卷详细参数
[root@RHEL5 ~]# pvdisplay #查看各物理卷详细参数
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 39.90 GB / not usable 20.79 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 1276
Free PE 0
Allocated PE 1276
PV UUID aJlaad-NHPT-Cgg3-7yu4-a2RJ-kJJ1-qxSFgD
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 3.83 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID v2VajD-yS53-SiQA-yTzu-KOiD-RyT3-p0wTvt
--- NEW Physical volume ---
PV Name /dev/sdb2
VG Name
PV Size 3.83 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID iOoK3V-yuww-ZlLF-cRLq-v7hC-CL7c-0bQU1x
----------------------------------------------------------------------
当物理卷没有被使用时可删除物理卷
[root@RHEL5 /]# pvremove /dev/sdb2 #删除物理卷,
|