title: Why read per second (r/s) in linux command (iostat) all the time is zero?
body: <p>I run a java code that produces a lot of read and write from/to a text file. The program source is very simple and in a loop I write 2000 lines in a test file and then I read them again just to generate a lot of read and write to the disk. But when program is running I <strong>monitor the disk</strong> by "iostat -d -x 1" I found that <strong>there is no change in read in second "r/s" but "w/s" increased as I expected!!!</strong> 
  This is a sample output of iostat command:</p>
  
  <pre><code>Device: rrqm/s wrqm/s  r/s   w/s    rsec/s wsec/s   avgrq-sz avgqu-sz await svctm  %util
  sda     0.00   913.00  0.00  82.00  0.00   7872.00   96.00    0.58    7.09   7.11  58.30
  
  Device: rrqm/s wrqm/s  r/s   w/s   rsec/s  wsec/s  avgrq-sz  avgqu-sz  await  svctm  %util
  sda     0.00   869.00  0.00  79.00  0.00   7584.00    96.00   0.57    7.11   7.18  56.70
  
  Device: rrqm/s wrqm/s  r/s   w/s   rsec/s  wsec/s  avgrq-sz avgqu-sz   await  svctm  %util
  sda     0.00   847.00  0.00  77.00  0.00   7392.00   96.00   0.57      7.42   7.43  57.20
  
  Device: rrqm/s wrqm/s  r/s   w/s   rsec/s  wsec/s   avgrq-sz avgqu-sz  await  svctm  %util
  sda     0.00  1221.00  0.00  113.00  0.00  10760.00  95.22    0.84     7.47   7.32  82.70
  </code></pre>
  
  <p>As it is shown, all "r/s" are zero! but in Java program I read as much as I write in the file?! When I run the Java code, number of write per second increases, but there is no change in " r/s" !!
  Here is java code that I run when monitoring disk :</p>
  
  <pre><code>import java.io.*;
  
  public class Test {
  
      public static void main(String [] args) throws IOException{
  
      String fileName = "/scratch/dump_file.txt";
      File f = new File(fileName);
      // Attempt to delete it
      boolean success = f.delete();
      int j=0;
      while(j&lt;20000)
      {
          ++j;
          Writer output = null;
          String text = "A test content";
          File file = new File(fileName);
          output = new BufferedWriter(new FileWriter(file));
  
          int i=1;
          while(i&lt;2000)
          {
              //Here we start writing 2000 lines into file line by line
              output.write("j==="+Integer.toString(j)+text+Integer.toString(i)+"\n");
              ++i;
          }
          output.close();
          System.out.println("Your file has been written");  
  
          String line = null;
          try {
              // FileReader reads text files in the default encoding.
              FileReader fileReader = new FileReader(fileName);
              BufferedReader bufferedReader = 
              new BufferedReader(fileReader);
              i=1;
              while((line = bufferedReader.readLine()) != null) {
                  //Here we start reading from file line by line and show the result on screen
                  ++i;
                  System.out.println(line);
              }   
              // Always close file
              bufferedReader.close();         
          }
          catch(FileNotFoundException ex) {
              System.out.println(
                  "Unable to open file '" + 
                  fileName + "'");                
          }
          catch(IOException ex) {
              System.out.println(
                  "Error reading file '" 
                  + fileName + "'");                  
              // Or we could just do this: 
              // ex.printStackTrace();
          }
      }
  }
  }
  </code></pre>