Device Mapper

Device Mapper is a framework exposed by the Linux kernel for mapping block devices (devices that support reading and/or writing fixed-size blocks of data) to higher-level block devices, passing data from the high-level block device to another device. It allows the logical disk level to be decoupled from the underlying storage configuration.

Note that Device Mapper devices are managed by specialised system services like Logical Volume Manager. We don't manage them by hand.

Listing available targets

Targets provide different types of device mappings for Device Mapper. These can be listed as follows:

$ sudo dmsetup targets
crypt            v1.18.1
striped          v1.6.0
linear           v1.4.0
error            v1.5.0

Listing devices

Device Mapper devices known to the system can be listed as follows:

$ sudo dmsetup ls --tree --options blkdevname,device,uuid
my-encrypted-data-disk <dm-2> (253:2) [CRYPT-LUKS1-00000000000000000000000000000000-my-encrypted-data-disk]
 └─my-lvm-lv <dm-0> (253:0) [LVM-MuB51DT4gxmR1yU5eJlIO83n7pKAwNycYNGXjzaHc31a8IJi6iP9cuJKqb5lSNI0]
    ├─ <sde1> (8:65)
    └─ <sdd1> (8:49)
my-encrypted-os-disk <dm-1> (253:1) [CRYPT-LUKS1-00000000000000000000000000000001`-my-encrypted-os-disk]
 └─ <sda1> (8:1)

The tree format emphasises the dependencies between devices. In the above output:

  • dm-2 is a dm-crypt LUKS container inside of an LVM volume group called my-lvm-vg.
    • dm-0 is the LVM volume group.
      • sdd1 and sde1 contain LVM physical volumes backing the LVM volume group.
  • dm-1 is another LUKS container.
    • sda1 is the partition containing the operating system.

  1. LVM
  2. dm-crypt
  3. drbd