device mapper, logical volumes, mount points and raw device paths

The other day I was needing to dig into I/O performance on a Linux box and in the past iostat has served me well, so I tried the good old

iostat -x

but wasn’t quite sure what to look at.

Now the box I was working on was enjoying the benefits of RAID and LVM and so the output I saw looked as follows:

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.01    0.00    0.01    0.00    0.00   99.98

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.00     0.89  0.01  0.57     0.28    11.70    20.63     0.00    2.47   0.32   0.02
sdb               0.00     0.00  0.00  0.00     0.00     0.00    13.03     0.00    6.52   6.44   0.00
dm-0              0.00     0.00  0.01  1.46     0.28    11.70     8.12     0.02   13.90   0.13   0.02
dm-1              0.00     0.00  0.00  0.00     0.00     0.00     8.00     0.00    7.76   1.60   0.00

I thought “Ok, so what is the mount point I should focus on” and it turned out to be /dev/mapper/VolGroup00-LogVol00.

I was pretty sure that this path mapped to one of the dm-0 or dm-1 and had I been forced to guess, I would have chosen dm-0 because of the high number of 0s, but that just seemed sloopy.

So I started searching on how to map them exactly. I played with lvdisplay and pvdisplay and ls /dev but there were no clear symlinks or references to follow it clearly.

Finally after much to much time, I found /sys/block/, which actually contained (among others) directories named dm-0 and dm-1. Unfortunately, with I did not find a clear pointer back to the /dev/mapper hierarchy.

finally after much googling I found some references that suggest that the key lies in the major and minor numbers.

So, the secret is that the devices in /dev/mappper have a major and minor number (that’s not the secret). That major and minor number can be found as MAJ:MIN in one of the files under /dev/block/*/dev where the * will end up being something like dm-0. Then you can use iostat to query that device.

That seemed painful to me, but easy to execute, once I found it.

Oh and while I was digging and searching and hunting about I came across a really nice tutorial on LVM2


Leave a Reply

Your email address will not be published. Required fields are marked *