LinuxCommandLibrary

dmsetup

Manage logical volumes with Device Mapper

SYNOPSIS

dmsetup [options] command [arguments]

PARAMETERS

--commandprofile, -C ProfileConfigFile
    Profile config file for commands

--configfile, -c ConfigFile
    Alternative config file

--devicesfile DevicesFile
    File listing devices

-d, --debug {0|1|2}
    Debug logging level

--exec ExecMode
    Execution mode

-h, --help
    Display help

--helpdistro
    Distro-specific help

--inactive
    Use inactive table for operations

-i, --interval Seconds
    Status poll interval

--major Major
    Specify major device number

--minor Minor
    Specify minor device number

--multipath PMpath_table
    Multipath table file

-n, --nameprefix Prefix
    Prefix for device names

--nocreatemind
    Skip 'device exists' check

-o, --options Opt_string
    Table line options

-r, --readonly
    Open devices readonly

--rootowner
    Set root ownership

--setkeys
    Reconfigure live table keys

--sorttable
    Sort table lines

--tableloader LoaderType
    Table loader type

-t, --type Type
    Target type filter

-u, --uuid UUID
    Specify device UUID

-U, --uid UID
    Set UID for device

-v, --verbose [{0|1|2}]
    Verbose output level

--version, -V
    Display version

-y, --yes
    Confirm yes automatically

-z, --missing
    Show missing devices

DESCRIPTION

dmsetup is a userspace command-line utility for administering the Linux kernel's device-mapper (dm) driver, which enables the creation of virtual block devices layered on top of physical or other virtual devices.

This allows advanced storage features such as logical volume management (LVM), snapshots, device-mapper crypt (dm-crypt) for encryption, thin provisioning (dm-thin), multipath I/O (dm-multipath), RAID (dm-raid), and verity (dm-verity).

Key operations include creating mapped devices from transformation tables (create), loading/reloading tables (load), removing devices (remove), displaying status (status), listing devices (ls), and querying info (info). Tables define how logical sectors map to underlying devices, supporting linear, striped, mirrored, or custom mappings.

dmsetup is essential for low-level control; higher-level tools like LVM2's lvcreate(8) use it internally. Mapped devices appear as /dev/mapper/<name> or /dev/dm-N. Requires root privileges; misuse risks data corruption.

CAVEATS

Requires root privileges. Incorrect table specifications or device removal can cause data loss or system instability. Test in safe environments; backup data first. Devices must not be in use during certain operations like remove_all.

COMMON COMMANDS

create name table - Create device from table
load name --tableload table_file - Load table
remove name - Remove device
ls [--target type] - List devices
status [name] - Show status
info name - Device info
table name - Show table

TABLE FORMAT

Tables: start length type params
Example: 0 40960000 linear /dev/sda1 0
Use dmsetup table to inspect.

HISTORY

Developed as part of the LVM2 project starting around 2003; device-mapper kernel support merged in Linux 2.6.9 (2004). Evolved with kernel features like dm-cache, dm-thin (2.6.33+), and ongoing enhancements for NVMe, integrity.

SEE ALSO

lvcreate(8), cryptsetup(8), multipath(8), pvs(8), vgs(8), lvs(8)

Copied to clipboard