← 返回命令列表

Linux command

blktrace 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Trace block I/O

blktrace -d [/dev/sda]

Trace with output to specific directory

blktrace -d [/dev/sda] -D [/tmp/traces]

Trace multiple devices

blktrace -d [/dev/sda] -d [/dev/sdb]

Trace for a specific duration

blktrace -d [/dev/sda] -w [10]

Trace and pipe to blkparse

blktrace -d [/dev/sda] -o - | blkparse -i -

Trace with specific buffer size

blktrace -d [/dev/sda] -b [1024]

Stop tracing

killall blktrace

说明

blktrace is a Linux block layer I/O tracing utility that captures detailed information about block device operations. It tracks requests from submission through the I/O scheduler to completion, providing visibility into storage subsystem behavior. The traces include information like queue insertions, merges, dispatch to driver, and completion events. Each event contains timestamp, process ID, action code, and I/O parameters (sector, size, flags). blktrace produces binary trace files that are analyzed with blkparse, btt, or other tools. It's invaluable for diagnosing I/O performance issues, understanding workload patterns, and tuning storage configurations.

参数

-d _device_
Device to trace (can specify multiple).
-o _file_
Output file base name.
-D _dir_
Directory for output files.
-w _seconds_
Trace duration in seconds.
-b _size_
Per-CPU buffer size in KB.
-n _num_
Number of per-CPU buffers.
-a _action_
Trace only specific actions.
-A _mask_
Set action mask.
-r _relay_
Use specific debugfs relay path.
-I _devs_
Add multiple devices from file.
-h
Display help.
-V
Display version.

FAQ

What is the blktrace command used for?

blktrace is a Linux block layer I/O tracing utility that captures detailed information about block device operations. It tracks requests from submission through the I/O scheduler to completion, providing visibility into storage subsystem behavior. The traces include information like queue insertions, merges, dispatch to driver, and completion events. Each event contains timestamp, process ID, action code, and I/O parameters (sector, size, flags). blktrace produces binary trace files that are analyzed with blkparse, btt, or other tools. It's invaluable for diagnosing I/O performance issues, understanding workload patterns, and tuning storage configurations.

How do I run a basic blktrace example?

Run `blktrace -d [/dev/sda]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -d _device_ do in blktrace?

Device to trace (can specify multiple).