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

来源:互联网 发布:人工智能老师 编辑:程序博客网 时间:2024/05/16 11:55


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/ext3Block size: 4096       Fundamental block size: 4096Blocks: Total: 76899893   Free: 8380419    Available: 4474114Inodes: 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/sdb2tweedleburg:/mnt/sdb2 # echo hallo>welttweedleburg:/mnt/sdb2 # df .Filesystem           1K-blocks      Used Available Use% Mounted on/dev/sdb2            307599572 274077900  17896452  94% /mnt/sdb2tweedleburg:/mnt/sdb2 # du -csh welt4.0K    welt4.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;


0 0
原创粉丝点击