Linux LVM磁盘分区动态扩容

版权声明:本文为博主-周列原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38232749/article/details/81776873

环境: 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的文件系统是ext2\ext3\ext4

[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

猜你喜欢

转载自blog.csdn.net/weixin_38232749/article/details/81776873