How to identify /dev/mapper/path actual device on our linux system ?

Today in this post, we will look how to identify the lvm, or multipath device which is mapped by device mapper on our system.

Device mapper automatically creates a pseudo block device from the existing devices on the system, and mount our root and other filesystems from these mapper bloack device paths.

Have you ever confused how to get the actual device behind these mapper device names ?

Its quite easy, lets see this step by step.

1. Identify the mapper device path.

[root@ngelinux ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  6.2G  4.7G  1.6G  75% /
devtmpfs                 480M     0  480M   0% /dev
tmpfs                    496M     0  496M   0% /dev/shm

Here we have “/dev/mapper/centos-root” device path mapped to /.

 

2. Get the major and nimor number of this device path.

### Lets check the device with which it is linked to.
[root@ngelinux ~]# cd /dev/mapper/
[root@ngelinux mapper]# ls -ltr
total 0
crw-------. 1 root root 10, 236 Aug 23 22:31 control
lrwxrwxrwx. 1 root root       7 Aug 23 22:31 centos-swap -> ../dm-1
lrwxrwxrwx. 1 root root       7 Aug 23 22:31 centos-root -> ../dm-0

### Do a long list to the actual binary device.
### Here we get 253 and 0 as major and minor numbers.
[root@ngelinux mapper]# ls -l ../dm-0 
brw-rw----. 1 root disk 253, 0 Aug 23 22:31 ../dm-0

3. Match the major and minor numbers with system devices.

[root@ngelinux mapper]# dmsetup ls --tree
centos-swap (253:1)
 `- (8:2)
centos-root (253:0)
 `- (8:2)

[root@ngelinux mapper]# lsblk 
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0    8G  0 disk 
|-sda1            8:1    0    1G  0 part /boot
`-sda2            8:2    0    7G  0 part 
  |-centos-root 253:0    0  6.2G  0 lvm  /
  `-centos-swap 253:1    0  820M  0 lvm  [SWAP]
sdb               8:16   0    8G  0 disk 
|-sdb1            8:17   0    1G  0 part 
`-sdb2            8:18   0  1.9G  0 part /testext
sr0              11:0    1 1024M  0 rom  
[root@ngelinux mapper]# 

 

4. Verify with lvdisplay in case of LVM.

  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                MFUdb1-Rsv6-TYnP-iP9r-ubYs-cOK7-YW19ej
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-03-13 19:09:41 -0400
  LV Status              available
  # open                 1
  LV Size                <6.20 GiB
  Current LE             1586
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
3 2 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments