UNIX/Redhat

dm-x 디바이스 매핑

99iberty 2020. 9. 29. 11:15

access.redhat.com/solutions/38628

 

How do I determine which dm-X device maps to each device mapper device on Red Hat Enterprise Linux? - Red Hat Customer Portal

The iostat command is reporting many dm devices that do not exist any longer. They did un-present several LUNs, and did it cleanly. The devices do not show in /dev, but they do see them under sys/block. They do still have aliases in the multipath config fi

access.redhat.com

How do I determine which dm-X device maps to each device mapper device on Red Hat Enterprise Linux?

 

환경

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7
  • Several device-mapper managed devices (either device-mapper-multipath or LVM)

문제

  • The iostat command is reporting many dm devices that do not exist any longer. They did un-present several LUNs, and did it cleanly. The devices do not show in /dev, but they do see them under sys/block. They do still have aliases in the multipath config file for the devices that are no longer present. How do I tell what device is what?
  • PV is created on top of dm device. How to find which dm device maps to which block device?
  • How to find which dm-* device maps to which LVM logical volume?
  • It's difficult to find which dm-* device maps to which LVM if there are too many dm-* devices in the system. How to find the mapping relationship between them?
  • Need to map logical volumes to physical devices
  • Need to find out which LVs are on which disks

해결

readlink

As other device-mapper devices (multipath volumes, LVM volumes, etc) are symlinks to dm-X devices, you can read the symlinks under /dev/ with the command:

Raw

# find /dev/ -name "dm-*" -exec readlink -n {} \; -exec echo " -->" {} \;

For example:

Raw

# find /dev/ -name "dm-*" -exec readlink -n {} \; -exec echo " -->" {} \; ../../dm-1 --> /dev/disk/by-id/dm-uuid-LVM-EiPCcTLzqsUyulYa2uVD8rkRpm2N4qZGZcse3vTfPhuq68qjQcEOCno4aD3Sannx ../../dm-1 --> /dev/disk/by-id/dm-name-vg_home-lv_home ../../dm-0 --> /dev/disk/by-id/dm-uuid-LVM-TNb6i1YpqVhWKdnDFwHjPKBwy9XehulSwFlemewWLMX7X3tL4vbdcgtKx8Ek0HrW ../../dm-0 --> /dev/disk/by-id/dm-name-vg_root-lv_root

dmsetup

Run dmsetup info -c to show all the device mapper managed devices on the system. Take note of the minor number, because this is what dictates the dm-X name of the device:

Raw

# dmsetup info -c Name Maj Min Stat Open Targ Event UUID VolGroup00-LogVol00 253 0 L--w 1 1 0 LVM-os7vitDH17P5xKCpnrvz7Ly6EAyML5ndV7h2Ccn0RvSvgp1b6RNv2U0henbblPV6 VolGroup00-LogVol04 253 1 L--w 1 1 0 LVM-os7vitDH17P5xKCpnrvz7Ly6EAyML5nd2lDXB72mTJWfVbvlSfSZjyUYoF9nO9tT VolGroup00-LogVol02 253 2 L--w 1 1 0 LVM-os7vitDH17P5xKCpnrvz7Ly6EAyML5nd8bFL5gOk9ws2yNNSKWOxIxQb1c1Bi7dY VolGroup00-LogVol01 253 3 L--w 1 1 0 LVM-os7vitDH17P5xKCpnrvz7Ly6EAyML5ndy7pz11AUC12iMJfdDK3qxed43dliIrdW VolGroup00-LogVol03 253 4 L--w 1 1 0 LVM-os7vitDH17P5xKCpnrvz7Ly6EAyML5ndlIeildzKaqemTq7RZXZztD37Z2kd28VM mpath1 253 5 L--w 1 1 1 mpath-3600508b4001056f900006000283c0000 mpath2 253 6 L--w 1 1 1 mpath-3600508b4001056f900006000285a0000 mpath3 253 7 L--w 1 1 1 mpath-3600508b4001056f90000600024560000 mpath6 253 8 L--w 1 1 1 mpath-3600508b4001056f900006000245c0000 mpath5 253 9 L--w 1 1 1 mpath-3600508b4001056f90000600020dd0000 mpath4 253 10 L--w 1 1 1 mpath-3600508b4001056f90000600020ea0000

In the above table:

  • dm-6 would be multipath device mpath2
  • dm-4 is logical volume LogVol03 in volume group VolGroup00

Block Devices

The following dmsetup command can be used to find dm-X device associated/mapped with block device:

Raw

# dmsetup info -c -o name,blkdevname,devnos_used,blkdevs_used

Example output:

Raw

# dmsetup info -c -o name,blkdevname,devnos_used,blkdevs_used Name BlkDevName DevNosUsed BlkDevNamesUsed mpathe dm-1 8:16 sdb mpathd dm-0 8:0 sda mpathb dm-2 8:48 sdd

In the above, dm-1 maps to mpathe whose major number is 8 and minor number is 16

근본 원인

  • device-mapper uses the major device number of 253 for all dm-X devices, and the minor number determines which dm-X device it maps to.
  • The dmsetup command shows device-mapper's internal status.
  • A device mapper device like dm-7 is always presented on the system as block device major number 253 and minor number 7 (hence dm-7)
  • The device dm-8 would therefore be major 253, minor 8.

진단 단계

Other, similar commands. See appropriate man page and lvs -o +help, for example, for more information on the available options of the following commands.

  • lvs (note: KMaj,KMin of 253,1 = dm-1 ; 253,2 = dm-2, etc.)

    Raw

    # lvs --segments -o+lv_uuid,lv_kernel_major,lv_kernel_minor,devices LV VG Attr #Str Type SSize LV UUID KMaj KMin Devices lvhome vga -wi-ao---- 1 linear 488.28g xal02g-UyHA-pcHr-oP3L-wvQJ-K7Jw-RH0YYF 253 1 /dev/sdb6(43366) lvtmp vga -wi-ao---- 1 linear 169.40g zni1v1-r6ZJ-nMQz-WNTE-12zU-xZvd-zCFtoj 253 0 /dev/sdb6(0) lvcases vgb -wi-ao---- 1 linear 188.88g Nzug27-Std2-P0eu-2Pdp-cMO9-uPod-dpPuuK 253 2 /dev/sda2(0) lvcases vgb -wi-ao---- 1 linear 22.48g Nzug27-Std2-P0eu-2Pdp-cMO9-uPod-dpPuuK 253 2 /dev/sda4(0) # lvs --segments -o +lv_kernel_major,lv_kernel_minor,seg_pe_ranges LV VG Attr #Str Type SSize KMaj KMin PE Ranges lvhome vga -wi-ao---- 1 linear 488.28g 253 1 /dev/sdb6:43366-168365 lvtmp vga -wi-ao---- 1 linear 169.40g 253 0 /dev/sdb6:0-43365 lvcases vgb -wi-ao---- 1 linear 188.88g 253 2 /dev/sda2:0-48353 lvcases vgb -wi-ao---- 1 linear 22.48g 253 2 /dev/sda4:0-5755 # lvs -o+seg_le_ranges LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert LE Ranges lvhome vga -wi-ao---- 488.28g /dev/sdb6:43366-168365 lvtmp vga -wi-ao---- 169.40g /dev/sdb6:0-43365 lvcases vgb -wi-ao---- 211.37g /dev/sda2:0-48353 lvcases vgb -wi-ao---- 211.37g /dev/sda4:0-5755 # lvs -ao+devices LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices lvhome vga -wi-ao---- 488.28g /dev/sdb6(43366) lvtmp vga -wi-ao---- 169.40g /dev/sdb6(0) lvcases vgb -wi-ao---- 211.37g /dev/sda2(0) lvcases vgb -wi-ao---- 211.37g /dev/sda4(0)

  • pvs

    Raw

    # pvs --segments -o+lv_kernel_major,lv_kernel_minor,lv_uuid PV VG Fmt Attr PSize PFree Start SSize KMaj KMin LV UUID /dev/sda2 vgb lvm2 a--u 188.88g 0 0 48354 253 2 Nzug27-Std2-P0eu-2Pdp-cMO9-uPod-dpPuuK /dev/sda4 vgb lvm2 a--u 22.48g 0 0 5756 253 2 Nzug27-Std2-P0eu-2Pdp-cMO9-uPod-dpPuuK /dev/sdb6 vga lvm2 a--u 657.68g 0 0 43366 253 0 zni1v1-r6ZJ-nMQz-WNTE-12zU-xZvd-zCFtoj /dev/sdb6 vga lvm2 a--u 657.68g 0 43366 125000 253 1 xal02g-UyHA-pcHr-oP3L-wvQJ-K7Jw-RH0YYF

  • lsblk (note: MAJ:MIN of 253,1 = dm-1 ; 253,2 = dm-2, etc. as shown)

    Raw

    # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 232.9G 0 disk ├─sda1 8:1 0 21.5G 0 part ├─sda2 8:2 0 188.9G 0 part │ └─vgb-lvcases (dm-2) 253:2 0 211.4G 0 lvm /cases └─sda4 8:4 0 22.5G 0 part └─vgb-lvcases (dm-2) 253:2 0 211.4G 0 lvm /cases sdb 8:16 0 931.5G 0 disk ├─sdb1 8:17 0 400M 0 part /boot ├─sdb2 8:18 0 205.1G 0 part /testa ├─sdb3 8:19 0 48.8G 0 part / ├─sdb4 8:20 0 1K 0 part ├─sdb5 8:21 0 19.5G 0 part [SWAP] └─sdb6 8:22 0 657.7G 0 part ├─vga-lvtmp (dm-0) 253:0 0 169.4G 0 lvm /tmp └─vga-lvhome (dm-1) 253:1 0 488.3G 0 lvm /home sr0 11:0 1 1024M 0 rom sdc 8:32 0 7.3T 0 disk └─sdc1 8:33 0 7.3T 0 part /mnt/backups