There are plenty of commands to choose from when you want to know how hard your disks are working or identify potential slowdowns. Credit: pirke / Shutterstock Ever wonder how hard your disks are working? If so, you’re in luck. Linux provides quite a few useful commands for gauging disk activity. This post examines five options that are all very useful and easy to use. This handy suite of commands will help you to see how busy your disks are, not just how full. Two of the commands (iostat and ioping) may have to be added to your system. The iotop command requires that you use sudo privileges. dstat iostat iotop ioping atop dstat All five commands provide useful ways to view disk activity. Probably one of the easiest and most obvious of these commands is dstat. In spite of the fact that the dstat command begins with the letter “d”, it provides stats on a lot more than just disk activity. This includes CPU stats. If you use the command without specifying options, the command displays the data in the format shown below. $ dstatYou did not select any stats, using -cdngy by default.----total-usage---- -dsk/total- -net/total- ---paging-- ---system--usr sys idl wai stl| read writ| recv send| in out | int csw 1 0 99 0 0| 0 0 | 54B 658B| 0 0 | 116 168 1 0 99 0 0| 0 36k| 54B 338B| 0 0 | 88 138 0 0 99 0 0| 0 0 |7501B 354B| 0 0 | 62 113 1 1 97 2 0| 0 1416k| 54B 354B| 0 0 | 159 233 0 0 99 0 0| 0 0 | 157B 370B| 0 0 | 99 134 0 0 99 0 0| 0 0 | 54B 354B| 0 0 | 78 113 1 0 99 0 0| 0 0 | 16k 424B| 0 0 | 107 145 0 0 100 0 0| 0 0 | 500B 354B| 0 0 | 70 123 1 0 99 0 0| 0 0 | 54B 354B| 0 0 | 81 127 0 0 99 0 0| 0 0 | 54B 354B| 0 0 | 84 128 0 0 99 0 0| 0 272k| 54B 354B| 0 0 | 93 147 0 1 98 0 0| 0 124k| 54B 354B| 0 0 | 243 387 ^C Note that the command output displays user, system and idle time along with other stats like disk read and write activity, interrupts and context switches. The following command displays the top processes related to memory and CPU usage. $ dstat --top-mem --top-cpu--most-expensive-- -most-expensive- memory process | cpu processgnome-softwa 511|gnome-softwa 511|btrfs-transa 0.5gnome-softwa 511|pmdaproc 1.0gnome-softwa 511|python3 1.5gnome-softwa 511|kworker/u4:0 1.5 If you want to view just disk activity, you can use the -d option. As shown below, you’ll get a continuous list of disk read/write measurements until you stop the display with a ^c. Note that after the first report, each subsequent row in the display will report disk activity in the following time interval, and the default is only one second. $ dstat -d-dsk/total- read writ 949B 73k 65k 0 Including a number after the -d option will set the interval to that number of seconds. $ dstat -d 10-dsk/total- read writ 949B 73k 65k 81M Notice that the reported data may be shown in a number of different units — e.g., M (megabytes), k (kilobytes), and B (bytes). The dstat command provides valuable insights into overall Linux system performance, pretty much replacing a collection of older tools, such as vmstat, netstat, iostat, and ifstat, with a flexible and powerful command that combines their features. iostat The iostat command helps monitor system input/output device loading by observing the time the devices are active in relation to their average transfer rates. It’s sometimes used to evaluate the balance of activity between disks. $ iostatLinux 6.8.9-100.fc38.x86_64 (fedora) 11/05/2024 _x86_64_ (2 CPU)avg-cpu: %user %nice %system %iowait %steal %idle 2.42 0.19 1.44 0.44 0.00 95.52Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscdloop0 0.11 0.24 0.00 0.00 771 0 0loop1 0.01 0.02 0.00 0.00 63 0 0sda 25.13 685.20 175.07 102.58 2194224 560621 328480zram0 3.98 0.94 15.27 0.00 3000 48900 0 Of course, all the stats provided on Linux loop devices can clutter the display when you want to focus solely on your disks. The command, however, does provide the -p option, which allows you to just look at your disks — as shown in the commands below. $ iostat -p sdaLinux 6.8.9-100.fc38.x86_64 (fedora) 11/05/2024 _x86_64_ (2 CPU)avg-cpu: %user %nice %system %iowait %steal %idle 2.21 0.17 1.35 0.41 0.00 95.86Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscdsda 27.40 618.74 162.08 1297.02 2194423 574849 4600040sda1 0.05 1.70 0.00 167.39 6022 1 593676sda2 0.05 1.26 0.04 192.96 4469 152 684352sda3 27.27 615.38 162.04 936.67 2182528 574696 3322012 Note that tps refers to transfers per second. You can also get iostat to provide repeated reports. In the example below, we’re getting measurements every five seconds by using the -d option. $ iostat -p sda -d 5Linux 6.8.9-100.fc38.x86_64 (fedora) 11/05/2024 _x86_64_ (2 CPU)Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscdsda 25.96 583.46 155.50 1226.91 2194631 584897 4614944sda1 0.05 1.60 0.00 157.83 6022 1 593676sda2 0.05 1.19 0.04 181.94 4469 152 684352sda3 25.84 580.29 155.46 887.14 2182736 584744 3336916Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscdsda 0.00 0.00 0.00 0.00 0 0 0sda1 0.00 0.00 0.00 0.00 0 0 0sda2 0.00 0.00 0.00 0.00 0 0 0sda3 0.00 0.00 0.00 0.00 0 0 0 If you prefer to omit the first (stats since boot) report, add a -y to your command. $ iostat -p sda -d 5 -yLinux 6.8.9-100.fc38.x86_64 (fedora) 11/05/2024 _x86_64_ (2 CPU)Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscdsda 4.40 0.00 56.00 0.00 0 280 0sda1 0.00 0.00 0.00 0.00 0 0 0sda2 0.00 0.00 0.00 0.00 0 0 0sda3 4.40 0.00 56.00 0.00 0 280 0Device tps kB_read/s kB_wrtn/s kB_dscd/s kB_read kB_wrtn kB_dscdsda 0.00 0.00 0.00 0.00 0 0 0sda1 0.00 0.00 0.00 0.00 0 0 0sda2 0.00 0.00 0.00 0.00 0 0 0sda3 0.00 0.00 0.00 0.00 0 0 0 [ Learn more Linux commands for managing, partitioning, and troubleshooting ] iotop The iotop command is a top-like utility for looking at disk I/O. It gathers I/O usage information provided by the Linux kernel so that you can get an idea which processes are most demanding in terms of disk I/O. In the example below, the loop time has been set to 5 seconds. The display will update itself periodically, overwriting the previous output. $ sudo iotop -d 5Total DISK READ: 0.00 B/s | Total DISK WRITE: 133.87 K/sCurrent DISK READ: 0.00 B/s | Current DISK WRITE: 390.97 K/s TID PRIO USER DISK READ DISK WRITE> COMMAND 406 be/4 root 0.00 B/s 133.87 K/s [btrfs-transaction] 1 be/4 root 0.00 B/s 0.00 B/s systemd --switched-root –system --deserialize=35 rhgb 2 be/4 root 0.00 B/s 0.00 B/s [kthreadd] 3 be/4 root 0.00 B/s 0.00 B/s [pool_workqueue_release] 4 be/0 root 0.00 B/s 0.00 B/s [kworker/R-rcu_g] 5 be/0 root 0.00 B/s 0.00 B/s [kworker/R-rcu_p] 6 be/0 root 0.00 B/s 0.00 B/s [kworker/R-slub_] 7 be/0 root 0.00 B/s 0.00 B/s [kworker/R-netns] 9 be/0 root 0.00 B/s 0.00 B/s [kworker/0:0H-events_highpri] 12 be/0 root 0.00 B/s 0.00 B/s [kworker/R-mm_pe] 14 be/4 root 0.00 B/s 0.00 B/s [rcu_tasks_kthread] 15 be/4 root 0.00 B/s 0.00 B/s [rcu_tasks_rude_kthread] [ Related: Learn how to stress test your Linux system ] ioping The ioping command is an altogether different type of tool, but it can report disk latency — how long it takes a disk to respond to requests — and can be helpful in diagnosing disk problems. $ sudo ioping /dev/sda14 KiB <<< /dev/sda1 (block device 600 MiB): request=1 time=277.2 us (warmup)4 KiB <<< /dev/sda1 (block device 600 MiB): request=2 time=477.3 us4 KiB <<< /dev/sda1 (block device 600 MiB): request=3 time=472.3 us4 KiB <<< /dev/sda1 (block device 600 MiB): request=4 time=454.8 us atop The atop command, like top, provides a vast assortment of information on system performance, including some stats on disk activity and the amount of load on the system’s resources at the process level. If you want to look at just the disk stats, you can easily manage that with a command like this: $ atop | grep DSKDSK | sda | busy 1% | read 55761 | write 31218 | avio 0.68 ms |DSK | sda | busy 0% | read 0 | write 12 | avio 1.83 ms |DSK | sda | busy 0% | read 0 | write 33 | avio 0.73 ms | To view stats on memory usage, run a command like this one: $ atop | grep MEMMEM | tot 3.7G | free 782.1M | cache 1.8G | buff 1.8M | slab 188.7M |MEM | numnode 1 | shmem 134.5M | shrss 0.0M | tcpsk 0.0M | udpsk 0.0M |MEM | tot 3.7G | free 780.4M | cache 1.8G | buff 1.8M | slab 188.7M |MEM | numnode 1 | shmem 134.5M | shrss 0.0M | tcpsk 0.0M | udpsk 0.0M | Wrap-up Linux provides enough commands to give you good insights into how hard your disks are working and help you focus on potential problems or slowdowns. Hopefully, one of these commands will tell you just what you need to know when it’s time to question disk performance. Occasional use of these commands will help ensure that especially busy or slow disks will be obvious when you need to check them. SUBSCRIBE TO OUR NEWSLETTER From our editors straight to your inbox Get started by entering your email address below. Please enter a valid email address Subscribe