1.基础环境:
root@teamol:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 796M 1.3M 794M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 98G 75G 19G 80% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 976M 80M 829M 9% /boot
tmpfs 796M 0 796M 0% /run/user/1000
tmpfs 796M 0 796M 0% /run/user/0
root@teamol:~# vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size <98.99 GiB
PE Size 4.00 MiB
Total PE 25341
Alloc PE / Size 25318 / <98.90 GiB
Free PE / Size 23 / 92.00 MiB
VG UUID ARl3Ft-Mdm9-h0Bl-xpuX-S2rq-KeFF-eMBpqi
---------------------------------------------
2.扩容操作:
190 df -h
191 fdisk -l /dev/sda
192 fdisk /dev/sda——vm虚拟机磁盘扩容后,fdisk命令进行系统内扩容,分区格式设置为lvm
193 fdisk -l /dev/sda
194 partprobe /dev/sda5——新建的分区sda5写入内核
195 df -h
196 partprobe /dev/sda
197 df -h
198 pvcreate /dev/sda5——LVM建pv
199 df -h
200 fdisk -l /dev/sda
201 ll
202 df -h
206 vgdisplay
207 vgextend ubuntu-vg /dev/sda5——扩容新建的pv至vg
208 df -h
209 lvextend -L +20G /dev/mapper/ubuntu--vg-ubuntu--lv——扩容LV
210 df -h
211 resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv——文件系统扩容
xfs的文件系统重新定义大小用如下命令:
# xfs_growfs /dev/mapper/centos-root
212 df -h——扩容完成,查看文件系统级大小