在man du命令给出的命令详解是这样的,有两个选项,一个是
--apparent-size
print apparent sizes, rather than disk usage; although theapparent size is usually smaller, it may be larger due to holes
in (`sparse') files, internal fragmentation, indirect blocks,
and the like
-S, --separate-dirs
do not include size of subdirectories
-s, --summarize
display only a total for each argument
-a, --all
write counts for all files, not just directories
即-s命令是显示整个磁盘使用情况,或者为一个目录中的所有文件 显示总的磁盘使用情况。将该标志与-a标志进行对比。
-a显示文件,递归的显示目录下所有的文件。-s只显示本目录下的文件大小和文件夹的总大小。
而默认du显示的disk usage,即占用的blocksize,blocksize可以是1k也可以是4k,不能整除的上取整,就是就算占用半个block也会算作一个大小。
apparent size是实际大小,有的文件中有空洞,空洞不占用磁盘block,但是有大小,即holes,内部碎片fragmentation和indirect blocks不知道是什么情况,找了两张图片放在下面
External and Internal Fragmentation
External fragmentation is the phenomenon in which free storage becomes divided into many small pieces over time. It occurs when an application allocates and deallocates regions of storage of varying sizes, and the allocation algorithm responds by leaving the allocated and deallocated regions interspersed. The result is that although free storage is available, it is effectively unusable because it is divided into pieces that are too small to satisfy the demands of the application.
Internal fragmentation is the space wasted inside of allocated memory blocks because of restriction on the allowed sizes of allocated blocks.
这是国外一个论坛的帖子给出的一个解释'--apparent-size'
Print apparent sizes, rather than disk usage. The apparent size of a file is the number of bytes reported bywc -c
on regular files, or more generally,ls -l --block-size=1
orstat --format=%s
. For example, a file containing the word 'zoo' with no newline would, of course, have an apparent size of 3. Such a small file may require anywhere from 0 to 16 KiB or more of disk space, depending on the type and configuration of the file system on which the file resides. However, a sparse file created with this command:dd bs=1 seek=2GiB if=/dev/null of=big
has an apparent size of 2 GiB, yet on most modern systems, it actually uses almost no disk space.