lvm 扩容
总体思路:
逻辑卷要扩容,先扩容对应卷组,
扩容卷组的方式:
- 添加新的物理卷(磁盘已有分区,扩容后新建分区;或者新加了一块硬盘创建了新的物理卷),vgextend myvg /dev/vdb 扩容,/dev/vdb为示例新加了一块硬盘直接做的物理卷。
- 物理卷自身扩容(原有未分区已做物理卷的虚拟硬盘扩容,或者做物理卷的分区扩容)。直接pvresize刷新物理卷大小即可。
示例场景1:
/dev/vdc 由25G扩容到35G
[root@vm10-20-88-88 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 253:0 0 20G 0 disk └─vda1 253:1 0 20G 0 part / vdb 253:16 0 50G 0 disk vdc 253:32 0 35G 0 disk └─vdc1 253:33 0 25G 0 part └─myvg-mylv--1 252:0 0 59G 0 lvm /disk1 vdd 253:48 0 25G 0 disk └─vdd1 253:49 0 25G 0 part └─myvg-mylv--1 252:0 0 59G 0 lvm /disk1 vde 253:64 0 25G 0 disk └─vde1 253:65 0 25G 0 part └─myvg-mylv--1 252:0 0 59G 0 lvm /disk1 [root@vm10-20-88-88 ~]# pvs PV VG Fmt Attr PSize PFree /dev/vdb myvg lvm2 a-- <50.00g <50.00g /dev/vdc1 myvg lvm2 a-- <25.00g 0 /dev/vdd1 myvg lvm2 a-- <25.00g 0 /dev/vde1 myvg lvm2 a-- <25.00g <15.99g [root@vm10-20-88-88 ~]#
使用parted扩容分区方式
resizepart
[root@vm10-20-88-88 ~]# parted /dev/vdc GNU Parted 3.1 Using /dev/vdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the disk is smaller. Fix, by moving the backup to the end (and removing the old backup)?
备份GPT表没有像应该的那样位于磁盘的末尾。这可能意味着另一个操作系统认为磁盘更小。解决办法是把备份移到最后
(并删除旧的备份)?
Fix/Ignore/Cancel? f Warning: Not all of the space available to /dev/vdc appears to be used, you can fix the GPT to use all of the space (an extra 20971520 blocks) or continue with the current setting? Fix/Ignore? f
不是所有可用的空间/dev/vdc似乎被使用,您可以修复GPT使用所有空间(一个额外的20971520块)或继续当前设置?
Model: Virtio Block Device (virtblk) Disk /dev/vdc: 37.6GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 26.8GB 26.8GB (parted) print Model: Virtio Block Device (virtblk) Disk /dev/vdc: 37.6GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 26.8GB 26.8GB (parted)resizepart 1 37.6GB # 此步骤扩容了1分区 (parted) print Model: Virtio Block Device (virtblk) Disk /dev/vdc: 37.6GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 37.6GB 37.6GB (parted)
然后pvresize扩容物理卷,卷组自动扩容
[root@vm10-20-88-88 ~]# pvresize /dev/vdc1 Physical volume "/dev/vdc1" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized [root@vm10-20-88-88 ~]# vgs VG #PV #LV #SN Attr VSize VFree myvg 4 1 0 wz--n- 134.98g 75.98g [root@vm10-20-88-88 ~]#
或者新建一个分区新建物理卷,向卷组新加物理卷
vgextend myvg <新物理卷>
详细示例省略
示例场景2:
/dev/vdb磁盘未做分区,直接做了物理卷
物理卷扩容前25G
[root@vm10-20-88-88 ~]# pvs PV VG Fmt Attr PSize PFree /dev/vdb myvg lvm2 a-- <25.00g <25.00g /dev/vdc1 myvg lvm2 a-- <25.00g 0 /dev/vdd1 myvg lvm2 a-- <25.00g 0 /dev/vde1 myvg lvm2 a-- <25.00g <15.99g
虚拟机磁盘扩容....到50G
pvresize扩容物理卷
[root@vm10-20-88-88 ~]# pvresize /dev/vdb Physical volume "/dev/vdb" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized [root@vm10-20-88-88 ~]# pvs PV VG Fmt Attr PSize PFree /dev/vdb myvg lvm2 a-- <50.00g <50.00g /dev/vdc1 myvg lvm2 a-- <25.00g 0 /dev/vdd1 myvg lvm2 a-- <25.00g 0 /dev/vde1 myvg lvm2 a-- <25.00g <15.99g
vgs查看卷组大小已扩容
[root@vm10-20-88-88 ~]# vgs VG #PV #LV #SN Attr VSize VFree myvg 4 1 0 wz--n- 124.98g 65.98g [root@vm10-20-88-88 ~]#
posted on 2021-06-20 16:20 zhangmingda 阅读(546) 评论(0) 编辑 收藏 举报