142

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.

Giacomo1968
  • 58,727

10 Answers10

148

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

63

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/

gulden PT
  • 731
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  /
GChuf
  • 1,327
Pascal
  • 441
27

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 
Box293
  • 371
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).

Simon
  • 3,973
eel ghEEz
  • 318
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

Jawa
  • 3,679
Rob
  • 131
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
karthik
  • 141
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

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.