Device mapper: Difference between revisions
m →Applications: clean up; http->https or pr-URI, per VPP using AWB |
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5 |
||
(75 intermediate revisions by 37 users not shown) | |||
Line 1: | Line 1: | ||
{{Short description|Software framework of Linux kernel}} |
|||
The '''device mapper''' is a [[Linux kernel]] [[Software framework|framework]] for mapping block devices onto higher-level virtual block devices. It forms the foundation of [[LVM2]], software [[RAID]]s, [[dm-crypt]] disk encryption, and offers additional features such as file system [[Snapshot (computer storage)|snapshots]].<ref name="redhat-dm">{{cite web |
|||
The '''device mapper''' is a [[Software framework|framework]] provided by the [[Linux kernel]] for mapping physical [[block device]]s onto higher-level ''virtual block devices''. It forms the foundation of the [[logical volume manager]] (LVM), software [[RAID]]s and [[dm-crypt]] disk encryption, and offers additional features such as file system [[Snapshot (computer storage)|snapshots]].<ref name="redhat-dm">{{cite web |
|||
| url = https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/device_mapper.html |
| url = https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/device_mapper.html |
||
| title = Logical Volume Manager Administration |
| title = Logical Volume Manager Administration, Appendix A. The Device Mapper |
||
| access-date = 2013-09-29 |
|||
| work = Appendix A. The Device Mapper |
|||
| accessdate = 2013-09-29 |
|||
| publisher = [[Red Hat]] |
| publisher = [[Red Hat]] |
||
}}</ref> |
}}</ref> |
||
Device mapper works by passing data from a virtual |
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 hardware behavior. |
||
This article focuses on the device mapper implementation in the Linux kernel, but the device mapper functionality is also available in both [[NetBSD]] and [[DragonFly BSD]].<ref>{{cite web |
|||
| url = http://netbsd.gw.com/cgi-bin/man-cgi?dm+4+NetBSD-current |
|||
| title = NetBSD Kernel Interfaces Manual: dm(4) |
|||
| date = 2008-08-30 |
|||
| access-date = 2015-01-25 |
|||
| website = netbsd.gw.com |
|||
| archive-date = 2014-07-19 |
|||
| archive-url = https://web.archive.org/web/20140719152701/http://netbsd.gw.com/cgi-bin/man-cgi?dm+4+NetBSD-current |
|||
| url-status = dead |
|||
}}</ref><ref>{{cite web |
|||
| url = http://leaf.dragonflybsd.org/cgi/web-man?command=dm§ion=4 |
|||
| title = DragonFly On-Line Manual Pages: dm(4) |
|||
| date = 2010-07-28 | access-date = 2014-06-06 |
|||
| website = dragonflybsd.org |
|||
}}</ref> |
|||
== Usage == |
== Usage == |
||
Applications (like [[LVM2]] and [[Enterprise Volume Management System |
Applications (like [[LVM2]] and [[Enterprise Volume Management System]] (EVMS)) that need to create new mapped devices talk to the device mapper via the <code>libdevmapper.so</code> [[Library (computer science)|shared library]], which in turn issues [[ioctl]]s to the <code>/dev/mapper/control</code> [[device node]].<ref>{{cite web |
||
| url = http://www.sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/LVM2/libdm/libdevmapper.h?content-type=text/plain&cvsroot=lvm2 |
| url = http://www.sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/LVM2/libdm/libdevmapper.h?content-type=text/plain&cvsroot=lvm2 |
||
| title = libdevmapper.h |
| title = libdevmapper.h |
||
| |
| access-date = 2013-09-29 |
||
| publisher = sourceware.org |
| publisher = sourceware.org |
||
}}</ref> Configuration of the device mapper can be also examined and configured interactively |
}}{{Dead link|date=March 2023 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> Configuration of the device mapper can be also examined and configured interactively{{mdashb}}or from [[shell script]]s{{mdashb}}by using the {{man|8|dmsetup|man.cx||inline}} utility.<ref name="dmsetup-man">{{cite web |
||
| url = http://man.cx/?page=dmsetup%288%29 |
| url = http://man.cx/?page=dmsetup%288%29 |
||
| title = dmsetup(8) - Linux man page |
| title = dmsetup(8) - Linux man page |
||
| |
| access-date = 2013-10-22 |
||
| publisher = man.cx |
| publisher = man.cx |
||
}}</ref><ref>{{cite web |
}}</ref><ref>{{cite web |
||
Line 24: | Line 40: | ||
| title = Logical Volume Manager Administration |
| title = Logical Volume Manager Administration |
||
| work = Appendix A.2. The dmsetup Command |
| work = Appendix A.2. The dmsetup Command |
||
| |
| access-date = 2013-09-29 |
||
| publisher = [[Red Hat]] |
| publisher = [[Red Hat]] |
||
}}</ref> |
}}</ref> |
||
Both of these two userspace components |
Both of these two userspace components have their source code maintained alongside the LVM2 source.<ref>{{cite web |
||
| url = http://www.sourceware.org/dm/ |
| url = http://www.sourceware.org/dm/ |
||
| title = Device-mapper Resource Page |
| title = Device-mapper Resource Page |
||
| |
| access-date = 2013-09-29 |
||
| publisher = sourceware.org |
| publisher = sourceware.org |
||
}}</ref> |
}}</ref> |
||
== Features == |
== Features == |
||
[[File:The Linux Storage Stack Diagram.svg|thumb|right|upright=2.0|The position of the device mapper targets within various layers of the [[Linux kernel]]'s storage stack.<ref>{{Cite web |
|||
{{See also|dm-crypt|dm-cache}} |
|||
| url = https://www.thomas-krenn.com/en/wiki/Linux_Storage_Stack_Diagram |
|||
| title = Linux Storage Stack Diagram |
|||
| date = 2015-06-01 | access-date = 2015-06-08 |
|||
| author1 = Werner Fischer | author2 = Georg Schönberger |
|||
| publisher = Thomas-Krenn.AG |
|||
}}</ref>]] |
|||
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 (Linux)|Crypto API]].<ref name="redhat-dm" /> |
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 (Linux)|Crypto API]].<ref name="redhat-dm" /> |
||
{{As of|2014}}, the following mapping targets are available:<ref name="redhat-dm" /><ref name="dmsetup-man" /> |
|||
* '''linear''': maps a continuous range of blocks onto another block device |
|||
* '''striped''': strips the data across physical devices, with the number of stripes and the striping chunk size as parameters |
|||
* '''mirror''': mapping of a [[Disk mirroring|mirrored]] logical device, providing data redundancy |
|||
* '''snapshot''' and '''snapshot-origin''': used for creation of LVM snapshots, as part of the underlining copy-on-write scheme |
|||
* '''zero''': equivalent of <code>/dev/zero</code> — all reads return blocks of zeros, and writes are discarded |
|||
* '''multipath''': supports the mapping of [[Multipath I/O|multipathed]] devices, through usage of their path groups |
|||
* '''[[dm-crypt|crypt]]''': provides data encryption, by using the Linux kernel's [[Crypto API (Linux)|Crypto API]] |
|||
* '''[[dm-cache|cache]]''': allows creation of [[hybrid drive]]s, by using [[SSD]]s as caches for hard drives |
|||
* '''raid''': offers an interface to the Linux kernel's [[software RAID]] driver ([[mdadm|md]]) |
|||
* '''error''': simulates I/O errors for all mapped blocks (used for testing) |
|||
* '''flakey''': simulates periodic unreliable behaviour (used for testing) |
|||
* '''delay''': delays reads and/or writes to different devices (used for testing). |
|||
* ''[[dm-cache|cache]]''{{snd}} allows creation of [[hybrid volume]]s, by using [[solid-state drive]]s (SSDs) as caches for [[hard disk drive]]s (HDDs) |
|||
== Applications == |
|||
* ''clone''{{snd}} will permit usage before a transfer is complete. |
|||
The following features and projects are relying on the device mapper: |
|||
* [[ |
* ''[[dm-crypt|crypt]]''{{snd}} provides data encryption, by using the Linux kernel's [[Crypto API (Linux)|Crypto API]] |
||
* ''delay''{{snd}} delays reads and/or writes to different devices (used for testing) |
|||
* [[dm-crypt]] (mapping target providing encryption of volumes) |
|||
* ''era''{{snd}} 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<ref>{{cite web |
|||
* [[dm-cache]] (mapping target allowing creation of [[Hybrid drive#DUALDRIVE|hybrid volumes]]) |
|||
| url = http://kernelnewbies.org/Linux_3.15#head-33ab227d4984f4be9fa92f9163e403744e2a8f66 |
|||
* [https://code.google.com/p/cryptsetup/wiki/DMVerity dm-verity] (block integrity checking target, designed and developed as part of the [[Chrome OS]]) |
|||
| title = 6. Block layer | work = Linux kernel 3.15 |
|||
* {{man|8|dmraid|man.cx||inline}} (providing access to [[RAID|"fake" RAID]] configurations via the device mapper) |
|||
| date = 2014-06-08 | access-date = 2014-06-15 |
|||
* [[Linux DM Multipath|DM Multipath]] (I/O fail-over and load-balancing within Linux kernel for block devices) |
|||
| publisher = kernelnewbies.org |
|||
* Linux version of [[TrueCrypt]] |
|||
}}</ref> |
|||
* ''error''{{snd}} simulates I/O errors for all mapped blocks (used for testing) |
|||
* ''flakey''{{snd}} simulates periodic unreliable behaviour (used for testing) |
|||
* ''linear''{{snd}} maps a continuous range of blocks onto another block device |
|||
* ''mirror''{{snd}} maps a [[Disk mirroring|mirrored]] logical device, while providing data redundancy |
|||
* ''[[Linux DM Multipath|multipath]]''{{snd}} supports the mapping of [[Multipath I/O|multipathed]] devices, through usage of their path groups |
|||
* ''raid''{{snd}} offers an interface to the Linux kernel's [[software RAID]] driver ([[mdadm|md]]) |
|||
* ''snapshot'' and ''snapshot-origin''{{snd}} used for creation of LVM snapshots, as part of the underlying copy-on-write scheme |
|||
* ''striped''{{snd}} stripes the data across physical devices, with the number of stripes and the striping chunk size as parameters |
|||
* ''thin'' {{snd}} allows creation of devices larger than the underlying physical device, physical space is allocated only when written to |
|||
* ''zero''{{snd}} an equivalent of <code>/dev/zero</code>, all reads return blocks of zeros, and writes are discarded |
|||
== {{Anchor|DM-LOG-WRITES|DM-VERITY}}Applications == |
|||
Linux kernel features and projects built on top of the device mapper include the following: |
|||
* [[cryptsetup]]{{snd}} utility used to conveniently setup disk encryption based on dm-crypt |
|||
* [[dm-crypt]]/[[Linux Unified Key Setup|LUKS]]{{snd}} mapping target that provides volume encryption |
|||
* [[dm-cache]]{{snd}} mapping target that allows creation of [[Hybrid drive#DUALDRIVE|hybrid volumes]] |
|||
* dm-integrity{{snd}} mapping target that provides [[data integrity]], either using checksumming or cryptographic verification,<ref>{{cite web |
|||
| url = https://gitlab.com/cryptsetup/cryptsetup/wikis/DMIntegrity |
|||
| title = dm-integrity |
|||
| date = 2018-04-30 | access-date = 2018-05-08 |
|||
| publisher = cryptosetup project |
|||
}}</ref><ref>{{cite web |
|||
| url = https://www.kernel.org/doc/Documentation/device-mapper/dm-integrity.txt |
|||
| title = dm-integrity target |
|||
| date = 2017-05-13 | access-date = 2018-05-08 |
|||
| publisher = [[kernel.org]] |
|||
}}</ref> also used with LUKS<ref>{{cite web |
|||
| url = https://man.cx/?page=cryptsetup(8) |
|||
| title = cryptsetup - manage plain dm-crypt and LUKS encrypted volumes |
|||
| date = 2018-01-01 | access-date = 2018-05-08 |
|||
}}</ref> |
|||
* dm-log-writes{{snd}} mapping target that uses two devices, passing through the first device and logging the write operations performed to it on the second device<ref>{{cite web |
|||
| url = https://www.kernel.org/doc/Documentation/device-mapper/log-writes.txt |
|||
| title = Linux kernel documentation: Documentation/device-mapper/log-writes.txt |
|||
| date = 2015-05-29 | access-date = 2015-10-13 |
|||
| publisher = [[kernel.org]] |
|||
}}</ref> |
|||
* dm-verity{{snd}} validates the data blocks contained in a file system against a list of cryptographic hash values, developed as part of the [[ChromiumOS]] project<ref>{{cite web |
|||
| url = https://lwn.net/Articles/459420/ |
|||
| title = dm-verity |
|||
| date = 2011-09-19 | access-date = 2015-10-13 |
|||
| author = Jonathan Corbet | publisher = [[LWN.net]] |
|||
}}</ref> |
|||
* {{man|8|dmraid|man.cx||inline}}{{snd}} provides access to [[RAID|"fake" RAID]] configurations via the device mapper |
|||
* [[Linux DM Multipath|DM Multipath]]{{snd}} provides I/O failover and load-balancing of block devices within the Linux kernel |
|||
* [[Docker (software)|Docker]]{{snd}} uses device mapper to create copy-on-write storage for software containers |
|||
* [[DRBD]] (Distributed Replicated Block Device) |
* [[DRBD]] (Distributed Replicated Block Device) |
||
* {{man|8|kpartx|man.cx||inline}} (utility called from hotplug upon device maps creation and deletion) |
|||
* [[Enterprise Volume Management System|EVMS]] (deprecated) |
* [[Enterprise Volume Management System|EVMS]] (deprecated) |
||
* {{man|8|kpartx|man.cx||inline}}{{snd}} utility called from hotplug upon device maps creation and deletion |
|||
* [[cryptoloop]] (deprecated) |
|||
* [[LVM2]]{{snd}} [[logical volume management|logical volume manager]] for the Linux kernel |
|||
* [[VeraCrypt]] - Linux version of [[TrueCrypt]] |
|||
*VDO - Virtual Data Optimizer |
|||
== References == |
== References == |
||
{{ |
{{Reflist|30em}} |
||
== External links == |
== External links == |
||
* [http://sources.redhat.com/dm/ Device mapper home at Red Hat] |
* [http://sources.redhat.com/dm/ Device mapper home at Red Hat] {{Webarchive|url=https://web.archive.org/web/20060315124752/http://sources.redhat.com/dm/ |date=2006-03-15 }} |
||
* {{cite web | url=http://linuxgazette.net/114/kapil.html |
* {{cite web | url=http://linuxgazette.net/114/kapil.html | title=Right To Your Own Devices | work = [[Linux Gazette]] | date = May 2005 |
||
}}{{snd}} an article illustrating the use of various device mapper targets |
|||
| title=Right To Your Own Devices | work = [[Linux Gazette]] |date=May 2005 |
|||
}} — an article that illustrates the use of various device-mapper targets |
|||
* [http://people.redhat.com/~heinzm/sw/dmraid/readme userspace tool to set up software RAID using various RAID metadata formats] |
* [http://people.redhat.com/~heinzm/sw/dmraid/readme userspace tool to set up software RAID using various RAID metadata formats] |
||
* [ |
* [https://lwn.net/Articles/124703/ Multipath support in the device mapper], [[LWN.net]], February 23, 2005, by Jonathan Corbet |
||
{{Clear}} |
|||
{{Linux kernel}} |
{{Linux kernel}} |
||
{{Linux}} |
|||
{{Operating system}} |
|||
[[Category: |
[[Category:Device mapper| ]] |
||
[[Category:Red Hat software]] |
Latest revision as of 13:40, 29 January 2024
The device mapper is a framework provided by the Linux kernel for mapping physical block devices onto higher-level virtual block devices. It forms the foundation of the logical volume manager (LVM), software RAIDs and 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 hardware behavior.
This article focuses on the device mapper implementation in the Linux kernel, but the device mapper functionality is also available in both NetBSD and DragonFly BSD.[2][3]
Usage
[edit]Applications (like LVM2 and Enterprise Volume Management System (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.[4] Configuration of the device mapper can be also examined and configured interactively—or from shell scripts—by using the utility.[5][6]
Both of these two userspace components have their source code maintained alongside the LVM2 source.[7]
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]
As of 2014[update], the following mapping targets are available:[1][5]
- cache – allows creation of hybrid volumes, by using solid-state drives (SSDs) as caches for hard disk drives (HDDs)
- clone – will permit usage before a transfer is complete.
- 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[9]
- 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 underlying copy-on-write scheme
- striped – stripes the data across physical devices, with the number of stripes and the striping chunk size as parameters
- thin – allows creation of devices larger than the underlying physical device, physical space is allocated only when written to
- zero – an equivalent of
/dev/zero
, all reads return blocks of zeros, and writes are discarded
Applications
[edit]Linux kernel features and projects built on top of the device mapper include the following:
- cryptsetup – utility used to conveniently setup disk encryption based on dm-crypt
- dm-crypt/LUKS – mapping target that provides volume encryption
- dm-cache – mapping target that allows creation of hybrid volumes
- dm-integrity – mapping target that provides data integrity, either using checksumming or cryptographic verification,[10][11] also used with LUKS[12]
- dm-log-writes – mapping target that uses two devices, passing through the first device and logging the write operations performed to it on the second device[13]
- dm-verity – validates the data blocks contained in a file system against a list of cryptographic hash values, developed as part of the ChromiumOS project[14]
- "fake" RAID configurations via the device mapper – provides access to
- DM Multipath – provides I/O failover and load-balancing of block devices within the Linux kernel
- Docker – uses device mapper to create copy-on-write storage for software containers
- DRBD (Distributed Replicated Block Device)
- EVMS (deprecated)
- – utility called from hotplug upon device maps creation and deletion
- LVM2 – logical volume manager for the Linux kernel
- VeraCrypt - Linux version of TrueCrypt
- VDO - Virtual Data Optimizer
References
[edit]- ^ a b c "Logical Volume Manager Administration, Appendix A. The Device Mapper". Red Hat. Retrieved 2013-09-29.
- ^ "NetBSD Kernel Interfaces Manual: dm(4)". netbsd.gw.com. 2008-08-30. Archived from the original on 2014-07-19. Retrieved 2015-01-25.
- ^ "DragonFly On-Line Manual Pages: dm(4)". dragonflybsd.org. 2010-07-28. Retrieved 2014-06-06.
- ^ "libdevmapper.h". sourceware.org. Retrieved 2013-09-29.[permanent dead link ]
- ^ a b "dmsetup(8) - Linux man page". man.cx. Retrieved 2013-10-22.
- ^ "Logical Volume Manager Administration". Appendix A.2. The dmsetup Command. Red Hat. Retrieved 2013-09-29.
- ^ "Device-mapper Resource Page". sourceware.org. Retrieved 2013-09-29.
- ^ Werner Fischer; Georg Schönberger (2015-06-01). "Linux Storage Stack Diagram". Thomas-Krenn.AG. Retrieved 2015-06-08.
- ^ "6. Block layer". Linux kernel 3.15. kernelnewbies.org. 2014-06-08. Retrieved 2014-06-15.
- ^ "dm-integrity". cryptosetup project. 2018-04-30. Retrieved 2018-05-08.
- ^ "dm-integrity target". kernel.org. 2017-05-13. Retrieved 2018-05-08.
- ^ "cryptsetup - manage plain dm-crypt and LUKS encrypted volumes". 2018-01-01. Retrieved 2018-05-08.
- ^ "Linux kernel documentation: Documentation/device-mapper/log-writes.txt". kernel.org. 2015-05-29. Retrieved 2015-10-13.
- ^ Jonathan Corbet (2011-09-19). "dm-verity". LWN.net. Retrieved 2015-10-13.
External links
[edit]- Device mapper home at Red Hat Archived 2006-03-15 at the Wayback Machine
- "Right To Your Own Devices". Linux Gazette. May 2005. – an article illustrating the use of various device mapper targets
- userspace tool to set up software RAID using various RAID metadata formats
- Multipath support in the device mapper, LWN.net, February 23, 2005, by Jonathan Corbet