Table of Contents

Block Layer I/O Tracing

Tools

Install blktrace on Debian based systems:

root@host:~# apt-get install blktrace

Ensure that the virtual filesystem Debug-FS is mounted:

root@host:~# mount | grep debugfs

Mount the Debug-FS if it's currently not available:

root@host:~# /etc/init.d/mountdebugfs start

or:

root@host:~# mount -t debugfs debugfs /sys/kernel/debug

Start the recording of the block I/O on a device until CTRL+Ctrl is pressed. In this example the block device /dev/sda:

root@host:~# blktrace /dev/sda
^C
=== sda ===
  CPU  0:                 8674 events,      407 KiB data
  CPU  1:                 9747 events,      457 KiB data
  CPU  2:                  631 events,       30 KiB data
  CPU  3:                 8977 events,      421 KiB data
  Total:                 28029 events (dropped 0),     1314 KiB data

This creates the output files sda.blktrace.<CPU-#> in the current working directory. The output files can be analysed with the command:

root@host:~# blkparse -i sda.blktrace.<CPU-#>

See man blkparse for a description of the output format.

Recording and analysis of the block I/O on a device can be pipelined:

root@host:~# blktrace /dev/sda -o - | blkparse -i -

or the shorthand command:

root@host:~# btrace /dev/sda

be used.

To record and replay the block I/O on a device the commands btrecord and btreplay can be used. This can be especially useful to compare different environments or settings with the exact same block I/O load.

The tool btt perfoms an analysis on the output files written by the blktrace command:

root@host:~# btt -i sda.blktrace.0

See man btt for the available options.

The tool blkiomon can be used to perfom an iostat-like analysis on the output generated by the blktrace command. For example to generate an 1 hour long trace of the device /dev/sda and output the statistics in a human-readable format in 10 second intervals:

root@host:~# blktrace /dev/sda -w 3600 -o - | blkiomon -I 10 -h -

See man blkiomon for the available options.

For visualization purposes there are the tools bno_plot and iowatcher available.

Linux Magazine - Issue 03/2019 - Plattenzugriffe bis aufs letzte Bit nachvollziehen