(...) GPT PMBR size mismatch (20971519 != 52428799) will be corrected by write. The backup GPT table is not on the end of the device. This problem will be corrected by write. Disk /dev/sda: 25 GiB, 26843545600 bytes, 52428800 sectors Disk model: Virtual disk Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 3C880C2B-2144-44D6-942C-80780689FED0
Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 1861631 1857536 907M Linux filesystem /dev/sda3 1861632 20969471 19107840 9.1G Linux filesystem (...)
物理磁盘已经扩容成功,我们接下来创建 PV 。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.34). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
GPT PMBR size mismatch (20971519 != 52428799) will be corrected by write. The backup GPT table is not on the end of the device. This problem will be corrected by write.
Command (m for help): n Partition number (4-128, default 4): First sector (20969472-52428766, default 20969472): Last sector, +/-sectors or +/-size{K,M,G,T,P} (20969472-52428766, default 52428766):
Created a new partition 4 of type 'Linux filesystem' and of size 15 GiB.
Command (m for help): w The partition table has been altered. Syncing disks.
sudo fdisk -l 再次列出所有设备。
1 2 3 4 5 6 7
(...) Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 1861631 1857536 907M Linux filesystem /dev/sda3 1861632 20969471 19107840 9.1G Linux filesystem /dev/sda4 20969472 52428766 31459295 15G Linux filesystem (...)
$ sudo lvextend /dev/mapper/ubuntu--vg-ubuntu--lv /dev/sda4 Size of logical volume ubuntu-vg/ubuntu-lv changed from <9.11 GiB (2332 extents) to <24.11 GiB (6171 extents). Logical volume ubuntu-vg/ubuntu-lv successfully resized.
扩展 LV。这里的 /dev/sda4 应该为你之前记住的 PV 名。
此时 LVM 的部分就完成了,可以调整文件系统的大小了。
1 2 3 4 5
$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv resize2fs 1.45.5 (07-Jan-2020) Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 4 The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 6319104 (4k) blocks long.
1 2 3 4
$ sudo df -h Filesystem Size Used Avail Use% Mounted on (...) /dev/mapper/ubuntu--vg-ubuntu--lv 24G 4.2G 19G 19% /