第一步,注释掉home 的开机挂载 ,可以的话删除
1 2 3 4 5 6 7 8 9 10 11 12 | [root@test_dc_5 ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Jun 23 00:52:21 2020 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/centos-root / xfs defaults 0 0 UUID=4d4521fb-197c-4633-a085-4255fb8acffc /boot xfs defaults 0 0 #/dev/mapper/centos-home /home xfs defaults 0 0 |
第二步,umount 掉挂载的点
1 | [root@test_dc_5 ~]# umount /dev/mapper/centos-home |
1 2 3 4 5 6 7 8 9 | [root@test_dc_5 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 50G 2.2G 48G 5% / devtmpfs 11G 0 11G 0% /dev tmpfs 11G 0 11G 0% /dev/shm tmpfs 11G 12M 11G 1% /run tmpfs 11G 0 11G 0% /sys/fs/cgroup /dev/sda1 1014M 146M 869M 15% /boot tmpfs 2.1G 0 2.1G 0% /run/user/0 |
第三步,删除home 的lv卷
1 2 3 | [root@test_dc_5 ~]# lvremove /dev/centos/home Do you really want to remove active logical volume centos/home? [y/n]: y Logical volume "home" successfully removed |
第四步,扩容root的lv
1 2 3 | [root@test_dc_5 ~]# lvextend -L 283G /dev/centos/root Size of logical volume centos/root changed from 282.00 GiB (72192 extents) to 283.00 GiB (72448 extents). Logical volume centos/root successfully resized. |
可以看得到虽然root的lv扩展了,但是文件系统还是50G
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | [root@test_dc_5 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 300G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 299G 0 part ├─centos-root 253:0 0 283G 0 lvm / └─centos-swap 253:1 0 15.8G 0 lvm sdb 8:16 0 300G 0 disk sr0 11:0 1 4.3G 0 rom [root@test_dc_5 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 50G 2.2G 48G 5% / devtmpfs 11G 0 11G 0% /dev tmpfs 11G 0 11G 0% /dev/shm tmpfs 11G 12M 11G 1% /run tmpfs 11G 0 11G 0% /sys/fs/cgroup /dev/sda1 1014M 146M 869M 15% /boot tmpfs 2.1G 0 2.1G 0% /run/user/0 |
第5步,扩容文件系统,完成
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | [root@test_dc_5 ~]# xfs_growfs /dev/centos/root meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=13107200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=6400, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 13107200 to 74186752 [root@test_dc_5 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 283G 2.2G 281G 1% / devtmpfs 11G 0 11G 0% /dev tmpfs 11G 0 11G 0% /dev/shm tmpfs 11G 12M 11G 1% /run tmpfs 11G 0 11G 0% /sys/fs/cgroup /dev/sda1 1014M 146M 869M 15% /boot tmpfs 2.1G 0 2.1G 0% /run/user/0 |