[Linux]解决/usr满了,安装不了软件的问题

1.在安装java环境的时候报错,/usr文件系统空间不够。

2.查看df -h,发现/usr已经99%了,但是/home只有1%

[root@training usr]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 484M     0  484M   0% /dev
tmpfs                    496M     0  496M   0% /dev/shm
tmpfs                    496M  6.8M  489M   2% /run
tmpfs                    496M     0  496M   0% /sys/fs/cgroup
/dev/mapper/centos-root  5.0G  209M  4.8G   5% /
/dev/mapper/centos-usr   4.0G  4.0G   67M  99% /usr
/dev/mapper/centos-home  5.0G   33M  5.0G   1% /home
/dev/mapper/centos-tmp   5.0G   33M  5.0G   1% /tmp
/dev/mapper/centos-var   5.0G  950M  4.1G  19% /var
/dev/sda1                485M  108M  353M  24% /boot
tmpfs                    100M     0  100M   0% /run/user/0

3.将/home 打成tar 包保存起来

[root@training /]# tar -cvf root/tmp/home.tar home/

4.卸载 home

[root@training /]# umount /home

5.删除home所在的lv

[root@training /]# lvremove /dev/centos/home 
Do you really want to remove active logical volume centos/home? [y/n]: y
  Logical volume "home" successfully removed

6.扩展/usr所在的lv,增加1.5G

[root@training /]# lvextend -L +1.5G /dev/mapper/centos-usr
  Size of logical volume centos/usr changed from 4.00 GiB (1024 extents) to 5.50 GiB (1408 extents).
  Logical volume centos/usr successfully resized.

7.扩展/usr文件系统

[root@training /]# xfs_growfs /dev/mapper/centos-usr 
meta-data=/dev/mapper/centos-usr isize=512    agcount=4, agsize=262144 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=1048576, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1048576 to 1441792
[root@training /]# df
Filesystem              1K-blocks    Used Available Use% Mounted on
devtmpfs                   495176       0    495176   0% /dev
tmpfs                      507380       0    507380   0% /dev/shm
tmpfs                      507380    6992    500388   2% /run
tmpfs                      507380       0    507380   0% /sys/fs/cgroup
/dev/mapper/centos-root   5232640  338228   4894412   7% /
/dev/mapper/centos-usr    5756928 4115672   1641256  72% /usr
/dev/mapper/centos-var    5232640  983104   4249536  19% /var
/dev/mapper/centos-tmp    5232640   33180   5199460   1% /tmp
/dev/sda1                  495844  109569    360675  24% /boot
tmpfs                      101480       0    101480   0% /run/user/0

8.重新创建home lv

[root@training /]# lvcreate -L 3.5G -n home centos
  Logical volume "home" created.

9.创建文件系统

[root@training /]# mkfs.xfs /dev/centos/home 
meta-data=/dev/centos/home       isize=512    agcount=4, agsize=229376 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=917504, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

10.挂载/home

[root@training /]# mount /dev/centos/home

11.查看磁盘情况,/usr增加了1.5G

[root@training /]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 484M     0  484M   0% /dev
tmpfs                    496M     0  496M   0% /dev/shm
tmpfs                    496M  6.9M  489M   2% /run
tmpfs                    496M     0  496M   0% /sys/fs/cgroup
/dev/mapper/centos-root  5.0G  331M  4.7G   7% /
/dev/mapper/centos-usr   5.5G  4.0G  1.6G  72% /usr
/dev/mapper/centos-var   5.0G  961M  4.1G  19% /var
/dev/mapper/centos-tmp   5.0G   33M  5.0G   1% /tmp
/dev/sda1                485M  108M  353M  24% /boot
tmpfs                    100M     0  100M   0% /run/user/0
/dev/mapper/centos-home  3.5G   33M  3.5G   1% /home

12.将/tmp/home.tar 解压

[root@training /]# tar -xvf root/tmp/home.tar

 

posted @ 2020-09-24 09:30  gracexu  阅读(2188)  评论(0编辑  收藏  举报