dmsetup
Manage logical volumes with Device Mapper
SYNOPSIS
dmsetup [global_options] command [device_name...] [command_specific_arguments...]
PARAMETERS
-v, --verbose
Increases the verbosity of the output, providing more detailed information about operations and device states.
--version
Displays the version of the dmsetup command and exits.
-f, --noflush
When deactivating a device, this option prevents flushing outstanding I/O requests. This should be used with extreme caution, as it can lead to data loss or corruption if I/O operations are still pending on the device.
-r, --readonly
Opens devices in read-only mode where applicable, preventing any write operations.
-u, --uuid
Ensures that UUIDs (Universally Unique Identifiers) are displayed for devices when listing or querying information, providing a unique identifier for each device.
-j, --nouuid
Suppresses the display of UUIDs for devices, resulting in a more concise output.
-l, --nolocking
Disables LVM (Logical Volume Manager) locking. This is a highly dangerous option that should only be used in specific debugging scenarios by experienced administrators, as it can lead to race conditions and severe data corruption if multiple processes attempt to modify device-mapper configuration concurrently.
DESCRIPTION
dmsetup is a low-level utility designed for direct interaction with the Linux device-mapper kernel driver.
It enables users to create, remove, and manage virtual block devices, commonly referred to as "device-mapper devices" or "DM devices". These virtual devices translate I/O requests from a logical device to one or more underlying physical storage devices based on a defined "mapping table".
This sophisticated mechanism forms the backbone of numerous critical Linux storage technologies, including LVM (Logical Volume Manager) for flexible volume management, LUKS (Linux Unified Key Setup) for disk encryption, and multipath for I/O path redundancy.
While most users interact with higher-level tools (like lvcreate or cryptsetup) that abstract its complexity, dmsetup remains the fundamental utility for advanced diagnostics, debugging, and manual configuration of device-mapper constructs. It provides capabilities to inspect mapping tables, monitor device status, suspend/resume I/O, and send messages to device-mapper targets.
CAVEATS
dmsetup is a powerful, low-level tool that interacts directly with the Linux kernel's device-mapper subsystem.
Misuse of dmsetup commands, particularly those that modify device states or mapping tables, carries a significant risk of data loss, filesystem corruption, or system instability.
It requires root privileges to operate.
In most common use cases, higher-level management tools such as LVM (Logical Volume Manager) or cryptsetup are strongly recommended for managing device-mapper devices, as they provide safer abstractions and handle underlying complexities more robustly.
COMMON COMMANDS
The dmsetup utility supports a wide array of subcommands, each designed for a specific action on device-mapper devices. Essential subcommands include: create (to establish a new device-mapper device), remove (to destroy an existing device), info (to display general device information), table (to show the current mapping table of a device), status (to display I/O statistics and target-specific status), suspend (to temporarily halt I/O to a device), resume (to restart I/O), reload (to update a device's table without suspending I/O), and message (to send a control message to a device-mapper target). A solid understanding of these subcommands is critical for effective dmsetup usage, especially during advanced configuration or debugging.
MAPPING TABLES
At the core of every device-mapper device's functionality is its 'mapping table'. This table is a list of entries that define how logical blocks on the virtual device are translated and mapped to physical blocks on one or more underlying storage devices. Each entry in the table specifies a segment of the virtual device and how it corresponds to physical storage.
A typical table entry follows the format: `start_sector num_sectors target_type target_arguments`.
The `target_type` designates the kind of transformation or functionality for that specific segment (e.g., `linear` for a direct 1:1 mapping, `stripe` for RAID 0 functionality, `crypt` for encryption, `zero` for a block of zeros, `error` to simulate I/O errors). The `target_arguments` provide specific parameters relevant to the chosen target type, such as the path to the underlying physical device, its offset, or encryption keys.
HISTORY
The device-mapper subsystem was integrated into the Linux kernel beginning with version 2.4.10 (around 2001), establishing a flexible and extensible framework for virtual block devices.
dmsetup was subsequently developed as the primary user-space utility to control and interact with this kernel module. Its introduction revolutionized Linux's storage capabilities, enabling the robust implementation of advanced features like LVM2 (which superseded the `md/block` basis of LVM1), kernel-level disk encryption (via LUKS), and multi-path I/O. Since then, it has solidified its position as a foundational component of storage management across virtually all modern Linux distributions.
SEE ALSO
lvm(8), cryptsetup(8), multipath(8), kpartx(8), udevadm(8), lsblk(8)