性能监控的时候使用vmstat
,查看 man
bo: Blocks sent to a block device (blocks/s).
下图是分别运行vmstat 1
和iostat 1
截图
盲猜 block 大小为 1KB,
但是通过fdisk -l
root@debian:~# fdisk -l
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5e118ce6
看到I/O size (minimum/optimal): 512 bytes / 512 bytes
执行dumpe2fs -h /dev/sda1
root@debian:~# dumpe2fs -h /dev/sda1
dumpe2fs 1.44.5 (15-Dec-2018)
Filesystem volume name: <none>
Last mounted on: /
Filesystem UUID: 7305e4f3-57d3-49f9-8348-8416ad736173
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 4964352
Block count: 19847168
Reserved block count: 992358
Free blocks: 15643755
Free inodes: 4807531
First block: 0
Block size: 4096
Fragment size: 4096
Group descriptor size: 64
Reserved GDT blocks: 1024
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Flex block group size: 16
Filesystem created: Tue Sep 24 15:52:12 2019
Last mount time: Wed Jun 24 08:13:34 2020
Last write time: Wed Jun 24 08:13:32 2020
Mount count: 27
Maximum mount count: -1
Last checked: Tue Sep 24 15:52:12 2019
Check interval: 0 (<none>)
Lifetime writes: 282 GB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 32
Desired extra isize: 32
Journal inode: 8
First orphan inode: 4195685
Default directory hash: half_md4
Directory Hash Seed: aaa256b0-0045-4830-aed1-533d6f7f0a28
Journal backup: inode blocks
Checksum type: crc32c
Checksum: 0xba8682f2
Journal features: journal_incompat_revoke journal_64bit journal_checksum_v3
Journal size: 512M
Journal length: 131072
Journal sequence: 0x00c303f9
Journal start: 103755
Journal checksum type: crc32c
Journal checksum: 0x9e666967
看到
Block size: 4096
Reserved GDT blocks: 1024
那么问题来了,block 的大小到底的多少?
1
freenull 2020-06-24 13:42:41 +08:00
我记得一直是 4K
|
2
loading 2020-06-24 13:53:36 +08:00 via Android
我只知道文件系统的 block 是可以指定的。
|
3
nullboy OP 177 次点击 2 回答,呼叫大佬.......
|
4
feather12315 2020-06-24 14:12:58 +08:00 via Android 1
通常 physical block 为 512,
格式化默认的 logic block 为 4K |
5
nullboy OP @feather12315 那为啥 vmstat bi bo 对应的是 1KB 呢?
|
6
feather12315 2020-06-24 14:40:56 +08:00 via Android 1
@nullboy
1. vmstat 存在参数-S 用于指定 block size (这个是可调节的)。同样,du 、dh 也是 2. 磁盘与光盘的最小存储单位是扇区 (sector),操作系统每次 I/O 的首选长度 (block size) 称为块 (block),文件系统上最小的分配单位 (fragment size) 叫做 fragment |
7
linvon 2020-06-24 14:56:14 +08:00 1
磁盘里面的和文件系统里面的两个基本单位都叫 block size,但是实际上是两个东西,一个是硬盘扇区的大小,应该叫做 sector size ;一个是文件系统的 block 的大小。磁盘扇区一般都是 512bytes 。
|
8
vuuv 2020-06-24 23:08:26 +08:00 via Android 1
我记得是 1K 。
刚才 man vmstat 确认了。在 note 章节: ``` All linux blocks are currently 1024 bytes. Old kernels may report blocks as 512 bytes, 2048 bytes, or 4096 bytes. ``` |