Using the iostat command to keep track of disk usage on Linux.

Posted: January 19, 2013. At: 11:24 PM. This was 5 years ago. Post ID: 5216
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

This example shows the iostat command printing information about disk usage on my Ubuntu system.

[email protected]:~$ iostat
Linux 4.6.0-rc1-jason (jason-desktop) 	01/05/16 	_x86_64_	(4 CPU)
 
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           2.50    0.43    1.28   24.37    0.00   71.42
 
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               1.49       147.22         0.00      64455          0
sdb               0.41        14.30         0.00       6260          0
sdc               0.51        19.06         0.00       8345          0
sdd               0.75        28.59         0.00      12516          0
scd0              0.04         0.17         0.00         76          0
sde             153.23      2141.39       783.14     937499     342860

The -c parameter prints the CPU usage chart.

[email protected]:~$ iostat -c
Linux 4.6.0-rc1-jason (jason-desktop) 	01/05/16 	_x86_64_	(4 CPU)
 
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           2.38    0.38    1.20   21.51    0.00   74.52

Use the -h parameter to display the hardware utilization chart in a human readable format.

[email protected]:~$ iostat -h
Linux 4.6.0-rc1-jason (jason-desktop) 	01/05/16 	_x86_64_	(4 CPU)
 
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           2.28    0.34    1.19   19.46    0.00   76.72
 
Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda
                  1.19       117.04         0.00      64455          0
sdb
                  0.33        11.37         0.00       6260          0
sdc
                  0.40        15.15         0.00       8345          0
sdd
                  0.60        22.73         0.00      12516          0
scd0
                  0.03         0.14         0.00         76          0
sde
                122.03      1702.43       629.65     937511     346744

The iostat command is available in the sysstat package for Debian and other distributions. Type sudo apt-get install sysstat to install this useful utility. A related command is vmstat. This will also print out useful system information.

vmstat example.

[email protected]:~$ vmstat 
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 9868316 201264 1025412    0    0   411   139  270  992  3  1 79 17  0

Use the -d parameter in vmstat to print out disk usage information. Kernel version newer than 2.5.70 required.

[email protected]:~$ vmstat -d
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
ram0       0      0       0       0      0      0       0       0      0      0
ram1       0      0       0       0      0      0       0       0      0      0
ram2       0      0       0       0      0      0       0       0      0      0
ram3       0      0       0       0      0      0       0       0      0      0
ram4       0      0       0       0      0      0       0       0      0      0
ram5       0      0       0       0      0      0       0       0      0      0
ram6       0      0       0       0      0      0       0       0      0      0
ram7       0      0       0       0      0      0       0       0      0      0
ram8       0      0       0       0      0      0       0       0      0      0
ram9       0      0       0       0      0      0       0       0      0      0
ram10      0      0       0       0      0      0       0       0      0      0
ram11      0      0       0       0      0      0       0       0      0      0
ram12      0      0       0       0      0      0       0       0      0      0
ram13      0      0       0       0      0      0       0       0      0      0
ram14      0      0       0       0      0      0       0       0      0      0
ram15      0      0       0       0      0      0       0       0      0      0
loop0      0      0       0       0      0      0       0       0      0      0
loop1      0      0       0       0      0      0       0       0      0      0
loop2      0      0       0       0      0      0       0       0      0      0
loop3      0      0       0       0      0      0       0       0      0      0
loop4      0      0       0       0      0      0       0       0      0      0
loop5      0      0       0       0      0      0       0       0      0      0
loop6      0      0       0       0      0      0       0       0      0      0
loop7      0      0       0       0      0      0       0       0      0      0
sda      653      0  128910    1224      0      0       0       0      0      0
sdb      181      0   12520     892      0      0       0       0      0      0
sdc      223      0   16690    1556      0      0       0       0      0      0
sdd      329      0   25032    3765      0      0       0       0      0      1
sr0       19      0     152     400      0      0       0       0      0      0
sde    62169   2174 1875086 1247335   5089  13350  695344  516993      0    241

The -p parameter will print out information about a partition. Kernel version newer than 2.5.70 required.

[email protected]:~$ vmstat -p /dev/sda1
sda1          reads   read sectors  writes    requested writes
                 563     124696          0          0

No comments have been made. Use this form to start the conversation :)

Leave a Reply