Chinaunix首页 | 论坛 | 博客
  • 博客访问: 677182
  • 博文数量: 94
  • 博客积分: 3369
  • 博客等级: 中校
  • 技术积分: 1144
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
文章分类

全部博文(94)

文章存档

2014年(1)

2013年(1)

2012年(65)

2011年(20)

2009年(7)

我的朋友

分类: LINUX

2012-03-28 15:34:42

The problem with this is that there are four distinct units that you must be keeping in mind. To make things even worse, two of these units bear the same name. These are the different units:

1. Hardware block size, "sector size"
2. Filesystem block size, "block size"
3. Kernel buffer cache block size, "block size"
4. Partition table block size, "cylinder size"

To differentiate between the filesystem block size and the buffer cache block size, I will follow FAT terminology and use "cluster size" for the filesystem block size.

The sector size is the units that the hardware deals with. This ranges between different hardware types, but most PC-style hardware (floppies, IDE disks, etc.) use 512 byte sectors.

The cluster size is the allocation unit that the filesystem uses, and is what causes fragmentation - I'm sure you know about that. On a moderately sized ext3 filesystem, this is usually 4096 bytes, but you can check that with dumpe2fs. Remember that these are also usually called "blocks", only that I refer to them as clusters here.
The cluster size is what gets returned in st_blksize in the stat buffer, in order for programs to be able to calculate the actual disk usage of a file.

The block size is the size of the buffers that the kernel uses internally when it caches sectors that have been read from storage device (hence the name "block device"). Since this is the most primitive form of storage in the kernel, all filesystem cluster sizes must be multiples of this. This block size is also what is almost always referred to by userspace programs. For example, when you run "du" without the -h or -H options, it will return how many of these blocks a file takes up. df will also report sizes in these blocks, the "Blocks" column in the fdisk -l output is of this type, and so on. It is what is most commonly referred to as a "block". Two disk sectors fit into each block.

The cylinder size is only used in the partition table and by the BIOS (and the BIOS isn't used by Linux).

"df" only operates on filesystems, so, no, it can't be used without a filesystem - without a filesystem, the data that it would return doesn't exist. "du" operates on individual files.
阅读(494) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

oniziga2012-03-28 15:37:07

回头再看看文件系统的block size的相关描述