linux 逻辑卷的使用
给磁盘分区并添加lvm标示
[root@node1 /]# fdisk /dev/sdb
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
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 183 1469916 83 Linux
/dev/sdb2 184 366 1469947+ 8e Linux LVM
/dev/sdb3 367 1218 6843690 8e Linux LVM
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
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 183 1469916 8e Linux LVM
/dev/sdb2 184 366 1469947+ 8e Linux LVM
/dev/sdb3 367 1218 6843690 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
删除卷组合物理卷
[root@node1 /]# vgremove lvm_test
Volume group "lvm_test" successfully removed
[root@node1 /]# pvremove /dev/sdb2
Labels on physical volume "/dev/sdb2" successfully wiped
[root@node1 /]# pvremove /dev/sdb1
Labels on physical volume "/dev/sdb1" successfully wiped
创建物理卷
[root@node1 /]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@node1 /]# pvcreate /dev/sdb2
Physical volume "/dev/sdb2" successfully created
[root@node1 /]# pvcreate /dev/sdb3
Physical volume "/dev/sdb3" successfully created
显示物理卷
[root@node1 /]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 19.88G 0
/dev/sdb1 lvm2 -- 1.40G 1.40G
/dev/sdb2 lvm2 -- 1.40G 1.40G
/dev/sdb3 lvm2 -- 6.53G 6.53G
创建vg并将两个物理卷加入卷组
[root@node1 /]# vgcreate lvm_test /dev/sdb1 /dev/sdb2
Volume group "lvm_test" successfully created
在现有的卷组上添加一个物理卷
[root@node1 /]# vgextend lvm_test /dev/sdb3
Volume group "lvm_test" successfully extended
创建逻辑卷
[root@node1 /]# lvcreate -L 1500 -n test lvm_test
Logical volume "test" created
[root@node1 /]# lvcreate -L 1500 -n test2 lvm_test
Logical volume "test2" created
[root@node1 /]# lvcreate -L 1500 -n test3 lvm_test
Logical volume "test3" created
[root@node1 /]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 17.88G
LogVol01 VolGroup00 -wi-ao 2.00G
test lvm_test -wi-a- 1.46G
test2 lvm_test -wi-a- 1.46G
test3 lvm_test -wi-a- 1.46G