Sometimes, to troubleshoot some multipath related issues, you would require to map the /dev/mapper/mpathY device to its corresponding /dev/sdX device. The /dev/mapper/mpathY is the multipath’d device where as the /dev/sdX is the actual device underlying it. Follow the steps below to find the mapping between the two and vice versa. We would also see how to find the /dev/sdX device name from the corresponding /dev/mapper/dm-* entry.

 

How to map /dev/mapper/mpathY device from /dev/dm-Z device

 

1. To determine which /dev/mapper entry corresponds to this /dev/dm-* entries, run the following ls command:

# ls -l /dev/dm-9
brw-r----- 1 root disk 252,  9 Oct 16 00:54 /dev/dm-9

 

2. Now, examine the friendly names for these devices.

# ls -l /dev/mapper/*
brw-rw---- 1 root disk 252,   9 Oct 16 00:54 /dev/mapper/backup
brw-rw---- 1 root disk 252,  10 Oct 16 00:54 /dev/mapper/home
brw-rw---- 1 root disk 252,  12 Oct 16 00:54 /dev/mapper/log
brw-rw---- 1 root disk 252,  11 Oct 16 00:54 /dev/mapper/stage

 

3. The fifth and sixth fields are the device major and minor numbers. This pair uniquely identifies each device.

 

4. For the /dev/dm-9 query, we find the pair 252,9 as the system device. By examining the listing of the friendly names we can see that 252,9 pair associated with the /dev/mapper/backup name.

 

How to map /dev/sdX device from /dev/mapper/ device

 

To determine the /dev/sdX Device details from the output of /dev/mapper, follow the example shown below.

 

1. You have a /dev/mapper device as shon below from the ‘df-hP’ command output.

# df -hP
Filesystem                          Size  Used Avail Use% Mounted on
/dev/mapper/vg_os-lv_os             184G  125G   51G  72% /

 

2. Run the command below on the /dev/mapper/vg_os-lv_os device as shown below.

# dmsetup table /dev/mapper/vg_os-lv_os
0 392183808 linear 8:2 2048

 

The fourth field (8:2) is the one which is of interest here.

 

3. Now run the below command to list all sdX device under /dev folder. For example:

# ls -Al /dev/sd*
brw-rw---- 1 root disk 8, 0 Sep  8 10:51 /dev/sda
brw-rw---- 1 root disk 8, 1 Mar 30  2017 /dev/sda1
brw-rw---- 1 root disk 8, 2 Mar 30  2017 /dev/sda2
brw-rw---- 1 root disk 8, 3 Mar 30  2017 /dev/sda3

 

4. The entry 8 (major), 4 (minor) from the “ls -Al” output is the one which matches the 8:2 entry from the “dmsetup table” command. So, /dev/mapper/vg_os-lv_os actually is /dev/sda2.

 

Using the command blkid and lsblk

 

The commands blkid and lsblk are very handy to map the relationship between /dev/sdX, /dev/mapper and /dev/dm-* devices. Below are sample outputs of both the commands.

# blkid 
/dev/mapper/vg_os-lv_root: UUID="d5b718a4-0c7d-4289-b0ae-5787c0248413" TYPE="ext4"
/dev/mapper/vg_os-lv_swap: UUID="f578caa6-18b0-46b9-bfc4-10c23aacca01" TYPE="swap"

 

# lsblk
NAME                                 MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                                    8:0    0 838.3G  0 disk
├─sda1                                 8:1    0     1G  0 part  /boot
└─sda2                                 8:2    0 837.3G  0 part
  ├─vg_os-lv_root (dm-0)             253:0    0   100G  0 lvm   /
  └─vg_os-lv_swap (dm-1)             253:1    0   192G  0 lvm   [SWAP]

 

As seen from the outputs above, /dev/dm-0 corresponds to the root device (/) which in turn maps to /dev/mapper/vg_os-lv_root device.

 

Ця відповідь Вам допомогла? 0 Користувачі, які знайшли це корисним (0 Голосів)