LINUX,DU, DF Statistical disk condition inconsistent

Source: Internet
Author: User

Reprint: http://blog.linezing.com/?p=2136

When you run a Linux server, you encounter situations where you need to see hard disk space, and you typically use the DF-LH command to check the total and usage of each hard disk that is mounted on the file system, or you can use the Du-sh [directory] command to count the footprint of all files in a directory.

When you use the DF, du command, you often encounter problems with inconsistent usage of the hard disk. For example, the total file size of the DU statistics root is 2G, while DF determines that the hard disk mounted in the root directory has used space to reach 3g,20g or more. This happens for the following three reasons:

1. Reserved space

In order to prevent emergencies, the Linux ext file system reserves some hard disk space, the specific reserved values can be through tune2fs-l [Dev_name] | grep "Reserved block Count" sees (Dev_name is the device name), where the reserved space is computed by DF into the used space, resulting in inconsistent df and du statistics. If you need to adjust the amount of headroom, we can use tune2fs-m [size] [dev_name] to adjust.

2. Phantom files (phantom file)

Du is the size of each file that is recorded by the file system, and then the cumulative size that is obtained by the file system. DF is mainly read from the Super Block (Superblock) in the use of hard disk information, DF obtained is the case of disk block is used. When a file is deleted, if another process is using it (possession handle), the file will not be counted by DU, but the disk space occupied by this file will still be counted by DF. These files, as well as the processes that are using these files, can be lsof | grep deleted found. When the process stops or is killed, the space is freed.

3. Documents not counted

If the above two cases are excluded, but the data is inconsistent, what is it? There is a situation here: when we hang a directory on a new device (hard disk) before, if there is already data in this directory, then this part of the data will not be aware of DU, the file system can not see the data, but the data is actually occupied disk space, can be counted by DF. At this time by DU/DF statistics of the original equipment space use, you will find that DF statistics more than DU. When you encounter such a situation, use fuser-km [directory] to kill all processes that occupy that directory (be careful!) ), and then use Umount [directory] To uninstall the device that is attached to the directory, at which point the original data in the directory appears, and we remove it and then reinstall the device (mount-t [type] [dev] [directory]).

LINUX,DU, DF Statistical disk condition inconsistent

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.