Device mapper

From Wikipedia, the free encyclopedia
Jump to: navigation, search

The device mapper is a Linux kernel's framework for mapping physical block devices onto higher-level virtual block devices. It forms the foundation of LVM2, software RAIDs, dm-crypt disk encryption, and offers additional features such as file system snapshots.[1]

Device mapper works by passing data from a virtual block device, which is provided by the device mapper itself, to another block device. Data can be also modified in transition, which is performed, for example, in the case of device mapper providing disk encryption or simulation of unreliable behavior.

While this article focuses on the Linux kernel's implementation, the device mapper functionality is also available in DragonFly BSD.[2]

Usage[edit]

Applications (like LVM2 and EVMS) that need to create new mapped devices talk to the device mapper via the libdevmapper.so shared library, which in turn issues ioctls to the /dev/mapper/control device node.[3] Configuration of the device mapper can be also examined and configured interactively—​or from shell scripts—​by using the dmsetup(8) utility.[4][5]

Both of these two userspace components have their source code maintained alongside the LVM2 source.[6]

Features[edit]

Functions provided by the device mapper include linear, striped and error mappings, as well as crypt and multipath targets. For example, two disks may be concatenated into one logical volume with a pair of linear mappings, one for each disk. As another example, crypt target encrypts the data passing through the specified device, by using the Linux kernel's Crypto API.[1]

The following mapping targets are available:[1][4]

  • cache – allows creation of hybrid volumes, by using solid-state drives (SSDs) as caches for hard disk drives (HDDs)
  • crypt – provides data encryption, by using the Linux kernel's Crypto API
  • delay – delays reads and/or writes to different devices (used for testing)
  • era – behaves in a way similar to the linear target, while it keeps track of blocks that were written to within a user-defined period of time[7]
  • error – simulates I/O errors for all mapped blocks (used for testing)
  • flakey – simulates periodic unreliable behaviour (used for testing)
  • linear – maps a continuous range of blocks onto another block device
  • mirror – maps a mirrored logical device, while providing data redundancy
  • multipath – supports the mapping of multipathed devices, through usage of their path groups
  • raid – offers an interface to the Linux kernel's software RAID driver (md)
  • snapshot and snapshot-origin – used for creation of LVM snapshots, as part of the underlining copy-on-write scheme
  • striped – strips the data across physical devices, with the number of stripes and the striping chunk size as parameters
  • zero – an equivalent of /dev/zero, all reads return blocks of zeros, and writes are discarded

Applications[edit]

The following Linux kernel features and projects are relying on the device mapper:

References[edit]

  1. ^ a b c "Logical Volume Manager Administration, Appendix A. The Device Mapper". Red Hat. Retrieved 2013-09-29. 
  2. ^ "DragonFly On-Line Manual Pages: dm(4)". dragonflybsd.org. 2010-07-28. Retrieved 2014-06-06. 
  3. ^ "libdevmapper.h". sourceware.org. Retrieved 2013-09-29. 
  4. ^ a b "dmsetup(8) - Linux man page". man.cx. Retrieved 2013-10-22. 
  5. ^ "Logical Volume Manager Administration". Appendix A.2. The dmsetup Command. Red Hat. Retrieved 2013-09-29. 
  6. ^ "Device-mapper Resource Page". sourceware.org. Retrieved 2013-09-29. 
  7. ^ "6. Block layer". Linux kernel 3.15. kernelnewbies.org. 2014-06-08. Retrieved 2014-06-15. 

External links[edit]