赞
踩
On the other hand, every file system needs to split up a partition into blocks to store files and file parts. This is why there is a different block size for a file system as you can see here:
tweedleburg:/mnt/sdb2 # stat -f . File: "." ID: 236d62321492c2ce Namelen: 255 Type: ext2/ext3 Block size: 4096 Fundamental block size: 4096 Blocks: Total: 76899893 Free: 8380419 Available: 4474114 Inodes: Total: 39075840 Free: 38013010
So, if you store a file in this file system, it will be stored in a 4096-byte-block, that means, even if your file only contains 5 bytes, it will take away 4096 bytes from your disk's capacity:
tweedleburg:/mnt/sdb2 # df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdb2 307599572 274077896 17896456 94% /mnt/sdb2 tweedleburg:/mnt/sdb2 # echo hallo>welt tweedleburg:/mnt/sdb2 # df . Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdb2 307599572 274077900 17896452 94% /mnt/sdb2 tweedleburg:/mnt/sdb2 # du -csh welt 4.0K welt 4.0K total
摘自:http://wiki.linuxquestions.org/wiki/Block_devices_and_block_sizes
小结:
1. stat命令输出的Blocks单位通常是512bytes,也就是一个扇区。
2. 一个文件假设只有几个字节,其实也会占用一个文件块(Block size)大小,通常是4096bytes。
3. 系统通常一次会读取一个Block size大小,而不是一个扇区大小。
原文出自:http://blog.csdn.net/daiyudong2020/article/details/53897775
End;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。