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/
内容如下:
引用
LVM使用之三-从卷组VG移除并删除物理卷PV
发表于 2011 年 07 月 01 日 由 steptodream
删除硬盘的过程简单如下:
从VG删除PV->删除PV->删除该硬盘上的LVM分区->拔掉硬盘
第一步,从VG删除PV
1.删除前,先确认要删除的PV所在的VG情况:
[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
[root@test ~]# vgreduce VolGroup00 /dev/cciss/c0d1p1
Removed "/dev/cciss/c0d1p1" from volume group "VolGroup00"
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.
好了,现在可以拔掉硬盘了或者拿来做爱做之事!