读书人

lvm中物理卷的剔除

发布时间: 2012-11-03 10:57:44 作者: rapoo

lvm中物理卷的删除
1,umount相应分区:umount /xxx/xxx/xx
2,删除相应的逻辑卷(lv)
可以通过 lvdiplay 命令查看所有逻辑卷信息,然后找到要删除的逻辑卷;
通过 lvremove 逻辑卷名称 来删除逻辑卷。
3,将要删除的物理卷对应的PV从VG中移除。
命令是vgreduce vg名称 pv名称
可以通过vgdisplay -v 查看信息。
4,删除pv;
命令是pvremove pv名称
可以通过pvdispay命令查看。
5,重新对物理卷格式化;fdisk /dev/sdb
6,重新生成文件系统;mkfs.xfs /dev/sdb1

以上就是整个过程,其中的(2,3,4,5,6)步的具体方法见链接:
http://www.litvip.com/351/

内容如下:

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信息:


[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

[root@test ~]# pvremove /dev/cciss/c0d1p1
Labels on physical volume "/dev/cciss/c0d1p1" successfully wiped

3.确认PV是否删除成功

[root@test ~]# pvdisplay | grep "/dev/cciss/c0d1p1"
[root@test ~]#

可见,已经删除成功。

第三步,删除该硬盘(/dev/cciss/c0d1)上的LVM分区(/dev/cciss/c0d1p1)

[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.

好了,现在可以拔掉硬盘了或者拿来做爱做之事!

读书人网 >操作系统

热点推荐