Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Differences between df and du commands

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Under normal circumstances, there is a gap between df and du output.

The du-sh command accumulates the number of blocks used by all directories, symbolic links, and files in a specified file system

Total number of blocks

The df command obtains the total number of blocks and the number of remaining blocks by looking at the disk block allocation map of the file system.

The file system allocates some of these blocks to record some of its own data, such as I nodes, disk distribution maps, indirect blocks, super blocks, etc.

. This data is invisible to most user-level programs, often referred to as Meta Data.

The du command is a user-level program that does not consider Meta Data, while the df command looks at the disk allocation diagram of the file system and considers Meta Data

.

Therefore, under normal circumstances, the USED space calculated by df is slightly larger than that calculated by du.

2. In abnormal cases, the USED space calculated by df is much larger than that of du.

This is also the problem encountered before, df check the results of the file system is 100% used, and the result of du is still 6GB free, such a problem hardware manufacturer a SUPPORT unexpectedly do not know how to explain, this also makes me curious to come back at night to check the reason, as a result GOOGLE has.

The reason is that du calculates space usage based on file and directory names, while df calculates space usage based on hard disk block usage.

When an application is writing a large file, we RM or MV the file (UNIX is allowed to do this, and WINDOWS is foolish at this point), and the application will occupy the handle and write directly to disk based on the location of the disk indicated by the handle without checking whether the file has been deleted.

Therefore, the above problems will arise. Specific to the Oracle level, this may happen: Oracle is generating a large TRACE file for some reason, which may cause directories such as oracle to be full. If you directly RM or MV the TRACE file at this time, you will find that the space will not be released, which may lead to the Oracle database down machine.

Solution: use the "> tracefile.trc" command to clear the file. If you need to keep the TRACE file to analyze the problem afterwards, you can use CP to copy the file to another place, and then empty the original file.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report