1,虚拟机关机,虚拟机设置->硬盘->磁盘实用工具->扩展,设置更大的磁盘总量。
2,虚拟机开机,fdisk -l看到/dev/sda:显示的容量已经扩大,后面还需要 (创建物理卷)->(加入卷组)->(扩容逻辑卷)->(操作系统reload)
创建物理卷:命令 fdisk /dev/sda (在现有sda下创建设备sda3)
[root@localhost ~]# fdisk /dev/sda
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
依次选择执行n、p、t、w (序号会自增为3,即设备名为sda3)
pvdisplay查看现有物理卷(PV Name:/dev/sda2;VG Name:centos),依然没有sda3
[root@localhost ~]# reboot
[root@localhost ~]# pvcreate /dev/sda3
重启后,执行pvcreate /dev/sda3 可添加相应的物理卷。
加入卷组:vgdisplay命令查看卷组,加入原有的卷组即可(VG Name:centos),执行vgextend centos /dev/sda3将新建的sda3物理卷加入原有的centos组
扩容逻辑卷:lvdisplay查看所有逻辑卷,找到需要扩容的逻辑卷的LV Path属性,
执行lvextend -L +20G /dev/centos/root将物理容量20G纳入逻辑卷。
也可执行lvextend /dev/centos/root /dev/sda3 将物理卷sda3全部纳入逻辑卷。
操作系统reload:执行xfs_growfs /dev/mapper/centos-root重新检测文件系统容量,这里的目录是fdisk -l查看到的逻辑磁盘名称