当前位置:   article > 正文

关于linux文件Blocks和Block size的一些解析_blocks block_size

blocks block_size


File system block sizes

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;


声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/343346
推荐阅读
相关标签
  

闽ICP备14008679号