问题:系统默认安装会出现根目录下划分空间少,大部分空间划分的home下的情况,随着根目录下文件的增加,会出现根目录满了的情况,这时需要将ome下空间释放挂载到根目录下。

进行下面的步骤需要基本的linux功底:智一面初中级LInux运维工程师在线评测

解决方法:
注意:在操作之前一定要备份/home下的文件
1.卸载home目录的挂载

[root@ecs0020 ~]# umount /home/
[root@localhost script]# df -h
文件系统               容量  已用  可用 已用% 挂载点
/dev/mapper/nlas-root   50G  1.9G   49G    4% /
devtmpfs                16G     0   16G    0% /dev
tmpfs                   16G     0   16G    0% /dev/shm
tmpfs                   16G   81M   16G    1% /run
tmpfs                   16G     0   16G    0% /sys/fs/cgroup
/dev/vda1             1014M  167M  848M   17% /boot
tmpfs                  3.2G     0  3.2G    0% /run/user/0

 2.释放home逻辑卷占用的空间

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

3.查看centos卷组剩余的释放空间的大小,然后将所以空间都添加给逻辑卷

  [root@localhost dev]# vgdisplay
  --- Volume group ---
  VG Name               nlas
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.53 TiB
  PE Size               4.00 MiB
  Total PE              401151
  Alloc PE / Size       16832 / 65.75 GiB
  Free  PE / Size       384319 / <1.47 TiB
  VG UUID               cY7myf-VyT3-4R1K-fhnD-76rc-vO07-1TIXrA
  [root@localhost dev]# lvextend -L +1.4TiB /dev/mapper/nlas-root
  Rounding size to boundary between physical extents: 1.40 TiB.
  Size of logical volume nlas/root changed from 50.00 GiB (12800 extents) to <1.45 TiB (379802 extents).
  Logical volume nlas/root successfully resized.

4.对root挂载目录在线扩容

[root@localhost dev]# xfs_growfs /dev/mapper/nlas-root
meta-data=/dev/mapper/nlas-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 388917248

5.修改/etc/fstab文件,取消home目录的自动挂载,防止重启系统是出问题

[root@localhost dev]# vi /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Apr 27 02:01:40 2021
#
# 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/nlas-root   /                       xfs     defaults        0 0
UUID=b3ee82c5-00f1-45f6-a57b-ddcde013473f /boot                   xfs     defaults        0 0
#/dev/mapper/nlas-home   /home                   xfs     defaults        0 0
/dev/mapper/nlas-swap   swap                    swap    defaults        0 0

运维工程师QQ在线交流群:580175957