1)首先在vm的配置編輯中增加磁盤(pán)容量,并重啟虛擬機(jī)使其生效。
2)使用fdisk命令劃分一個(gè)新的分區(qū)并將這個(gè)新分區(qū)的 system id 改為8e(lvm格式),并執(zhí)行命令 partprobe /dev/sdxn 更新磁盤(pán)分區(qū)表。
fdisk /dev/sdxn;
pratprobe /dev/sdx;
3)使用vgextend命令擴(kuò)容vg卷的容量,可以使用--help去查詢命令幫助
命令格式如下:
vgextend VolumeGroupName PhysicalDevicePath
例子:
vgextend ubuntu-vg /dev/sda3
4)使用lvextend命令擴(kuò)容lv卷的容量,可以使用--help去查詢命令幫助
命令格式如下:
lvextend LogicalVolume[Path] [ PhysicalVolumePath... ]
例子:
lvextend /dev/ubuntu-vg/root /dev/sda3
5)使用resize2fs命令使其生效,這時(shí)如果執(zhí)行失敗請(qǐng)重啟后再執(zhí)行
命令如下:
resize2fs /dev/ubuntu-vg/root
執(zhí)行完畢后,使用df -h查看下所掛載的分區(qū)是否生效,最后再次重啟vm。
注意:centos 7 使用:xfs_growfs 命令