跳转到主内容

为什么Linux命令"df"和"du"的结果不同?

Views:
23
Visibility:
Public
Votes:
0
Category:
ontap-9
Specialty:
nas
Last Updated:

适用场景

  • ONTAP 9
  • NFS
  • 三项功能

问题解答

  • du 遍历目标并计算每个对象的空间使用量
  • 目标可以是目录、子目录、文件或整个文件系统
  • df 查询文件系统中的当前空间使用量
  • 存储系统启用了卷效率

示例:

[root@user1]# df -Ph | grep DB
192.xxx.xxx.xxx:/vol1    12T  784G  12T   7% /DB

[root@user1]# du -sh /DB/
2.7T  /DB

DF
/vol/vol1/    12884901888  847244892 12037656996     7%  /vol/vol1/
/vol/vol1/.snapshot      0      0      0     0%  /vol/vol1.snapshot

DF -S
Filesystem         used     total-saved   %total-saved   deduplicated   %deduplicated   compressed   %compressed   vbn zero   %vbn zero
/vol/vol1/     847244892     2560004340       75%    1515678176        44%   1044326164       31%   726488260      21%

追加信息

例如:

当我们复制大于可用空间的文件时、文件系统最初可能允许使用稀疏文件技术或过度配置来继续复制。但是,一旦实际物理空间耗尽,复制操作将失败。尽管如此、文件系统可能仍会报告文件的逻辑大小、其中包括稀疏区域、因此看起来存储的数据比物理容量更多。

  1. 复制操作:开始将一个7 GB的文件复制到2 GB的磁盘。
  2. 稀疏文件处理:文件系统写入非零数据块并跳过零块,最初允许复制继续。
  3. 故障点:实际2 GB物理空间用尽后,复制操作将失败。
  4. 磁盘使用情况报告: du -sh 显示文件的逻辑大小,包括可能超过物理容量的稀疏区域。 df 显示实际使用的物理空间,仍为2 GB。
  • du -sh:此命令显示文件和目录的实际磁盘使用量。它包括稀疏文件所使用的空间、就好像它们已完全分配一样、这可能会使空间使用量看起来比实际可用空间要多。
  • df:此命令显示文件系统上的可用磁盘空间和已用磁盘空间。它会报告实际已用物理空间、  如果存在稀疏文件、则该空间可能小于DU报告的空间。
NetApp provides no representations or warranties regarding the accuracy or reliability or serviceability of any information or recommendations provided in this publication or with respect to any results that may be obtained by the use of the information or observance of any recommendations provided herein. The information in this document is distributed AS IS and the use of this information or the implementation of any recommendations or techniques herein is a customer's responsibility and depends on the customer's ability to evaluate and integrate them into the customer's operational environment. This document and the information contained herein may be used solely in connection with the NetApp products discussed in this document.