Device mapper
| Company type | Kernel framework |
|---|---|
| Industry | Computer software |
| Headquarters | Linux kernel |
| Products | Virtual block device mapping, LVM, software RAID, disk encryption (dm-crypt), snapshots |
| Website | access |
The device mapper is a framework integrated within the Linux kernel that facilitates the creation of virtual block devices by mapping them onto underlying physical block devices. It serves as the foundation for essential storage solutions like the logical volume manager (LVM), software-based RAID, and disk encryption through dm-crypt, while also supporting capabilities such as file system snapshots.
This system functions by directing data traffic from virtual block devices to physical ones, with the capacity to alter data during transmission—an important feature for operations like disk encryption or emulating hardware characteristics.
Although this overview centers on the Linux kernel’s implementation, similar device mapper features exist in other operating systems such as NetBSD and DragonFly BSD.
Usage
Tools like LVM2 and the Enterprise Volume Management System (EVMS) utilize device mapper through the libdevmapper.so shared library, which communicates via ioctl commands sent to /dev/mapper/control. Users can configure and manage device mapper either interactively or through automation scripts using the provided utility.
The source code for both LVM2 and dmsetup is developed alongside the device mapper project, ensuring coordinated maintenance and feature enhancement.
Features
Device mapper offers a variety of mapping types including linear, striped, and error mappings, along with specialized targets such as cryptographic and multipath functionalities. For example, linear mappings allow combining two physical disks into a single logical volume. The crypt target leverages the Linux kernel's Crypto API to encrypt data.
Currently supported mapping targets include:
- cache — facilitates hybrid volumes by employing solid-state drives (SSDs) as cache layers for hard disk drives (HDDs)
- clone — permits usage of data before transfer completion
- crypt — provides encryption through the Linux kernel’s Crypto API
- delay — introduces artificial delays in read/write operations for testing purposes
- era — monitors blocks written over a user-specified timeframe
- error — simulates input/output errors to test system resilience
- flakey — mimics intermittent unreliable device behavior for diagnostic testing
- linear — maps continuous segments of blocks onto another device
- mirror — offers redundancy by mirroring data across disks
- multipath — manages devices with multiple paths using path groups
- raid — integrates with the Linux kernel’s software RAID driver (md)
- snapshot and snapshot-origin — enable LVM snapshot functionality using copy-on-write mechanisms
- striped — distributes data across multiple devices in configurable stripes and chunk sizes
- thin — creates virtual devices larger than actual storage by allocating space dynamically upon writes
- zero — emulates
/dev/zero, returning zeros on reads and ignoring writes
Applications
Key functionalities of the Linux kernel and notable projects utilizing the device mapper include:
- cryptsetup, a tool designed for configuring disk encryption that operates on top of dm-crypt
- dm-crypt combined with Linux Unified Key Setup (LUKS), a device mapper target enabling encrypted volumes
- dm-cache, which facilitates the creation of hybrid storage volumes
- dm-integrity, providing data verification through checksums or cryptographic methods, also integrated with LUKS
- dm-log-writes, a feature that records write operations on a secondary device while forwarding them to the primary device
- dm-verity, used to verify filesystem data blocks against cryptographic hashes, initially developed for ChromiumOS
- Support for accessing "fake" RAID configurations through the device mapper interface
- DM Multipath, a Linux kernel component offering input/output failover and load balancing for block devices
- Docker, which leverages device mapper technology to implement copy-on-write storage for container environments
- DRBD (Distributed Replicated Block Device)
- EVMS (Enterprise Volume Management System), now deprecated
- A utility triggered by hotplug events to manage device maps
- LVM2, the Linux kernel’s logical volume management solution
- VeraCrypt, the Linux-compatible version of TrueCrypt encryption software
- VDO (Virtual Data Optimizer)
External links
- Official Device Mapper page at Red Hat
- – article demonstrating various device mapper targets
- Userspace utility for configuring software RAID with multiple metadata formats
- Overview of Multipath support in Device Mapper, LWN.net, February 23, 2005, authored by Jonathan Corbet