Linux to find lost disk space

  
                

The Linux system disk prompt is full, but the size of the files in the disk is inconsistent with the size of the occupied files. This is the case of disk loss. So what program is taking up disk space? The following small series will introduce you to Linux to retrieve lost disk space. Users

linux frequent contact may often encounter this problem:

Disk receive a warning, saying that such and such a partition is full, then log server df a look, Found that the disk is really full, and then you want to find out which directory is full, so du -s * a look, but found that the total size of all subdirectories and df shows the total used disk space is not right, there are Sometimes even a lot of difference, so I wondered: Where is my disk space?

Here are three cases:

hidden files

The Linux system takes the file name. The file at the beginning of the (dot) is treated as a hidden file, and operators like bash do not match hidden files, so if there is a large hidden file in the root directory, it will not be du-sh. * Statistics, the solution is: du -sh. [^.]*.

Non-empty directories are mounted

When mounting other partitions, it is recommended to mount to an empty directory. What happens if you mount to a non-empty directory? For example, the /mnt directory originally has files, and then executed sudo mount /dev/sda6 /mnt. In fact, this mount command can be executed normally, and the partition that is mounted can also be accessed normally. Only the files in /mnt are not accessible now, including du, but the disk space is still occupied. Because if you umount /mnt later, the original file will come back.

Empty file

The size of a file and the disk space may not be exactly the same. For example, a program always opens a file called log, while someone in the middle uses "log" The command clears the contents of the log and produces such a file.

The above is a description of the way Linux retrieves lost disk space. The main reason is that the three situations in the text take up disk space, and the disk space is full to clean up from these aspects.

Copyright © Windows knowledge All Rights Reserved