Skip to main content

Block Devices

Recently I was looking at some performance data with sar on one of my systems at home. While it was performing well, I didn't quite understand why there wasn't a lot of data being written on a particular device (compared to a couple of other volumes where I was doing about 50 tps for my database).

sar -d -s 19:35:00 -e 19:45:00 -f /var/log/sa/sa09 | egrep 'DEV|8-3'
07:35:01 PM     DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
07:36:01 PM  dev8-3      0.84      0.00      6.71      8.00      0.00      0.80      0.74      0.06
07:37:01 PM  dev8-3      1.05      0.00      8.43      8.00      0.00      0.75      0.70      0.07
07:38:01 PM  dev8-3      0.98      0.00      7.84      8.00      0.00      0.71      0.71      0.07
07:39:01 PM  dev8-3      1.02      0.00      8.20      8.00      0.00      0.74      0.69      0.07
07:40:01 PM  dev8-3      0.92      0.00      7.38      8.00      0.00      0.87      0.87      0.08
07:41:01 PM  dev8-3      1.11      0.00      8.87      8.00      0.00      0.79      0.70      0.08
07:42:01 PM  dev8-3      0.98      0.00      7.87      8.00      0.00      0.83      0.78      0.08
07:43:01 PM  dev8-3      1.16      0.00      9.26      8.00      0.00      0.70      0.58      0.07
07:44:01 PM  dev8-3      1.09      0.00      8.72      8.00      0.00      0.88      0.68      0.07
Average:     dev8-3      1.02      0.00      8.14      8.00      0.00      0.78      0.71      0.07

While the drive wasn't really busy at this particular hour, I wanted to see which drive it actually was, and where it was mapped on my system.

Running the following command, I was able to map out all the devices on my system (in the below example, I am grepping on 8 from the dev8-3 above, which corresponds to sda3 below. This represents major device id 8 in column 5 and minor device id 3 in column 6):

timb@pc015:~$ ls -l /dev/ | grep -E ' 8, '
brw-rw---- 1 root disk      8,   0 2016-05-21 13:45 sda
brw-rw---- 1 root disk      8,   1 2016-05-21 13:45 sda1
brw-rw---- 1 root disk      8,   2 2016-05-21 13:45 sda2
brw-rw---- 1 root disk      8,   3 2016-05-21 13:45 sda3
brw-rw---- 1 root disk      8,   4 2016-05-21 13:45 sda4
brw-rw---- 1 root disk      8,   5 2016-05-21 13:45 sda5
brw-rw---- 1 root disk      8,   6 2016-05-21 13:52 sda6
brw-rw---- 1 root disk      8,  16 2016-05-21 13:45 sdb
brw-rw---- 1 root disk      8,  17 2016-05-21 13:45 sdb1
brw-rw---- 1 root disk      8,  32 2016-05-21 13:45 sdc
brw-rw---- 1 root disk      8,  48 2016-05-21 13:45 sdd
brw-rw---- 1 root disk      8,  64 2016-05-21 13:45 sde
brw-rw---- 1 root disk      8,  80 2016-05-21 13:45 sdf

And now I was able to see that device 8-3 maps to sda3.

Now, I could look at my /etc/fstab file (or even just run mount to see what is mounted where) and see the following:

timb@pc015:~$ mount
/dev/sda3 on / type ext3 (rw,relatime,errors=remount-ro)
proc on /proc type proc (rw)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
   ...
none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/dev/sdb1 on /media/sdb1 type ext3 (rw,relatime)
/dev/sda1 on /boot type ext3 (rw,relatime)
/dev/sda6 on /home type ext3 (rw,relatime)

So now I can see that the activity is low (performance wise) because the mount point (/) is just my main root file system. Of course, I'm not going to be reading and writing a lot of data there. But this helped me track down the disk performance characteristics that sar was showing me.

I could probably write a small script to give me more data and map this out for me, but sometimes showing the steps will help someone else understand their own system.