删除硬盘的过程简单如下:
从VG删除PV->删除PV->删除该硬盘上的LVM分区->拔掉硬盘
第一步,从VG删除PV
1.删除前,先确认要删除的PV所在的VG情况:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
[root@
test
~]
# vgdisplay -v
Finding all volume
groups
Finding volume group
"VolGroup00"
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 7
VG Access
read
/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 390.53 GB
PE Size 32.00 MB
Total PE 12497
Alloc PE / Size 653 / 20.41 GB
Free PE / Size 11844 / 370.12 GB
VG UUID 0UvEJz-rfLm-MVDb-20uW-JMCa-T14K-wCmyLO
--- Logical volume ---
LV Name
/dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID fDHwa0-IUZV-no5O-RRJB-4N9o-U2MV-TAqucp
LV Write Access
read
/write
LV Status available
# open 1
LV Size 15.00 GB
Current LE 480
Segments 1
Allocation inherit
Read ahead sectors auto
- currently
set
to 256
Block device 253:0
--- Logical volume ---
LV Name
/dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID cUjKA9-bI60-6R05-K0jS-MdXi-r26d-mfwU8X
LV Write Access
read
/write
LV Status available
# open 1
LV Size 5.41 GB
Current LE 173
Segments 1
Allocation inherit
Read ahead sectors auto
- currently
set
to 256
Block device 253:1
--- Physical volumes ---
PV Name
/dev/cciss/c0d0p3
PV UUID 6K7yBW-NuRf-3Quv-LU8U-6N1S-DmzG-ccCmbx
PV Status allocatable
Total PE / Free PE 8122 / 7469
PV Name
/dev/cciss/c0d1p1
<--要从VG里移除的PV
PV UUID TWzjBK-0N5x-1A6c-wht3-n4l1-7gFp-m24iy3
PV Status allocatable
Total PE / Free PE 4375 / 4375
|
可以看到VG名为VolGroup00的最后那一段PV名字是/dev/cciss/c0d1p1就是我要从VG里删除的PV。
2.从VG删除PV
1
2
|
[root@
test
~]
# vgreduce VolGroup00 /dev/cciss/c0d1p1
Removed
"/dev/cciss/c0d1p1"
from volume group
"VolGroup00"
|
3.确认是否已经删除
1
2
3
|
[root@
test
~]
# vgdisplay -v VolGroup00 | grep "/dev/cciss/c0d1p1"
Using volume group(s) on
command
line
Finding volume group
"VolGroup00"
|
可以看到,VolGroup00里已经不包含名为/dev/cciss/c0d1p1的PV了。
第二步,删除PV
1.确认PV信息:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@
test
~]
# pvdisplay
--- Physical volume ---
PV Name
/dev/cciss/c0d0p3
VG Name VolGroup00
PV Size 253.82 GB / not usable 6.99 MB
Allocatable
yes
PE Size (KByte) 32768
Total PE 8122
Free PE 7469
Allocated PE 653
PV UUID 6K7yBW-NuRf-3Quv-LU8U-6N1S-DmzG-ccCmbx
"/dev/cciss/c0d1p1"
is a new physical volume of
"136.73 GB"
--- NEW Physical volume ---
PV Name
/dev/cciss/c0d1p1
<--我们要删除的PV
VG Name
PV Size 136.73 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID TWzjBK-0N5x-1A6c-wht3-n4l1-7gFp-m24iy3
|
名为/dev/cciss/c0d1p1的就是我们要删除的PV。
2.删除PV
1
2
|
[root@
test
~]
# pvremove /dev/cciss/c0d1p1
Labels on physical volume
"/dev/cciss/c0d1p1"
successfully wiped
|
3.确认PV是否删除成功
1
2
|
[root@
test
~]
# pvdisplay | grep "/dev/cciss/c0d1p1"
[root@
test
~]
#
|
可见,已经删除成功。
第三步,删除该硬盘(/dev/cciss/c0d1)上的LVM分区(/dev/cciss/c0d1p1)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
[root@
test
~]
# fdisk /dev/cciss/c0d1
The number of cylinders
for
this disk is
set
to 35139.
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/cciss/c0d1
: 146.8 GB, 146807930880 bytes
255 heads, 32 sectors
/track
, 35139 cylinders
Units = cylinders of 8160 * 512 = 4177920 bytes
Device Boot Start End Blocks Id System
/dev/cciss/c0d1p1
1 35139 143367104 8e Linux LVM
Command (m
for
help): d <--删除分区
Selected partition 1
Command (m
for
help): p <--在显示分区情况,发现已经没了
Disk
/dev/cciss/c0d1
: 146.8 GB, 146807930880 bytes
255 heads, 32 sectors
/track
, 35139 cylinders
Units = cylinders of 8160 * 512 = 4177920 bytes
Device Boot Start End Blocks Id System
Command (m
for
help): w <--保存退出
The partition table has been altered!
Calling ioctl() to re-
read
partition table.
Syncing disks.
附加:在增加逻辑卷空间的第一次报错 是
Couldn
't find device with uuid '
nsLqhQ-7new-6cSe-EWQz-kusd-U2Ht-zJ2joY'.
类的错误
通过
vgreduce --removemissing VolGroup00(vg名字)
清理后从新 添加
|
好了,现在可以拔掉硬盘了或者拿来做爱做之事!
具体可参考:http://www.litvip.com/category/lvm%e4%bd%bf%e7%94%a8/
本文转自奔跑在路上博客51CTO博客,原文链接http://blog.51cto.com/qiangsh/1559396如需转载请自行联系原作者
qianghong000