ProxmoxVE之系统重装磁盘清理
上次有一台物理机装了PVE,由于当初规划没有规划好,在配置使用存储的时候出了问题,后面索性就重装,当重装后发现除了系统盘会格式化之外,其他原先的盘的分区信息还是存在,特别是残留了大量的lvm的信息,所以还是需要手工去干预处理。这里做一个记录。
公司专注于为企业提供成都做网站、网站制作、成都外贸网站建设、微信公众号开发、商城网站建设,小程序开发,软件按需制作网站等一站式互联网企业服务。凭借多年丰富的经验,我们会仔细了解各客户的需求而做出多方面的分析、设计、整合,为客户设计出具风格及创意性的商业解决方案,成都创新互联更提供一系列网站制作和网站推广的服务。
按照一般的lvm删除lv vg pv的顺序,首先是删除vg下的lv ,再删除vg,最后删除pv ,但是一般情况下pve在使用过程中会产生大量的lv,所以在删除的时候,可以使用vgremove命令直接删除vg,会同时将vg下的lv删除。
重装完成后,pve节点会自己创建一个叫pve的vg ,除此之外的,都是原来残留的vg,如下所示:
root@pve:~# vgdisplay |more --- Volume group --- VG Name ceph-d910d1d3-3595-4c5a-93ed-579e4a0968b4 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 17 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 30.00 GiB PE Size 4.00 MiB Total PE 7679 Alloc PE / Size 7679 / 30.00 GiB Free PE / Size 0 / 0 VG UUID Ngu9qK-BILc-sY4K-BFLG-0ICd-k4Fp-5mVXpg --- Volume group --- VG Name ceph-3ab6b8cb-a06c-458f-9947-eaaf40fc0525 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 17 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 30.00 GiB PE Size 4.00 MiB Total PE 7679 Alloc PE / Size 7679 / 30.00 GiB Free PE / Size 0 / 0 VG UUID T8ReNU-YOdO-Bver-KdYe-NG1p-qoiv-T6tUO1 --- Volume group --- VG Name ceph-aa50bad9-b042-40bd-b060-438cddaf8ff2 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 17 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 30.00 GiB PE Size 4.00 MiB Total PE 7679 Alloc PE / Size 7679 / 30.00 GiB Free PE / Size 0 / 0 VG UUID Wnn3OH-X11z-TovS-VFxn-sbz7-btsH-jPbUUa --- Volume group --- VG Name ceph-38029056-30a1-4bb8-b94f-da32dde62217 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 17 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 30.00 GiB PE Size 4.00 MiB Total PE 7679 Alloc PE / Size 7679 / 30.00 GiB Free PE / Size 0 / 0 VG UUID IT06de-ABnj-yE07-4VFS-WqES-0cep-7j3O4I --- Volume group --- VG Name vg-sdb System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 32.00 GiB PE Size 4.00 MiB Total PE 8191 Alloc PE / Size 7696 / 30.06 GiB Free PE / Size 495 / 1.93 GiB VG UUID QDHI0E-K5Vd-DZ77-o6N9-JRGC-AezH-eIai7Q --- Volume group --- VG Name pvevg2 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 493 VG Access read/write VG Status resizable MAX LV 0 Cur LV 23 Open LV 7 Max PV 0 Cur PV 1 Act PV 1 VG Size 556.93 GiB PE Size 4.00 MiB Total PE 142573 Alloc PE / Size 140836 / 550.14 GiB Free PE / Size 1737 / 6.79 GiB VG UUID 0NWJ32-iGhh-jPU8-BwxZ-46Ie-5DDB-md0XFB --- Volume group --- VG Name ceph-18ccfe46-ab1a-44e4-9b5e-910d55679b2d System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 17 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 30.00 GiB PE Size 4.00 MiB Total PE 7679 Alloc PE / Size 7679 / 30.00 GiB Free PE / Size 0 / 0 VG UUID 6A7ViB-O1UM-sbBw-iCSn-RR3D-IA2o-Uf5nMW --- Volume group --- VG Name ceph-ca21f994-6ea2-4d97-9377-b71e1713089d System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 17 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 30.00 GiB PE Size 4.00 MiB Total PE 7679 Alloc PE / Size 7679 / 30.00 GiB Free PE / Size 0 / 0 VG UUID bBvYWE-skn5-lD6G-A0aa-HvC1-cufv-HPh69e --- Volume group --- VG Name pve System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 556.68 GiB PE Size 4.00 MiB Total PE 142509 Alloc PE / Size 138413 / 540.68 GiB Free PE / Size 4096 / 16.00 GiB VG UUID 3rZ2nK-8oci-O0gh-c6ac-1XXX-slCA-5kh4jZ
接下来删除除了pve以外的所有vg:
root@pve:~# vgremove ceph-d910d1d3-3595-4c5a-93ed-579e4a0968b4 Do you really want to remove volume group "ceph-d910d1d3-3595-4c5a-93ed-579e4a0968b4" containing 1 logical volumes? [y/n]: y Do you really want to remove and DISCARD active logical volume ceph-d910d1d3-3595-4c5a-93ed-579e4a0968b4/osd-block-8b281dbd-5dac-40c7-86a9-2eadcd9d876b? [y/n]: y Logical volume "osd-block-8b281dbd-5dac-40c7-86a9-2eadcd9d876b" successfully removed Volume group "ceph-d910d1d3-3595-4c5a-93ed-579e4a0968b4" successfully removed root@pve:~# root@pve:~# vgremove ceph-3ab6b8cb-a06c-458f-9947-eaaf40fc0525 Do you really want to remove volume group "ceph-3ab6b8cb-a06c-458f-9947-eaaf40fc0525" containing 1 logical volumes? [y/n]: y Do you really want to remove and DISCARD active logical volume ceph-3ab6b8cb-a06c-458f-9947-eaaf40fc0525/osd-block-7b89b395-2506-4997-a545-14eb1a5a029f? [y/n]: y Logical volume "osd-block-7b89b395-2506-4997-a545-14eb1a5a029f" successfully removed Volume group "ceph-3ab6b8cb-a06c-458f-9947-eaaf40fc0525" successfully removed root@pve:~# root@pve:~# vgremove -f ceph-aa50bad9-b042-40bd-b060-438cddaf8ff2 Logical volume "osd-block-c1ccede6-d03b-409b-952d-57fd702b08fd" successfully removed Volume group "ceph-aa50bad9-b042-40bd-b060-438cddaf8ff2" successfully removed root@pve:~# root@pve:~# vgremove -f ceph-38029056-30a1-4bb8-b94f-da32dde62217 Logical volume "osd-block-a2331e8c-907b-48dd-a053-071d0e1d88ca" successfully removed Volume group "ceph-38029056-30a1-4bb8-b94f-da32dde62217" successfully removed root@pve:~# vgremove -f vg-sdb Logical volume "lvm-sdb" successfully removed Volume group "vg-sdb" successfully removed root@pve:~# vgremove -f pvevg2 Logical volume "vm-112-disk-3" successfully removed Logical volume "vm-112-disk-4" successfully removed Logical volume "vm-111-disk-5" successfully removed Logical volume "vm-112-disk-5" successfully removed Logical volume "vm-113-disk-5" successfully removed Logical volume "vm-112-disk-7" successfully removed Logical volume "snap_vm-112-disk-2_pve52init1" successfully removed Logical volume "snap_vm-112-disk-6_pve52init1" successfully removed Logical volume "vm-111-state-pve52ceph2" successfully removed Logical volume "vm-113-state-pve52ceph2" successfully removed Logical volume "vm-111-state-pve52cephok" successfully removed Logical volume "vm-113-state-pve52cephok" successfully removed Logical volume pvevg2/vm-111-disk-2 is used by another device. root@pve:~# vgremove ceph-18ccfe46-ab1a-44e4-9b5e-910d55679b2d -f Logical volume "osd-block-7e68233c-97b2-4bd7-8d24-a48212e02943" successfully removed Volume group "ceph-18ccfe46-ab1a-44e4-9b5e-910d55679b2d" successfully removed root@pve:~# vgremove ceph-ca21f994-6ea2-4d97-9377-b71e1713089d -f Logical volume "osd-block-a489f6f9-e24d-408c-ada2-850dbe876c23" successfully removed Volume group "ceph-ca21f994-6ea2-4d97-9377-b71e1713089d" successfully removed root@pve:~#
再次查看vg和pv情况:
root@pve:~# vgdisplay --- Volume group --- VG Name pve System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 556.68 GiB PE Size 4.00 MiB Total PE 142509 Alloc PE / Size 138413 / 540.68 GiB Free PE / Size 4096 / 16.00 GiB VG UUID 3rZ2nK-8oci-O0gh-c6ac-1XXX-slCA-5kh4jZ root@pve:~# root@pve:~# pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name pve PV Size 556.68 GiB / not usable 1.98 MiB Allocatable yes PE Size 4.00 MiB Total PE 142509 Free PE 4096 Allocated PE 138413 PV UUID 6LqVrb-YLWy-doYc-RMVR-XA58-6XuQ-sSVpwD "/dev/sdb1" is a new physical volume of "556.93 GiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size 556.93 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID 45XFJa-Uixa-4zi7-2Bbe-LnEs-vRea-XAKjiB
清理成功!
另外,记录一下,如果碰到一些lv像狗皮膏药一样怎么删都提示设备忙被占用的情况下怎么删除的方法。我参考了这个网址的内容:
http://blog.roberthallam.org/2017/12/solved-logical-volume-is-used-by-another-device/comment-page-1/
主要是用到了dmsetup这个更加底层的指令,主要步骤如下:
# lvremove -v /dev/vg/lv-old DEGRADED MODE. Incomplete RAID LVs will be processed. Using logical volume(s) on command line Logical volume vg/lv-old is used by another device. # dmsetup info -c | grep old vg-lv--old 253 9 L--w 1 2 1 LVM-6O3jLvI6ZR3fg6ZpMgTlkqAudvgkfphCyPcP8AwpU2H57VjVBNmFBpL Tis8ia0NE $ ls -la /sys/dev/block/253\:9/holders drwxr-xr-x 2 root root 0 Dec 12 01:07 . drwxr-xr-x 8 root root 0 Dec 12 01:07 .. lrwxrwxrwx 1 root root 0 Dec 12 01:07 dm-18 -> ../../dm-18 # dmsetup remove /dev/dm-18 # lvremove -v /dev/vgraid6/lv-old
当前名称:ProxmoxVE之系统重装磁盘清理
地址分享:http://pwwzsj.com/article/igehpj.html