需要新建分區,把擴容的磁盤加到這個分區中
#fdisk /dev/sda #進入分區界面
輸入n #新建一個分區
輸入P #創建一個主分區
回車默認 #分區號
回車默認 #設置起始分區地址
回車默認 #設置大小
輸入W #保存
創建物理卷
root@ubuntu:~# pvcreate /dev/sda4 Physical volume "/dev/sda4" successfully created
查看卷組
root@ubuntu:~# vgdisplay --- Volume group --- VG Name ubuntu-vg #我這裏卷組的名字是ubuntu-vg ...
把創建的物理卷加入卷組
root@ubuntu:~# vgextend ubuntu-vg /dev/sda4 加入卷組 Volume group "ubuntu-vg" successfully extended
查看擴容的文件路徑
root@ubuntu:~# df -Th Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 971M 0 971M 0% /dev tmpfs tmpfs 199M 5.9M 193M 3% /run /dev/mapper/ubuntu--vg-root ext4 18G 1.9G 16G 12% / 。 。 。
把卷組剩餘內存容量加到擴容的文件系統上,我這裏是 /dev/mapper/ubuntu–vg-root
root@ubuntu:~# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-root Size of logical volume ubuntu-vg/root changed from 18.32 GiB (4691 extents) to 38.33 GiB (9812 extents). Logical volume root successfully resized.
刷新命令
文件類型是ext4的使用:resize2fs /dev/mapper/ubuntu–vg-root
df -Th 查看內存情況,已成功擴容。
https://blog.csdn.net/weixin_41891696/article/details/118805670