The Linux root directory is full

 

1. Run the df -h command to check whether the remaining space of the/root directory is 0. The total system disk capacity is only 20 GB.

 

File system capacity used Available Used % Mount point

/dev/mapper/centos-root    20G   20G  20k   100% /

Devtmpfs 7.1g 0 7.1g 0% /dev

TMPFS 7.7g 168K 7.7g 1% /dev/shm

TMPFS 7.1g 1.4m 7.1g 1% /run

TMPFS 7.7g 0 7.7g 0% /sys/fs/cgroup

/dev/sdb1                  1.8T 1.4T  398G   78% /u01

/dev/sda1                  494M  208M 287M   42% /boot

TMPFS 1.6g 8.0k 1.6g 1% /run/user/42

TMPFS 1.6g 0 1.6g 0% /run/user/1001

TMPFS 1.2g 0 1.2g 0% /run/user/1007

TMPFS 1.6g 28K 1.6g 1% /run/user/0

TMPFS 1.2g 0 1.2g 0% /run/user/1006

TMPFS 1.6g 0 1.6g 0% /run/user/1012

/dev/mapper/centos-home  200G 1.4G  199G    1% /home

 

Du -h-x –max-depth=1 Check the directory that occupies too much space. Delete the content in the directory that occupies too much space

0       ./proc

132K         ./root

2.2 G/usr

12K  ./mnt

16K  ./lost+found

4.0 k. / media

4.0 k. / SRV

27M ./lib64

763M        ./var

16.6 G/opt

317M        ./lib

2.0 k. / boot

0       ./sys

0       ./net

56M ./tmp

33M ./etc

0       ./selinux

0       ./misc

7.7 m. / bin

64K  ./home

17M ./sbin

0       ./dev

20G  .

 

The opt directory occupies too much space. You can clear some files in opt to release some space.

 

CentOS 7 Adjust the home partition to expand the root partition

Overall process:

Back up the /home content, delete the logical volume where the /home file system resides, expand the /root file system, create /home, and restore the /home content

 

1. View partitions

df -h

2. Back up the home partition file

tar cvf /tmp/home.tar/home

3. Uninstall /home. If the uninstallation fails, stop the process that uses the /home file system

 

fuser -km /home/

umount /home

4. Delete the LV where /home resides

lvremove/dev/mapper/centos-home

5. Expand the LV where /root resides by 800 GB

lvextend -L +800G/dev/mapper/centos-root

6. Expand the /root file system

xfs_growfs/dev/mapper/centos-root

7. Recreate the Home LV

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

8. Create a file system

mkfs.xfs  /dev/mapper/centos-home

9. Mount the home

mount/dev/mapper/centos-home

10. Restore the home file

tar xvf /tmp/home.tar -C/home/

cd /home/home/

mv * .. /