Welcome to fdisk (util-linux 2.37.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
GPT PMBR size mismatch (209715199 != 314572799) will be corrected by write. This disk is currently in use - repartitioning is probably a bad idea. It's recommended to umount all file systems, and swapoff all swap partitions on this disk.
(parted) p free Model: VMware, VMware Virtual S (scsi) Disk /dev/sda: 314572800s Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags:
Number Start End Size File system Name Flags 34s 2047s 2014s Free Space 1 2048s 4095s 2048s bios_grub 2 4096s 4198399s 4194304s ext4 3 4198400s 314572766s 310374367s
可以看到 /dev/sda3 以及扩容完毕,按 q 退出 parted。
让LVM识别到新增的磁盘容量
更新LVM中pv物理卷
1 2 3
$ sudo pvresize /dev/sda3 Physical volume "/dev/sda3" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized
查看LVM中pv状态
1 2 3 4 5 6 7 8 9 10 11
$ sudo pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name ubuntu-vg PV Size <148.00 GiB / not usable 16.50 KiB Allocatable yes PE Size 4.00 MiB Total PE 37887 Free PE 12800 Allocated PE 25087 PV UUID eKN8FR-r6VU-127T-AoNO-tjvm-AYHb-68zSSY
查看LVM逻辑卷状态
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
$ sudo lvdisplay --- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID 276mRA-dCfi-PKNd-MLKM-4lWp-SFNR-a0hAee LV Write Access read/write LV Creation host, time ubuntu-server, 2022-08-29 21:59:13 +0800 LV Status available # open 1 LV Size <98.00 GiB Current LE 25087 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
给LVM逻辑卷扩容
1 2 3
$ sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv Size of logical volume ubuntu-vg/ubuntu-lv changed from <98.00 GiB (25087 extents) to <148.00 GiB (37887 extents). Logical volume ubuntu-vg/ubuntu-lv successfully resized.
刷新逻辑卷
1 2 3 4 5
$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv resize2fs 1.46.5 (30-Dec-2021) Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required old_desc_blocks = 13, new_desc_blocks = 19 The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 38796288 (4k) blocks long.