四. 创建VG
1.相关命令
vgcreate 创建VG
vgscan 扫描VG
vgdispaly
vgextend
vgreduce
vgchange
vgremove
2.创建逻辑卷VG
[root@san iscsi]# vgcreate vg0 /dev/sda5 /dev/sda6
Volume group "vg0" successfully created
[root@san iscsi]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg0" using metadata type lvm2
Device '/dev/sda6' has been left open.
Device '/dev/sda5' has been left open.
[root@san iscsi]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 200.00 MB
PE Size 4.00 MB /*分配的块大小默认为4M*/
Total PE 50
Alloc PE / Size 0 / 0
Free PE / Size 50 / 200.00 MB
VG UUID iE7uoy-boR3-N6Cv-91Gf-G5vE-ftD6-gSGVlB
3.删除与添加逻辑卷
[root@san iscsi]# vgreduce vg0 /dev/sda5
Removed "/dev/sda5" from volume group "vg0"
[root@san iscsi]# vgextend vg0 /dev/sda5
Volume group "vg0" successfully extended
4. PE 和LV 大小的关系
In order to limit the Linux kernel memory usage, there is a limit of 65,536 physical extents (PE) per logical volume (LV). Hence, the LVM PE size will directly determine the maximum size of a logical volume (LV)! For example, 4MB PE size (the default PE size) will limit single logical volume (LV) to 256GB, 16MB PE size will limit single LV to grow beyond 1TB, etc.
Beside the PE size, the maximum size of single LV is also limited by CPU architecture and Linux kernel version:
Linux kernel version 2.4.x limit the maximum LV size to 2TB.
Some older Linux kernel prior to 2.4.x, the maximum LV size is limited to 1TB (caused by the integer signedness problems in the block layer).
The combination of 32-bit CPU and Linux kernel version 2.6.x, the limit of logical volume size is maximized at 16TB.
For Linux kernel 2.6.x running on 64-bit CPU, the maximum LV size is 8EB (extremely terrible big storage for this time being!)
这段问题里有如下2个重点信息:
1. PE 的大小决定LV 的容量,默认4M 的PE 最大支持的256G 的LV。 16M的PE 最大支持1TB的LV。
2. 影响LV 容量的还有CPU 架构。 对于32bit 下,Linux 内核为2.6.X的支持16TB,64bit 下,Linux 内核为2.6.x的支持8EB。
所以如果要想支持大量的LV。 那么对在创建LV 的时候,还需要指定PE 的大小。 这个我们在vgcreate命令中加一个-s 参数即可:
[root@san iscsi]# vgremove vg0
Volume group "vg0" successfully removed
[root@san iscsi]# vgcreate -s 16MB vg0 /dev/sda5 /dev/sda6
Volume group "vg0" successfully created
[root@san iscsi]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg0" using metadata type lvm2
Device '/dev/sda6' has been left open.
Device '/dev/sda5' has been left open.
[root@san iscsi]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 192.00 MB
PE Size 16.00 MB - 这里我们看到PE 改成16MB了。
Total PE 12
Alloc PE / Size 0 / 0
Free PE / Size 12 / 192.00 MB
VG UUID A9w4ho-3Fdo-ELYl-VRqY-yhaZ-61rt-68sXsi
