CentOS 7 动态调整lv分区:扩大 root分区缩小home分区

官方提供的机器/root分区50G,/home分区395G,但是客户就是喜欢所有的磁盘都挂载到/root下,所以需要调整下LV分区大小。参考了这个:http://www.linuxidc.com/Linux/2017-03/141301.htm。

1、卸载/home分区

[root@localhost /]# umount /home/

2、删除 /dev/mapper/centos-home

[root@localhost /]# lvremove /dev/mapper/centos-home
Do you really want to remove active logical volume home? [y/n]: y
Logical volume “home” successfully removed

3、扩容/dev/mapper/centos-root分区,加大390G。

[root@localhost /]# lvextend -L +390G /dev/mapper/centos-root
Insufficient free space: 101120 extents needed, but only 100962 available

4、扩展/root文件系统。

[root@localhost /]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

5、重新创建home lv磁盘。

lvcreate -L 1G -n /dev/mapper/centos-home

6、创建文件系统,挂载/home

mkfs.xfs /dev/mapper/centos-home
mount /dev/mapper/centos-home
7、查看下磁盘分区,/扩展到440G了。

[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 440G 1.2G 439G 1% /
devtmpfs devtmpfs 32G 0 32G 0% /dev
tmpfs tmpfs 32G 0 32G 0% /dev/shm
tmpfs tmpfs 32G 8.7M 32G 1% /run
tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/sda1 xfs 497M 127M 371M 26% /boot
/dev/mapper/centos-home xfs 1014M 33M 982M 4% /home
tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/0

发表评论

电子邮件地址不会被公开。 必填项已用*标注