Linux df and du command to check out the use of space is different how to do

Source: Internet
Author: User

A user logged on to the Linux system server to view the time, unexpectedly found that DF and du check out the results are not the same, du check out the "actual use of space" is significantly more than DF to check out the use of space is much smaller, this is how is it? Is there some space hidden away? Here's what df and Du commands have found to be different solutions for using space.

  The method is as follows:

First, we use DF to view the used space:

From the figure above, the root partition has been used 5456700KB (contract 5.20GB).

We then use Du to identify the size of each directory under the root partition:

Excluding two directories in the red box (because they are mounted), the total size of all directories is 3075332KB (contract 2.93GB), which is much smaller than DF detected 2.27GB.

  Why is there so much less space?

It's because we deleted some of the files that were being written by the process, and although we've deleted them, as long as the process is still there, that file will not be deleted, but it is temporarily stored somewhere in the system, a bit like a Windows Recycle Bin.

To solve this problem, the simplest is to restart the server, but the production environment generally will not be easy to restart, so we can solve by other means.

First use the lsof command with the grep command to find out what has been deleted, but still occupy the system space "rogue".

The file in the red box above is just a big file I deleted before, and I'm now trying to reboot the program (node) and I kill the process directly because I started it automatically, so I don't have to start it manually.

The use of space has suddenly dropped to 3226324KB (contract 3.08GB), has been very close to the total space du statistics.

Next, I restarted the other deleted files one by one, and eventually DF was about the same size as the du statistic.

In this way, it solves the different documents of DF and Du, and drives away the "rogue" in the system, and returns the space that belongs to us.

DF and Du commands to check out the use of a different space to solve the problem here, as you also have this problem can follow the above steps to operate, so as to solve problems.

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.