root@host:/var/log/apache2# du access.log -bh
753M access.log
root@host:/var/log/apache2# du access.log -h
1.2G access.log
为什么同一个文件,大小会有这么大的差异?
答案1
就这样。来自精确的 Ubuntu 管理:
--apparent-size
print apparent sizes, rather than disk usage; although the
apparent size is usually smaller, it may be larger due to holes
in (`sparse') files, internal fragmentation, indirect blocks,
and the like
-B, --block-size=SIZE
scale sizes by SIZE before printing them. E.g., `-BM' prints
sizes in units of 1,048,576 bytes. See SIZE format below.
-b, --bytes
equivalent to `--apparent-size --block-size=1'
因此,您不仅可以在第一侧计算 MiB/GiB,还可以计算“稀疏文件“ 在你面前。
(我在这里假设您使用的是 coreutildu
而不是 POSIX)