How to Trace Disk I/O Activity in Linux with btrace

Quick Linux Tip #73:

Question: Something is thrashing my disks. How do I see block-level filesystem activity live?

Try: sudo btrace /dev/sda

Info: btrace traces block-layer I/O events in real time. It shows low-level read and write activity along with timing, process IDs, and I/O stages, helping you identify which processes are generating disk activity.

Examples:

  • $ sudo blktrace -d /dev/sda -o - | blkparse -i -  # Live block trace pipe
  • $ sudo iotop -o -d 1  # Interactive process-level I/O monitor
  • $ sudo iostat -xz 1  # Live extended device utilization statistics

Note: Install the required tools with sudo apt install blktrace. Block tracing can generate a very large amount of output, so use filters when investigating a busy system. Use iotop for a higher-level view when you mainly need to identify which processes are causing disk I/O.




LinuxTeck.com
linuxteck@ubuntu:~$ sudo btrace /dev/sda
  8,0    3        1   0.000000000  3456  A  WS 12345678 + 8 <- (8,1) 12345000
  8,0    3        2   0.000001245  3456  Q  WS 12345678 + 8 [mysqld]
  8,0    3        3   0.000023456  3456  G  WS 12345678 + 8 [mysqld]
  8,0    3        4   0.000034567  3456  P  N [mysqld]
  8,0    3        5   0.000045678  3456  I  WS 12345678 + 8 [mysqld]
  8,0    3        6   0.000056789     0  D  WS 12345678 + 8 [swapper/0]
  8,0    3        7   0.234567890     0  D  WS 12345678 + 8 [0]
linuxteck@ubuntu:~$

PREVIOUS ARTICLE Quick Linux Tip #72: How to Find Files Changed During a Specific Time in Linux NEXT ARTICLE Quick Linux Tip #74: Compress Old Linux Logs and Keep 30 Days
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.