3

I use vmstat to get IO stats from ubuntu linux. Below is the description of this command:

IO
       bi: Blocks received from a block device (blocks/s).
       bo: Blocks sent to a block device (blocks/s).

I wonder what the block device means. Does it mean the local disk? I tried to copy a large file on my disk but this value didn't change.

2
  • Yes, local disk would be type of block device, but any device that stores data in blocks of certain size ( usually 512 Mb ) can be called block device. As for vmstat read the IO description again: received from block device. vmstat is about memory, so it shows data copied from block dev to memory. Look for example at mmap()syscall. That maps a file on disk to RAM or virtual memory in general, because performance is better that way Feb 7, 2018 at 3:28
  • You might try iostat to get I/O stats. Feb 7, 2018 at 3:48

1 Answer 1

4

Yes. Your local disk should be a block device, and file copies should show in bi / bo. They are displayed in units of kilobytes per second.

USAGE NOTE. According to man vmstat, the first line of vmstat numbers "gives averages since the last reboot". And this is the only line shown if you run the command vmstat, without any options. Subsequent lines give "information on a sampling period of length delay". delay is an optional argument to vmstat.

Additionally, note that vmstat shows when data is written out to disk. If you write a relatively small amount of data to a file, and your program does not explicitly flush it to disk, then it may stay in cache for some time and not be written to disk immediately.

The following example runs vmstat 1 for a few seconds, while copying from /dev/zero to a file on my disk. I use sync to make sure I see some disk writes.

$ mkdir test &&
   (cd test &&
    (sync ; vmstat 1 > vmstat.log & PID1=$! ; \
     cat </dev/zero >test & PID2=$! ; \
     sleep 3 ; kill $PID2 ; sync ; kill $PID1 ; \
     cat vmstat.log))

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0 478976 2374288  76996 1023860    1    8    64   353   96  251 12  4 82  2  0
 0  2 478976 1782068  76996 1615824    0    0     0 202764 1405  786  0  9 56 34  0
 0  2 478976 1637036  76996 1760512    0    0     0 194572 1421 1013  0  2 59 39  0
 0  2 478976 1491580  76996 1906852    0    0     0 159760 1355  850  0  2 62 36  0
 0  1 478976 1491620  76996 1907068    0    0     0 129036  502  706  0  2 71 27  0
 1  1 478976 1491588  76996 1907068    0    0     0 157696  491  672  0  3 77 20  0
 0  3 478976 1491748  77004 1907064    0    0     0 19904  540 10719  0  2 73 25  0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .