How to Determine if /dev/dm-1 is a Partition or Whole Block Device in Linux and Find Its Parent Device


2 views

In Linux systems, /dev/dm-* devices are virtual block devices created by the Device Mapper subsystem. These can represent either:

  • Complete virtual block devices (e.g., LVM logical volumes, dm-crypt devices)
  • Partitions within such devices

The most reliable way to check if /dev/dm-1 is a partition or whole device is using lsblk:

lsblk -o NAME,MAJ:MIN,RM,SIZE,RO,TYPE,MOUNTPOINT /dev/dm-1

Key indicators in the output:

TYPE=part means it's a partition

TYPE=lvm or TYPE=crypt typically indicates a whole device

For even more detailed information:

udevadm info --query=all --name=/dev/dm-1 | grep -E 'DEVTYPE|ID_PART_ENTRY'

If you see DEVTYPE=partition, it's definitely a partition.

For partition devices, find the parent using:

lsblk -s /dev/dm-1

Or programmatically with this Python snippet:

import os
def get_parent_device(dev_path):
    sys_path = f"/sys{os.path.realpath(dev_path)}"
    if os.path.exists(f"{sys_path}/partition"):
        with open(f"{sys_path}/../dev", 'r') as f:
            major_minor = f.read().strip()
        return f"/dev/block/{major_minor.replace(':', '-')}"
    return None

parent = get_parent_device('/dev/dm-1')
print(f"Parent device: {parent}")

Direct sysfs inspection provides low-level details:

cat /sys/class/block/dm-1/partition

If this file exists (returns 1), dm-1 is a partition. For the parent device:

readlink /sys/class/block/dm-1/..

Consider an LVM scenario where /dev/dm-1 is a partition on an encrypted volume:

# lsblk output example
NAME          MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda             8:0    0  100G  0 disk  
└─sda1          8:1    0  100G  0 part  
  └─crypt     253:0    0  100G  0 crypt 
    ├─vg-root 253:1    0   90G  0 lvm   /
    └─vg-data 253:2    0   10G  0 lvm   
      └─dm-1  253:3    0   10G  0 part

In this case, /dev/dm-1 is a partition with parent device /dev/mapper/vg-data (major:minor 253:2).

Remember that Device Mapper devices can be nested, so you might need to traverse multiple levels to find the physical device.


The /dev/dm-1 device belongs to Linux's device mapper framework, which provides virtual block device functionality. These devices typically represent:

  • LVM logical volumes
  • Software RAID devices
  • Encrypted volumes (dm-crypt)
  • Thin-provisioned storage

The most straightforward way to identify the device type is using lsblk:

lsblk /dev/dm-1
NAME      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
dm-1     253:1    0   10G  0 lvm  /data

Check the TYPE column:

  • disk indicates a whole block device
  • part indicates a partition
  • lvm suggests it's an LVM logical volume (virtual device)

For detailed mapping information:

sudo dmsetup info /dev/dm-1
Name:              vg0-data
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
[...]

This reveals the device's origin and mapping details.

To trace back to physical devices for LVM volumes:

sudo lvdisplay /dev/dm-1 | grep "LV Path"
  LV Path                /dev/vg0/data

sudo pvdisplay -m
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               vg0
  PV Size               100.00 GiB
  [...]

For a dm-crypt encrypted partition at /dev/dm-1:

sudo cryptsetup status /dev/dm-1
/dev/mapper/sda3_crypt is active and is in use.
  type:    LUKS1
  cipher:  aes-xts-plain64
  keysize: 512 bits
  device:  /dev/sda3
  [...]

If the device might contain partitions:

sudo fdisk -l /dev/dm-1
Disk /dev/dm-1: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
  • DM devices are virtual - they map to other block devices
  • The device might be:
    • A whole virtual disk (like an LVM LV)
    • A partition mapping (like dm-crypt on a partition)
    • A stacked mapping (multiple DM layers)
  • Always check both high-level (lsblk) and low-level (dmsetup) views