基础知识 -- Linux 逻辑卷管理技术2
怎样从VG中移走PV ?
https:// svn.wso2.org //repos // wso2 // tags // wsas // java // 3.2.1 //
例如将/dev/sdb1从逻辑卷中移出:
linux-0eob:/ # pvmove /dev/sdb1
/dev/sdb1: Moved: 100.0%
linux-0eob:/ # pvscan
PV /dev/sdb1 VG vg0 lvm2 [52.00 MB / 52.00 MB free]
PV /dev/sdb2 VG vg0 lvm2 [52.00 MB / 32.00 MB free]
PV /dev/sdb3 VG vg0 lvm2 [52.00 MB / 52.00 MB free]
Total: 3 [156.00 MB] / in use: 3 [156.00 MB] / in no VG: 0 [0 ]
从vg0 中移走pv
linux-0eob:/ # vgreduce vg0 /dev/sdb1
Removed "/dev/sdb1" from volume group "vg0"
再一次查看:
linux-0eob:/ # pvscan
PV /dev/sdb2 VG vg0 lvm2 [52.00 MB / 32.00 MB free]
PV /dev/sdb3 VG vg0 lvm2 [52.00 MB / 52.00 MB free]
PV /dev/sdb1 lvm2 [54.88 MB]
Total: 3 [158.88 MB] / in use: 2 [104.00 MB] / in no VG: 1 [54.88 MB]
这样/dev/sdb1就变成*分区了
怎样指定vg中逻辑块的大小 ?
我们可以使用vgcreate的-s选项指定逻辑块大小,这样可以支持更大的逻辑卷
linux-0eob:/ # vgcreate vg1 -s 8M /dev/sdb1
Volume group "vg1" successfully created
linux-0eob:/ # vgdisplay vg1
--- Volume group ---
VG Name vg1
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 48.00 MB
PE Size 8.00 MB
Total PE 6
Alloc PE / Size 0 / 0
Free PE / Size 6 / 48.00 MB
VG UUID UWko2s-q9Qp-ybSZ-ZHJr-1FHl-R60q-8jzaR5
在vg1上创建逻辑卷
linux-0eob:/ # lvcreate -n lvdata2 -l 2 vg1
Logical volume "lvdata2" created
linux-0eob:/ # lvdisplay
--- Logical volume ---
LV Name /dev/vg0/lvdata
VG Name vg0
LV UUID tYWFX0-Msor-q6I3-dZjE-W06M-UKyj-McRdpP
LV Write Access read/write
LV Status available
# open 1
LV Size 20.00 MB
Current LE 5
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/vg1/lvdata2
VG Name vg1
LV UUID U2y1YP-uHOb-dKh3-pZTP-LFXJ-mOUm-hFZKzZ
LV Write Access read/write
LV Status available
# open 0
LV Size 16.00 MB
Current LE 2
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
lvcreate 强大的功能还有哪些 ?
-s 选项可以备份lv中的数据,--snapshots;可以实时捕捉数据的变化.
但是这种方式只能在负载不高的情形下进行.
linux-0eob:/ # lvcreate -n snap -s -l 4 /dev/vg1/lvdata2
Logical volume "snap" created
这样/dev/vg1/lvdata2 中的内容会与 /dev/vg1/snap下的数据是实时同步的
如何转换逻辑卷的状态 ?
linux-0eob:/ # lvscan
ACTIVE '/dev/vg0/lvdata' [20.00 MB] inherit
ACTIVE Original '/dev/vg1/lvdata2' [16.00 MB] inherit
ACTIVE Snapshot '/dev/vg1/snap' [32.00 MB] inherit
linux-0eob:/ # vgchange -an vg0
Can't deactivate volume group "vg0" with 1 open logical volume(s)
linux-0eob:/ # vgchange -an vg1
0 logical volume(s) in volume group "vg1" now active
linux-0eob:/ # lvscan
ACTIVE '/dev/vg0/lvdata' [20.00 MB] inherit
inactive Original '/dev/vg1/lvdata2' [16.00 MB] inherit
inactive Snapshot '/dev/vg1/snap' [32.00 MB] inherit
linux-0eob:/ # vgchange -ay vg1
1 logical volume(s) in volume group "vg1" now active
linux-0eob:/ # lvscan
ACTIVE '/dev/vg0/lvdata' [20.00 MB] inherit
ACTIVE Original '/dev/vg1/lvdata2' [16.00 MB] inherit
ACTIVE Snapshot '/dev/vg1/snap' [32.00 MB] inherit