Mapping DM device to name

Running iostat I've discovered it operates with dm-XX devices instead of names I used to.

Searching /sys FS brings solution:

# (cd /sys/devices/virtual/block ; for d in dm-* ; do echo "$d : $(cat $d/dm/name)" ; done )
dm-0 : rootvg-swap
dm-1 : rootvg-slash
dm-2 : rootvg-usr
dm-3 : rootvg-home
dm-4 : rootvg-opt
dm-5 : rootvg-var

Relevant for kernels above 2.6.18

Previous kernel versions require deep search for MAJOR:MINOR numbers of devices Here is a one-line script to do this:

# DM="dm-3"
# find /dev -type b -exec ls -l {} \; | awk '{gsub(",",":");print $5$6" "$NF}' | grep $(cat /sys/block/$DM/dev)
253:3 /dev/mapper/rootvg-var

Then I've found out that netstat -N prints name instead of dm- labels.


Updated on Sun Mar 9 08:35:52 UTC 2014 More documentations here