When working with LVM in Linux, you'll often encounter two different naming schemes for the same block devices:
# What you see in mount:
/dev/mapper/VolGroup00-LogVol00
# What appears in iostat:
dm-0
The most straightforward method uses dmsetup
:
sudo dmsetup ls --tree
VolGroup00-LogVol00 (253:0)
└─ (8:2)
This shows the mapping between the human-readable name and the device mapper number (253:0 here corresponds to dm-0).
For scripting purposes, this one-liner creates a complete mapping:
ls -l /dev/mapper/* | grep -v control | awk '{print $9, $10}' | \
while read -r link target; do \
dev=$(readlink -f "$link"); \
echo "$(basename "$link") -> $(basename "$dev")"; \
done
To make iostat show friendly names:
iostat -xN 1
The -N
flag displays LVM names instead of dm-* names.
For systems where device numbers might change, use UUIDs:
blkid /dev/mapper/VolGroup00-LogVol00
/dev/mapper/VolGroup00-LogVol00: UUID="5a3f4e1d..." TYPE="ext4"
Here's how I debugged a performance issue:
# iostat shows heavy IO on dm-3
iostat -x 1
# Find which LVM volume this is
ls -l /dev/dm-3
lrwxrwxrwx 1 root root 4 Jan 10 10:00 /dev/dm-3 -> ../dm-3
# Get major:minor numbers
ls -l /dev/dm-3
brw-rw---- 1 root disk 253, 3 Jan 10 10:00 /dev/dm-3
# Cross-reference with dmsetup
dmsetup info -c -o name,major,minor | grep "253,.*3"
backup_vg-backup_lv 253 3
Another approach using LVM tools:
lvdisplay -m | grep -A1 "Logical volume" | \
awk '/LV Name/{name=$3} /Block device/{print name, $3}'
When working with LVM-managed storage in Linux, you'll often encounter two different naming schemes:
# Mount output shows LVM logical volume names
/dev/mapper/VolGroup00-LogVol00 on / type ext4 (rw)
# iostat shows kernel device mapper names
Device: tps kB_read/s kB_wrote/s
dm-0 10.21 102.34 205.67
dm-1 5.43 51.29 89.32
Method 1: Using dmsetup
The most reliable way to map dm-X devices to LVM names:
# List all device mapper names with their major:minor numbers
$ sudo dmsetup ls --tree
VolGroup00-LogVol00 (253:0)
└─ (8:2)
VolGroup00-LogVol01 (253:1)
└─ (8:2)
# Then check iostat -x output to match major:minor numbers
$ ls -l /dev/dm-*
brw-rw---- 1 root disk 253, 0 Jan 15 10:30 /dev/dm-0
brw-rw---- 1 root disk 253, 1 Jan 15 10:30 /dev/dm-1
Method 2: Using lsblk
A more visual approach with hierarchical display:
$ lsblk -o NAME,KNAME,MAJ:MIN,RM,SIZE,RO,FSTYPE,MOUNTPOINT
NAME KNAME MAJ:MIN RM SIZE RO FSTYPE MOUNTPOINT
sda sda 8:0 0 500G 0
├─sda1 sda1 8:1 0 1G 0 ext4 /boot
└─sda2 sda2 8:2 0 499G 0
├─VolGroup00-LogVol00 dm-0 253:0 0 400G 0 ext4 /
└─VolGroup00-LogVol01 dm-1 253:1 0 99G 0 ext4 /home
Method 3: Using udevadm
For detailed low-level device information:
$ udevadm info -q all -n /dev/dm-0 | grep DM_NAME
E: DM_NAME=VolGroup00-LogVol00
For frequent use, create a mapping script:
#!/bin/bash
for device in $(ls /dev/dm-* | sort); do
dev_name=$(basename $device)
vol_name=$(sudo dmsetup info -c --noheadings -o name $dev_name)
echo "$dev_name -> /dev/mapper/$vol_name"
done
Sample output:
dm-0 -> /dev/mapper/VolGroup00-LogVol00
dm-1 -> /dev/mapper/VolGroup00-LogVol01
Note that dm-X numbering isn't persistent across reboots. For monitoring scripts, always use:
- /dev/mapper/ names (persistent)
- Major:minor numbers (consistent until configuration changes)
- UUIDs (most persistent but requires filesystem)
Combine these techniques to monitor specific LVM volumes:
# Get all dm-X devices for your volume group
$ vgdisplay -v VolGroup00 | grep "Logical volume" -A1 | grep "dm-"
# Then monitor specific LV:
$ iostat -x $(dmsetup info -c --noheadings -o name dm-0) 1 5