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

This example shows the iostat command printing information about disk usage on my Linux Mint 14 system.

john@adeptus-mechanicus ~ $ iostat 
Linux 3.5.0-17-generic (adeptus-mechanicus) 	19/01/13 	_x86_64_	(4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           9.51    0.01    2.01    0.58    0.00   87.89

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0.04         3.15         0.00     634168        808
sdb               0.03         0.08         0.07      15609      14218
scd0              0.00         0.00         0.00        384          0
sdc               0.02         1.42         0.00     285780          3
sdg               0.15         3.63         0.00     729908         24
sdh               1.73        19.24        40.66    3873113    8182464
sdi               0.01         0.29         0.00      58696          1

The -c parameter prints the CPU usage chart.

john@adeptus-mechanicus ~ $ iostat -c
Linux 3.5.0-17-generic (adeptus-mechanicus) 	19/01/13 	_x86_64_	(4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           9.61    0.01    2.00    0.58    0.00   87.80

And the -d parameter displays the hardware usage chart.

john@adeptus-mechanicus ~ $ iostat -d
Linux 3.5.0-17-generic (adeptus-mechanicus) 	19/01/13 	_x86_64_	(4 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0.04         3.14         0.00     634168        808
sdb               0.03         0.08         0.07      15609      14218
scd0              0.00         0.00         0.00        384          0
sdc               0.02         1.41         0.00     285780          3
sdg               0.15         3.61         0.00     729908         24
sdh               1.73        19.17        40.63    3874805    8215248
sdi               0.01         0.29         0.00      58696          1

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

john@adeptus-mechanicus ~ $ iostat -h
Linux 3.5.0-17-generic (adeptus-mechanicus) 	19/01/13 	_x86_64_	(4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           9.66    0.01    2.00    0.57    0.00   87.76

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda
                  0.04         3.13         0.00     634168        808
sdb
                  0.03         0.08         0.07      15609      14218
scd0
                  0.00         0.00         0.00        384          0
sdc
                  0.02         1.41         0.00     285780          3
sdg
                  0.15         3.61         0.00     729908         24
sdh
                  1.73        19.15        40.61    3874805    8218644
sdi
                  0.01         0.29         0.00      58696          1

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.

john@adeptus-mechanicus ~ $ vmstat 
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 1  0  11840 334480 605220 3473196    0    0    14    20   85   15 10  2 88  1

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

john@adeptus-mechanicus ~ $ 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     8714 162501 1268336   44212    120     82    1616     372      0     29
sdb     3138     90   31218   22524   2041   1030   28436   16540      0      5
sr0      130     62     768    9224      0      0       0       0      0      9
sdc     4851   1718  571560   65344      4      3       7       4      0     19
sdd        0      0       0       0      0      0       0       0      0      0
sde        0      0       0       0      0      0       0       0      0      0
sdf        0      0       0       0      0      0       0       0      0      0
sdg    29456 258350 1459816   88108      4      2      48       0      0     80
sdh   116902 447188 7749674 2103880 233916 315734 16469736 9003876      0   2749
sdi     1110   1320  117393   10684      3      0       3    1480      0      5

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

john@adeptus-mechanicus ~ $ vmstat -p /dev/sda1
sda1          reads   read sectors  writes    requested writes
                6785    1252408         78        992
About

I am a computer enthusiast that has always been interested in maintaining and upgrading computer hardware. I was born on a farm and lived there for 13 years before moving into town. I was always interested in technology and my father always gave me good encouragement for developing my knowledge and interest in tinkering with computers. He was using a computer on the farm but that was in the very late 80`s and late 90`s. Seeing what a computer could do always fascinated me and then I knew that is what I wanted to do. The first time I used Linux was Red Hat 6.2 installed off a single CDROM and I was amazed that you did not need to install any more drivers on my old Intel Celeron machine to be able to enjoy a nice 24BPP desktop and use the GIMP to edit photos and enjoy playing the old Linux games like Xbill. Then a while later I tried Mandrake Linux 9.2 and I was hooked. It came with so much software and was very easy to use as well. Then Mandrake Linux 10 and on through FreeBSD, Debian 3.0, Debian 3.1 Suse Linux 9.2, Suse 10 and onto the Ubuntu distributions although I am using Fedora Core 15 and the Gnome 3 desktop at the moment.

Tagged with: , , , ,
Posted in Ubuntu

Leave a Reply

close
Facebook Iconfacebook like buttonYouTube IconSubscribe on YouTubeTwitter Icontwitter follow button
Plugin from the creators of Brindes :: More at Plulz Wordpress Plugins