在PROXMOX Virtual Environment中,选择需要增加磁盘容量的虚拟机,点击硬件,然后点击调整磁盘大小,输入想要增加的磁盘容量大小。
jwu@jwu:~/ptk51_docker$ sudo fdisk -l Disk /dev/loop1: 55.5 MiB, 58183680 bytes, 113640 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop2: 61.79 MiB, 64770048 bytes, 126504 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop3: 61.93 MiB, 64913408 bytes, 126784 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop4: 67.25 MiB, 70508544 bytes, 137712 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop5: 43.28 MiB, 45371392 bytes, 88616 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop6: 32.32 MiB, 33878016 bytes, 66168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop7: 67.26 MiB, 70516736 bytes, 137728 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes GPT PMBR size mismatch (268435455 != 1610612735) 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: 768 GiB, 824633720832 bytes, 1610612736 sectors Disk model: QEMU HARDDISK 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: F2F367E0-BE05-4D72-A6C0-4B42A69133CD Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 2101247 2097152 1G Linux filesystem /dev/sda3 2101248 268433407 266332160 127G Linux filesystem Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 63.51 GiB, 68182605824 bytes, 133169152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop8: 55.52 MiB, 58204160 bytes, 113680 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes给分区增加空间
在此处使用resizepart 3 100%把所有剩余的空间增加到/dev/sda3分区。
jwu@jwu:~/ptk51_docker$ parted /dev/sda WARNING: You are not superuser. Watch out for permissions. Error: Error opening /dev/sda: Permission denied Retry/Cancel? ^C jwu@jwu:~/ptk51_docker$ sudo parted /dev/sda GNU Parted 3.3 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) resizepart 3 100% Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 1342177280 blocks) or continue with the current setting? Fix/Ignore? fix Partition number? 3 End? [137GB]? free(): invalid pointer Aborted jwu@jwu:~/ptk51_docker$ sudo parted /dev/sda GNU Parted 3.3 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) resizepart 3 100% (parted) quit Information: You may need to update /etc/fstab.查看分区和磁盘使用情况
这里能够看到分区已经增加到了 767G。但是磁盘却还是128G。这是因为没有更新物理卷。
# 查看分区 jwu@jwu:~/ptk51_docker$ sudo fdisk -l Disk /dev/loop1: 55.5 MiB, 58183680 bytes, 113640 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop2: 61.79 MiB, 64770048 bytes, 126504 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop3: 61.93 MiB, 64913408 bytes, 126784 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop4: 67.25 MiB, 70508544 bytes, 137712 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop5: 43.28 MiB, 45371392 bytes, 88616 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop6: 32.32 MiB, 33878016 bytes, 66168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop7: 67.26 MiB, 70516736 bytes, 137728 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sda: 768 GiB, 824633720832 bytes, 1610612736 sectors Disk model: QEMU HARDDISK 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: F2F367E0-BE05-4D72-A6C0-4B42A69133CD Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 2101247 2097152 1G Linux filesystem /dev/sda3 2101248 1610612702 1608511455 767G Linux filesystem Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 63.51 GiB, 68182605824 bytes, 133169152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop8: 55.52 MiB, 58204160 bytes, 113680 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes # 查看磁盘使用情况 jwu@jwu:~$ sudo df -hl [sudo] password for jwu: Filesystem Size Used Avail Use% Mounted on udev 1.9G 0 1.9G 0% /dev tmpfs 394M 1.1M 393M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv 63G 35G 25G 59% / tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/sda2 976M 206M 704M 23% /boot /dev/loop3 68M 68M 0 100% /snap/lxd/21835 /dev/loop1 62M 62M 0 100% /snap/core20/1081 /dev/loop5 56M 56M 0 100% /snap/core18/2284 /dev/loop4 33M 33M 0 100% /snap/snapd/13170 /dev/loop7 68M 68M 0 100% /snap/lxd/21545 /dev/loop0 56M 56M 0 100% /snap/core18/2253 /dev/loop6 44M 44M 0 100% /snap/snapd/14295 /dev/loop2 62M 62M 0 100% /snap/core20/1270 overlay 63G 35G 25G 59% /var/lib/docker/overlay2/b6d6819f2eb23004105a083b702d00f270b36d770a056180a8efffa16d1a62b0/merged tmpfs 394M 0 394M 0% /run/user/1000更新物理卷
jwu@jwu:~$ sudo pvresize /dev/sda3 Physical volume "/dev/sda3" changed 1 physical volume(s) resized or updated / 0 physical volume(s) not resized
jwu@jwu:~$ sudo lvresize --extents +100%FREE --resizefs /dev/mapper/ubuntu--vg-ubuntu--lv Size of logical volume ubuntu-vg/ubuntu-lv changed from 63.50 GiB (16256 extents) to <767.00 GiB (196351 extents). Logical volume ubuntu-vg/ubuntu-lv successfully resized. 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 = 8, new_desc_blocks = 96 The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 201063424 (4k) blocks long.再次查看磁盘使用情况
jwu@jwu:~$ df -h Filesystem Size Used Avail Use% Mounted on udev 1.9G 0 1.9G 0% /dev tmpfs 394M 1.1M 393M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv 755G 35G 689G 5% / tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/sda2 976M 206M 704M 23% /boot /dev/loop3 68M 68M 0 100% /snap/lxd/21835 /dev/loop1 62M 62M 0 100% /snap/core20/1081 /dev/loop5 56M 56M 0 100% /snap/core18/2284 /dev/loop4 33M 33M 0 100% /snap/snapd/13170 /dev/loop7 68M 68M 0 100% /snap/lxd/21545 /dev/loop0 56M 56M 0 100% /snap/core18/2253 /dev/loop6 44M 44M 0 100% /snap/snapd/14295 /dev/loop2 62M 62M 0 100% /snap/core20/1270 tmpfs 394M 0 394M 0% /run/user/1000
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)