1. 环境
2. Proxmox 虚拟化增加虚拟机存储
注意:这里的大小是增加多少存储,而不是总存储。
3. 虚拟机操作
(1)创建磁盘新分区
$ df -h
$ fdisk /dev/sda
w
(2)扩展卷组和卷
$ pvdisplay # 查看物理卷
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <38.00 GiB / not usable 0
$ vgdisplay # 查看卷组
--- Volume group ---
VG Name ubuntu-vg # 这个就是卷组名称
System ID
Format lvm2
VG Size <38.00 GiB # 目前卷组大小
$ vgextend ubuntu-vg /dev/sda4 # 把新分区添加到卷组中
Physical volume "/dev/sda4" successfully created.
Volume group "ubuntu-vg" successfully extended
$ lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
$ lvextend -l +100%free /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <19.00 GiB (4863 extents) to 157.99 GiB (40446 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
(3)重新计算文件系统大小
此时文件系统上依然显示为原来的磁盘大小,需要使用 resize2fs 命令重新计算。
$ 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 = 3, new_desc_blocks = 20
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 41416704 (4k) blocks long.
$ df -h # 再次查看磁盘大小