139

While poking around trying to figure out why a Linux -> Linux file transfer is running slower than I think it should, I stumbled across something I'm not familiar with. /dev/dm-0 seems to be my bottleneck, but I have no idea what it is.

On my destination server, the iostat command shows a device at the bottom, /dev/dm-0, as being 100% utilized. This server has 6 disks in a mdadm raid5 set, with LVM running on top of it. Each of the underlying disks are sitting around 50% util. The transfer is writing to a logical volume located on this raidset.

What is this /dev/dm-0 thing? Once I know what it is, maybe I can find how to increase its speed, or at least understand why its the speed that it is.

1
  • 4
    It turns out that the dm-0 device wasn't causing the slowness, I had the partitions aligned wrong. On a 4k sector drive, you need to manually align the partitions when you create them. Dumb, but easy to fix.
    – user4491
    Apr 16, 2010 at 21:15

10 Answers 10

143

It's part of the device mapper in the kernel, used by LVM. Use dmsetup ls to see what is behind it.

3
  • 67
    More specifically sudo dmsetup info /dev/dm-0
    – tgharold
    Dec 30, 2015 at 13:13
  • 6
    dmsetup ls does not return any useful information on what the dm-0 is, or where it can be found.
    – karatedog
    Sep 18, 2019 at 13:18
  • In my case the number after the : on each line matched the number in dm-0
    – Dark
    Nov 18, 2020 at 17:08
61

Those are LVM logical "devices"

You can map them using:

# sudo lvdisplay|awk  '/LV Name/{n=$3} /Block device/{d=$3; sub(".*:","dm-",d); print d,n;}'
dm-0 /dev/SysVolGroup/LogVolRoot
dm-1 /dev/SysVolGroup/xen
dm-2 /dev/SysVolGroup/db1-2
dm-3 /dev/SysVolGroup/db1-2swap
dm-4 /dev/SysVolGroup/python1
dm-5 /dev/SysVolGroup/python1swap
dm-6 /dev/SysVolGroup/db1-2snap

source: http://www.linuxquestions.org/questions/linux-newbie-8/dm0-in-iostat-652771/

43

As usual under a Linux system, there should be many ways to get the same result. If you've been given a non root user, I advise you to use lsblk command (list block devices) which will build a tree view of disks dependencies:

[oracle@abcdlinux ~]$ lsblk
NAME                               MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda                                  8:0    0  300G  0 disk
└─RATGORA1DSY_PJSTORE_1 (dm-4)     253:4    0  300G  0 mpath
  └─RATGORA1DSY_PJSTORE_1p1 (dm-5) 253:5    0  300G  0 part  /oradata
sdb                                  8:16   0  100G  0 disk
└─Boot-RATGORA1DSY (dm-0)          253:0    0  100G  0 mpath
  ├─Boot-RATGORA1DSYp1 (dm-1)      253:1    0  100M  0 part  /boot
  ├─Boot-RATGORA1DSYp2 (dm-2)      253:2    0   16G  0 part  [SWAP]
  └─Boot-RATGORA1DSYp3 (dm-3)      253:3    0 83.9G  0 part  /
sdc                                  8:32   0  300G  0 disk
└─RATGORA1DSY_PJSTORE_1 (dm-4)     253:4    0  300G  0 mpath
  └─RATGORA1DSY_PJSTORE_1p1 (dm-5) 253:5    0  300G  0 part  /oradata
sdd                                  8:48   0  100G  0 disk
└─Boot-RATGORA1DSY (dm-0)          253:0    0  100G  0 mpath
  ├─Boot-RATGORA1DSYp1 (dm-1)      253:1    0  100M  0 part  /boot
  ├─Boot-RATGORA1DSYp2 (dm-2)      253:2    0   16G  0 part  [SWAP]
  └─Boot-RATGORA1DSYp3 (dm-3)      253:3    0 83.9G  0 part  /
1
  • 1
    Were these devices created by LVM?
    – Melab
    Sep 10, 2020 at 13:56
23

I wanted to comment on Pascal's post, sometimes you need to define the output columns to see the name. For example on CentOS 6 it displays them but CentOS 7 doesn't. Using --output resolves this.

lsblk --output NAME,KNAME,TYPE,SIZE,MOUNTPOINT

NAME            KNAME TYPE  SIZE MOUNTPOINT
sda             sda   disk   16G 
├─sda1          sda1  part  500M /boot
└─sda2          sda2  part 15.5G 
  ├─centos-root dm-0  lvm  13.9G /
  └─centos-swap dm-1  lvm   1.6G [SWAP]
sr0             sr0   rom  1024M 
2
  • 4
    awesome, much easier to pinpoint KNAMEs on exact devices, thanks
    – Alexander
    Apr 25, 2018 at 20:33
  • The mount points may not show if you didn't run dmsetup mknodes... even if they exist, i.e. if the devices are mounted directly via /dev/dm-X, which is not recommended. lsblk will only see them if they're also linked in /dev/mapper, which is what dmsetup mknodes does. At least on Ubuntu 18. Jan 21 at 0:26
19
sudo lvdisplay

showed the mapping of mounted virtual partitions to "volume groups".

When I typed sudo pvs I saw the mapping of a volume group to a "physical volume" that looked like a familiar /dev/sdaN notation. (My looking at the whole disk with fdisk -l /dev/sda showed another partition).

0
13

pvs displays the physical volumes that underpin the LVM volume group. A number of physical devices can be grouped together to from one volume group. The group is then re-split into logical volumes as required treating the physical disks as a single resource to be chopped up and re-sized at will. Each time you slice of part of the volume group as a logical volume it is presented as a dm- device

4

You can use sar

df -h

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-rootvol
                   24G  4.1G   18G  19% /
tmpfs                 7.8G     0  7.8G   0% /dev/shm
/dev/mapper/VolGroup01-appvol
                   39G  411M   37G   2% /app
/dev/sda1             194M   93M   92M  51% /boot
/dev/mapper/VolGroup01-logvol
                   61G   18G   41G  30% /log
/dev/mapper/VolGroup00-tmpvol
                  2.0G  379M  1.5G  21% /tmp
/dev/mapper/VolGroup00-varvol
                   20G  2.1G   17G  12% /var

sar -bdp 1

01:00:20 AM       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz         await     svctm     %util
01:00:21 AM       sda      0.00      0.00      0.00      0.00      0.00              0.00      0.00      0.00
01:00:21 AM VolGroup00-swapvol      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
01:00:21 AM VolGroup00-rootvol      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
01:00:21 AM VolGroup01-appvol      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
01:00:21 AM VolGroup01-logvol      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
01:00:21 AM VolGroup00-varvol      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
01:00:21 AM VolGroup00-tmpvol      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
2
  • 1
    df -h worked on Android for me Mar 20, 2020 at 12:26
  • Thanks, sar is the only non-root option that showed what these mean.
    – Timmmm
    Aug 25, 2022 at 9:37
2

You could also use iostat for the purpose of identifying possible bottlenecks, for example:

iostat -x -d 1
2

Since the title of the question is still "What is this dm-0 device", it should be mentioned atleast once that dm-X (dm-0, etc) are not always LVM related. More directly, they are part of the "device mapper" system which is used by LVM but, for example, in my case some kind of strange happening from osprobe and/or update-grub created them.

dm-X devices showed up in my /dev/ folder and were causing problems since the devices they pointed to were raid members and when the raid was assembled through them it was read only. I came to this SU question trying to find out "What are these dm-X" devices, and it lead me to believe I somehow had slipped on a banana peel and ended up with an LVM setup that I never intentially created.

After I verified there was no actual LVM in use because the outputs of pvs lvs pvsetup and lvsetup all returned absolutely nothing, I just used the dmsetup command to remove the device mappings like dmsetup remove /dev/dm-0

After this the problems it was causing were resolved, and I could use my devices normally.

1
  • Thanks, I removed the EOL dm-2 with dmsetup remove /dev/dm-2. Good job! Dec 21, 2022 at 9:49
1

I got the requested information on CentOS 7 by first listing LVM volume groups with vgs:

# vgs
VG     #PV #LV #SN Attr   VSize  VFree
centos   1   3   0 wz--n- <1.82t 4.00m

Note the volume group name, and then simply list ls -l /dev/centos:

# ls -l /dev/centos
lrwxrwxrwx. 1 root root 7 Jun 23 09:26 home -> ../dm-2
lrwxrwxrwx. 1 root root 7 Jun 23 09:26 root -> ../dm-0
lrwxrwxrwx. 1 root root 7 Jun 23 09:26 swap -> ../dm-1

Ok, it's /dev/mapper/centos-root. The command df may show you where that file system is mounted. The command pvs shows the physical volume where the file system lives. In my case /dev/sda3.

You must log in to answer this question.