基础知识 -- Linux 逻辑卷管理技术2

sunln00 2011-04-01

怎样从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/sdb1VGvg0lvm2[52.00MB/52.00MBfree]

PV/dev/sdb2VGvg0lvm2[52.00MB/32.00MBfree]

PV/dev/sdb3VGvg0lvm2[52.00MB/52.00MBfree]

Total:3[156.00MB]/inuse:3[156.00MB]/innoVG:0[0]

从vg0中移走pv

linux-0eob:/ # vgreduce vg0 /dev/sdb1

  Removed "/dev/sdb1" from volume group "vg0"

再一次查看:

linux-0eob:/#pvscan

PV/dev/sdb2VGvg0lvm2[52.00MB/32.00MBfree]

PV/dev/sdb3VGvg0lvm2[52.00MB/52.00MBfree]

PV/dev/sdb1lvm2[54.88MB]

Total:3[158.88MB]/inuse:2[104.00MB]/innoVG:1[54.88MB]

这样/dev/sdb1就变成自由分区了

怎样指定vg中逻辑块的大小 ?

我们可以使用vgcreate的-s选项指定逻辑块大小,这样可以支持更大的逻辑卷

linux-0eob:/#vgcreatevg1-s8M/dev/sdb1

Volumegroup"vg1"successfullycreated

linux-0eob:/#vgdisplayvg1

---Volumegroup---

VGNamevg1

SystemID

Formatlvm2

MetadataAreas1

MetadataSequenceNo1

VGAccessread/write

VGStatusresizable

MAXLV0

CurLV0

OpenLV0

MaxPV0

CurPV1

ActPV1

VGSize48.00MB

PESize8.00MB

TotalPE6

AllocPE/Size0/0

FreePE/Size6/48.00MB

  VG UUID               UWko2s-q9Qp-ybSZ-ZHJr-1FHl-R60q-8jzaR5

在vg1上创建逻辑卷

linux-0eob:/#lvcreate-nlvdata2-l2vg1

Logicalvolume"lvdata2"created

linux-0eob:/#lvdisplay

---Logicalvolume---

LVName/dev/vg0/lvdata

VGNamevg0

LVUUIDtYWFX0-Msor-q6I3-dZjE-W06M-UKyj-McRdpP

LVWriteAccessread/write

LVStatusavailable

#open1

LVSize20.00MB

CurrentLE5

Segments1

Allocationinherit

Readaheadsectorsauto

-currentlysetto256

Blockdevice253:0

---Logicalvolume---

LVName/dev/vg1/lvdata2

VGNamevg1

LVUUIDU2y1YP-uHOb-dKh3-pZTP-LFXJ-mOUm-hFZKzZ

LVWriteAccessread/write

LVStatusavailable

#open0

LVSize16.00MB

CurrentLE2

Segments1

Allocationinherit

Readaheadsectorsauto

-currentlysetto256

Blockdevice253:1

lvcreate 强大的功能还有哪些 ?

-s 选项可以备份lv中的数据,--snapshots;可以实时捕捉数据的变化.

但是这种方式只能在负载不高的情形下进行.

linux-0eob:/#lvcreate-nsnap-s-l4/dev/vg1/lvdata2

Logicalvolume"snap"created

这样/dev/vg1/lvdata2 中的内容会与 /dev/vg1/snap下的数据是实时同步的

如何转换逻辑卷的状态 ?

linux-0eob:/#lvscan

ACTIVE'/dev/vg0/lvdata'[20.00MB]inherit

ACTIVEOriginal'/dev/vg1/lvdata2'[16.00MB]inherit

ACTIVESnapshot'/dev/vg1/snap'[32.00MB]inherit

linux-0eob:/#vgchange-anvg0

Can'tdeactivatevolumegroup"vg0"with1openlogicalvolume(s)

linux-0eob:/#vgchange-anvg1

0logicalvolume(s)involumegroup"vg1"nowactive

linux-0eob:/#lvscan

ACTIVE'/dev/vg0/lvdata'[20.00MB]inherit

inactiveOriginal'/dev/vg1/lvdata2'[16.00MB]inherit

  inactive Snapshot '/dev/vg1/snap' [32.00 MB] inherit

linux-0eob:/ # vgchange -ay vg1

1logicalvolume(s)involumegroup"vg1"nowactive

linux-0eob:/#lvscan

ACTIVE'/dev/vg0/lvdata'[20.00MB]inherit

ACTIVEOriginal'/dev/vg1/lvdata2'[16.00MB]inherit

  ACTIVE   Snapshot '/dev/vg1/snap' [32.00 MB] inherit

相关推荐