⑴LVM通常用于装备大量磁盘的系统,具有良好的可伸缩性,可对卷组、逻辑卷的大小进行调整,今天小编要给大家介绍的是Linux如何删除LVM中的PV物理卷(硬盘或分区,一起来学习下吧。
⑵一、由于硬盘或者分区的操作方式其实都一样,所以我这里就以分区为例。
⑶二、/home分区.G,由如下pv组成:
⑷/dev/sda M
⑸/dev/sda M
⑹/dev/sda M
⑺/dev/sda M
⑻/dev/sda M
⑼/dev/sda M
⑽/dev/sda M
⑾很碎对吧?^_^因为测试。
⑿三、随机写了一堆文件进去,用量达到了G,空闲M
⒀四、准备将sda这个M的PV卸掉(卸掉的容量必须小于空闲容量
⒁好了开始具体操作了。
⒂卸载分区(缩小操作必须卸载才能进行:
⒃umount /home
⒄efsck -f /dev/liuhg_disk/home
⒅resizefs /dev/liuhg_disk/home M
⒆首先将分区缩小到M这是为了给sda腾出空间,sda为M,而我腾出了M,因此应该是足够的。
⒇lvreduce -L M /dev/liuhg_disk/home
⒈分区缩小了用到的逻辑卷也要随着缩小,并查看PV使用的状态:
⒉pvdisplay -m
⒊--- Physical volume ---
⒋PV Name /dev/sda
⒌VG Name liuhg_disk
⒍PV Size . MiB / not usable . MiB
⒎Allocatable yes (but full
⒏PE Size . MiB
⒐Total PE
⒑Free PE
⒒Allocated PE
⒓PV UUID lnx-bjc-OOfZ-fQA-ttdQ-DZeD-Cerb
⒔--- Physical Segments ---
⒕Physical extent to :
⒖Logical volume /dev/liuhg_disk/home
⒗Logical extents to
⒘--- Physical volume ---
⒙PV Name /dev/sda
⒚VG Name liuhg_disk
⒛PV Size . MiB / not usable . MiB
①Allocatable yes (but full
②PE Size . MiB
③Total PE
④Free PE 《-----太悲剧了,sda里写满了数据一点不剩
⑤Allocated PE 《-----这PE的数据要挪走才行,否则数据就丢了,并且存放的地方也必须是连续的至少PE
⑥PV UUID Sane-nlFG-uSNR-NP-Yxa-cXRb-rEmK
⑦--- Physical Segments ---
⑧Physical extent to :
⑨Logical volume /dev/liuhg_disk/home
⑩Logical extents to
Ⅰ--- Physical volume ---
ⅡPV Name /dev/sda
ⅢVG Name liuhg_disk
ⅣPV Size . MiB / not usable . MiB
ⅤAllocatable yes
ⅥPE Size . MiB
ⅦTotal PE
ⅧFree PE 《---这个分区有个空余,因此预计装那个是不会有问题的
ⅨAllocated PE
ⅩPV UUID CFnlx-CAEw-CSul-Rig-Fi-zKa-oGmTEP
㈠--- Physical Segments ---
㈡Physical extent to :
㈢--- Physical volume ---
㈣PV Name /dev/sda
㈤VG Name liuhg_disk
㈥PV Size . MiB / not usable . MiB
㈦Allocatable yes
㈧PE Size . MiB
㈨Total PE
㈩Free PE
Allocated PE
PV UUID XIp-xxr-xLG-QQD-jbtS-Ci-xPnBl
--- Physical Segments ---
Physical extent to :
Logical volume /dev/liuhg_disk/home
Logical extents to