跨盘LV整合及硬盘分区合并
命令總覽
lvdisplay -v --maps /dev/rhel/var pvdisplay -v --maps /dev/sda4 pvmove -n /dev/rhel/var /dev/sda4 /dev/sda3 vgreduce rhel /dev/sda4 parted /dev/sda rm 4 parted /dev/sda unit B print free parted /dev/sda resizepart 3 1919816826879B pvresize /dev/sda3實(shí)驗(yàn)環(huán)境
設(shè)備型號(hào):IBM Power 822LC
操作系統(tǒng):RHEL7.3
背景
/dev/rhel/var這個(gè)LV跨盤了,對于強(qiáng)迫癥患者實(shí)在難以忍受。
[root@localhost ~]# lsblk NAME???????????????? MAJ:MIN RM? SIZE RO TYPE MOUNTPOINT sda??????????????????? 8:0??? 0? 1.8T? 0 disk |-sda1???????????????? 8:1??? 0?? 10M? 0 part |-sda2???????????????? 8:2??? 0??? 2G? 0 part /boot |-sda3???????????????? 8:3??? 0? 684G? 0 part | |-rhel-root??????? 253:0??? 0? 100G? 0 lvm? / | |-rhel-swap??????? 253:1??? 0?? 64G? 0 lvm? [SWAP] | |-rhel-home??????? 253:3??? 0?? 50G? 0 lvm? /home | `-rhel-var???????? 253:5??? 0?? 50G? 0 lvm? /var `-sda4???????????????? 8:4??? 0? 1.1T? 0 part `-rhel-var???????? 253:5??? 0?? 50G? 0 lvm? /var [root@localhost ~]#經(jīng)分析,/dev/sda3這個(gè)分區(qū),完全有能力接收/dev/rhel/var這個(gè)LV,并且還有盈余。???
所以,這里的思路是,將/dev/rhel/var全部遷移至/dev/sda3,之后/dev/sda4將完全閑置。此時(shí),可將/dev/sda4從rhel這個(gè)vg移除。直接上干貨。
查看LV分布:
[root@localhost ~]# lvdisplay -v --maps /dev/rhel/var--- Logical volume ---LV Path??????????????? /dev/rhel/varLV Name??????????????? varVG Name??????????????? rhelLV UUID??????????????? q0NMQ9-jYJt-zbfr-CJ5C-N7JN-u1nh-vLjJUwLV Write Access??????? read/writeLV Creation host, time localhost.localdomain, 2017-12-25 15:09:33 +0800LV Status????????????? available# open???????????????? 1LV Size??????????????? 50.00 GiBCurrent LE???????????? 12800Segments?????????????? 3Allocation???????????? inheritRead ahead sectors???? auto- currently set to???? 8192Block device?????????? 253:5--- Segments ---Logical extents 0 to 2559:Type??????????????? linearPhysical volume???? /dev/sda3Physical extents??? 156160 to 158719Logical extents 2560 to 2560:Type??????????????? linearPhysical volume???? /dev/sda3Physical extents??? 175104 to 175104Logical extents 2561 to 12799:Type??????????????? linearPhysical volume???? /dev/sda4Physical extents??? 76800 to 87038 [root@localhost ~]#這可以看到有87038-76800=10238個(gè)PE,此時(shí),檢查下/dev/sda3的Free PE是否足夠:
[root@localhost ~]# vgdisplay -v rhel ...--- Physical volumes ---PV Name?????????????? /dev/sda3??? ?PV UUID?????????????? icxEvA-jJqk-O0cb-g6De-vMl7-WdLr-4f0yXIPV Status???????????? allocatableTotal PE / Free PE??? 175105 / 117760PV Name?????????????? /dev/sda4??? ?PV UUID?????????????? l9SJmE-SzMU-T49o-kW46-UWKF-gcps-0FTvDNPV Status???????????? allocatableTotal PE / Free PE??? 282099 / 271860顯然,117760遠(yuǎn)遠(yuǎn)大于10238。
我們再次確認(rèn)下/dev/sda4只有var這個(gè)LV,避免遺漏:
[root@localhost ~]# pvdisplay -v --maps /dev/sda4Wiping internal VG cacheWiping cache of LVM-capable devices--- Physical volume ---PV Name?????????????? /dev/sda4VG Name?????????????? rhelPV Size?????????????? 1.08 TiB / not usable 0? ?Allocatable?????????? yes PE Size?????????????? 4.00 MiBTotal PE????????????? 282099Free PE?????????????? 271860Allocated PE????????? 10239PV UUID?????????????? l9SJmE-SzMU-T49o-kW46-UWKF-gcps-0FTvDN--- Physical Segments ---Physical extent 0 to 76799:FREEPhysical extent 76800 to 87038:Logical volume????? /dev/rhel/varLogical extents???? 2561 to 12799Physical extent 87039 to 282098:確無遺漏,可以開始遷移了。這邊查了下manual,需要用到pvmove命令:
[root@localhost ~]# pvmove -n /dev/rhel/var /dev/sda4 /dev/sda3/dev/sda4: Moved: 0.00%/dev/sda4: Moved: 7.80%/dev/sda4: Moved: 15.63%/dev/sda4: Moved: 23.46%/dev/sda4: Moved: 31.28%/dev/sda4: Moved: 39.12%/dev/sda4: Moved: 46.94%/dev/sda4: Moved: 54.76%/dev/sda4: Moved: 62.59%/dev/sda4: Moved: 70.42%/dev/sda4: Moved: 78.24%/dev/sda4: Moved: 86.06%/dev/sda4: Moved: 93.88%/dev/sda4: Moved: 100.00% [root@localhost ~]#完成后,再次檢查下。
[root@localhost ~]# lsblk NAME???????????????? MAJ:MIN RM? SIZE RO TYPE MOUNTPOINT sda??????????????????? 8:0??? 0? 1.8T? 0 disk |-sda1???????????????? 8:1??? 0?? 10M? 0 part |-sda2???????????????? 8:2??? 0??? 2G? 0 part /boot |-sda3???????????????? 8:3??? 0? 684G? 0 part | |-rhel-root??????? 253:0??? 0? 100G? 0 lvm? / | |-rhel-swap??????? 253:1??? 0?? 64G? 0 lvm? [SWAP] | |-rhel-home??????? 253:3??? 0?? 50G? 0 lvm? /home | `-rhel-var???????? 253:5??? 0?? 50G? 0 lvm? /var `-sda4???????????????? 8:4??? 0? 1.1T? 0 part [root@localhost ~]# [root@localhost ~]# vgdisplay -v rhel--- Physical volumes ---PV Name?????????????? /dev/sda3??? ?PV UUID?????????????? icxEvA-jJqk-O0cb-g6De-vMl7-WdLr-4f0yXIPV Status???????????? allocatableTotal PE / Free PE??? 175105 / 107521PV Name?????????????? /dev/sda4??? ?PV UUID?????????????? l9SJmE-SzMU-T49o-kW46-UWKF-gcps-0FTvDNPV Status???????????? allocatableTotal PE / Free PE??? 282099 / 282099Archiving volume group "rhel" metadata (seqno 21).Archiving volume group "rhel" metadata (seqno 23).Creating volume group backup "/etc/lvm/backup/rhel" (seqno 23). [root@localhost ~]# [root@localhost ~]# lvdisplay -v --maps /dev/rhel/var--- Logical volume ---LV Path??????????????? /dev/rhel/varLV Name??????????????? varVG Name??????????????? rhelLV UUID??????????????? q0NMQ9-jYJt-zbfr-CJ5C-N7JN-u1nh-vLjJUwLV Write Access??????? read/writeLV Creation host, time localhost.localdomain, 2017-12-25 15:09:33 +0800LV Status????????????? available# open???????????????? 1LV Size??????????????? 50.00 GiBCurrent LE???????????? 12800Segments?????????????? 3Allocation???????????? inheritRead ahead sectors???? auto- currently set to???? 8192Block device?????????? 253:5--- Segments ---Logical extents 0 to 2559:Type??????????????? linearPhysical volume???? /dev/sda3Physical extents??? 156160 to 158719Logical extents 2560 to 2560:Type??????????????? linearPhysical volume???? /dev/sda3Physical extents??? 175104 to 175104Logical extents 2561 to 12799:Type??????????????? linearPhysical volume???? /dev/sda3Physical extents??? 12800 to 23038 [root@localhost ~]#可以看到/dev/rhel/var已經(jīng)完全落在/dev/sda3這個(gè)PV上。
現(xiàn)在剩余的工作就是將/dev/sda4移除vg,然后再將剩余空間擴(kuò)在/dev/sda3上,直接上干貨,移除PV:
[root@localhost log]# vgreduce rhel /dev/sda4Removed "/dev/sda4" from volume group "rhel" [root@localhost log]# [root@localhost log]# vgdisplay -v rhel--- Physical volumes ---PV Name?????????????? /dev/sda3??? ?PV UUID?????????????? icxEvA-jJqk-O0cb-g6De-vMl7-WdLr-4f0yXIPV Status???????????? allocatableTotal PE / Free PE??? 175105 / 107521 [root@localhost log]#將剩余空間擴(kuò)在/dev/sda3上:
[root@localhost log]# parted /dev/sda rm 4 信息: You may need to update /etc/fstab. [root@localhost log]# [root@localhost log]# parted /dev/sda unit B print free Model: LSI MR9361-8i (scsi) Disk /dev/sda: 1919816826880B Sector size (logical/physical): 512B/4096B Partition Table: msdos Disk Flags: Number? Start????????? End???????????? Size??????????? Type???? File system? 標(biāo)志32256B???????? 1048575B??????? 1016320B???????????????? Free Space1????? 1048576B?????? 11534335B?????? 10485760B?????? primary?????????????? 啟動(dòng), prep2????? 11534336B????? 2159017983B???? 2147483648B???? primary? xfs3????? 2159017984B??? 736606814207B?? 734447796224B?? primary?????????????? lvm736606814208B? 1919816826879B? 1183210012672B?????????? Free Space [root@localhost log]# [root@localhost log]# parted /dev/sda? resizepart 3 1919816826879B 信息: You may need to update /etc/fstab. [root@localhost log]# [root@localhost log]# vgsVG???? #PV #LV #SN Attr?? VSize?? VFree ?rhel???? 1?? 4?? 0 wz--n- 684.00g 420.00gvgdata?? 1?? 2?? 0 wz--n-? 10.48t?? 9.70t [root@localhost log]# [root@localhost log]# pvresize /dev/sda3WARNING: Device for PV l9SJmE-SzMU-T49o-kW46-UWKF-gcps-0FTvDN not found or rejected by a filter.Physical volume "/dev/sda3" changed1 physical volume(s) resized / 0 physical volume(s) not resized [root@localhost log]# [root@localhost log]# vgsVG???? #PV #LV #SN Attr?? VSize? VFreerhel???? 1?? 4?? 0 wz--n-? 1.74t 1.49tvgdata?? 1?? 2?? 0 wz--n- 10.48t 9.70t [root@localhost log]#我們可以看到vg剩余空間,從420G變成1.49T。
[root@localhost ~]# lsblk NAME???????????????? MAJ:MIN RM? SIZE RO TYPE MOUNTPOINT sda??????????????????? 8:0??? 0? 1.8T? 0 disk |-sda1???????????????? 8:1??? 0?? 10M? 0 part |-sda2???????????????? 8:2??? 0??? 2G? 0 part /boot `-sda3???????????????? 8:3??? 0? 1.8T? 0 part|-rhel-root??????? 253:0??? 0? 100G? 0 lvm? /|-rhel-swap??????? 253:1??? 0?? 64G? 0 lvm? [SWAP]|-rhel-home??????? 253:3??? 0?? 50G? 0 lvm? /home`-rhel-var???????? 253:5??? 0?? 50G? 0 lvm? /var [root@localhost ~]#看到這里,是不是感覺舒服多了。
總結(jié)
以上是生活随笔為你收集整理的跨盘LV整合及硬盘分区合并的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Laravel 模型中 $hidden
- 下一篇: JS判断pc mobile几种方式