当前位置: 首页 > 工具软件 > OSChina Block > 使用案例 >

linux系统的blocksize

邓高韵
2023-12-01

linux 中有以下几种blocksize:

1.     硬件上的 block size, 应该是"sector size",扇区大小

可以通过 fdisk查看:

fdisk -l

Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000d7d2b

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    20971519    10484736   83  Linux
/dev/vda2        20971520   209715199    94371840   83  Linux


2.     有文件系统的分区的block size, 是"block size",大小不一,可以用工具查看

比如:ext4文件系统,可以通过命令tune2fs -l 查看 blocksize:

sudo tune2fs -l /dev/vda2| grep Block
Block count:              23592960
Block size:               4096
Blocks per group:         32768

xfs文件系统,可以通过命令xfs_info 查看 blocksize

xfs_info /dev/vda1
meta-data=/dev/vda1              isize=256    agcount=4, agsize=655296 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=2621184, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


3.     Kernel buffer cache 的block size, 就是"block size":

The block size is the size of the buffers that the kernel uses internally when it caches sectors that have been read from storage devices (hence the name "block device"). Since this is the mostprimitive form of storage in the kernel, all filesystem cluster sizesmust be multiples of this. This block size is also what is almostalways referred to by userspace programs. For example, when you run"du" without the -h or -H options, it will return how many of theseblocks 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. Itis what is most commonly referred to as a "block". Two disk sectors fitinto each block.

命令du 显示的就是 block数:

[XXX@yfslcentos71 test]$ ll
-rwxrwxr-x  1 wangxiumin wangxiumin    15323 Aug 19 20:00 r
[XXX@yfslcentos71 test]$ du r
16	r
[XXX@yfslcentos71 test]$ du -h r
16K	r


4.     磁盘分区的"cylinder size"。

转载于:https://my.oschina.net/ashnah/blog/1930428

 类似资料: