环境: centos7.2
背景:实际上环境中,有时候遇到前期规划的部分磁盘空间根本不够用,需要对磁盘空间实现动态扩容。
例子:将/srv/other系统分区减小20G,填加到/opt分区上面。
区别两种场景:
1、安装的centos的文件系统是 xfs
[root@web ~]# lvreduce -L -20G /dev/centos/srv_other
[root@web ~]# lvextend -L +20G /dev/centos/opt
[root@web ~]# mkfs.xfs -f /dev/centos/srv_other \xfs的文件系统不支持再线减小。如需减小,还要将减小的分区进行从新格式化基本操作。
[root@web ~]# mount -a
[root@web ~]# xfs_growfs /dev/centos/opt \xfs的文件系统,再线更新扩容大小。
[root@web ~]# lsblk \查看系统分区大小是否已改变
[root@web ~]# df -h
2、安装的centos的文件系统是ext2ext3ext4
[root@web ~]# lvreduce -L -20G /dev/centos/srv_other
[root@web ~]# lvextend -L +20G /dev/centos/opt
[root@web ~]# resize2fs /dev/centos/srv_other \再线调整分区大小
[root@web ~]# resize2fs /dev/centos/opt
[root@web ~]# lsblk \查看分区大小是否已改变
[root@web ~]# df -h