dmsetup

storageLinux/Unix
The dmsetup command is one of the most frequently used commands in Linux/Unix-like operating systems. dmsetup Low-level logical volume management tool for Device Mapper

Quick Reference

Command Name:

dmsetup

Category:

storage

Platform:

Linux/Unix

Basic Usage:

dmsetup [options] [arguments]

Common Use Cases

    Syntax

    dmsetup [options] [command] [command_args]

    Options

    Option Description
    --addnodeoncreate Add device node on create
    --checks Perform additional checks on the table
    --noudevsync Disable udev synchronization
    --readahead [+]sectors|auto|none Set device read ahead
    --table table Specify table directly on the command line
    --uuid uuid Specify UUID directly on the command line
    --verifyudev Verify udev operations
    -v, --verbose Verbose output

    Examples

    How to Use These Examples

    The examples below show common ways to use the dmsetup command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    dmsetup info
    Display information about all Device Mapper devices.
    dmsetup ls
    List all mapped devices.
    dmsetup status
    Show status of all mapped devices. # Advanced Examples Advanced dmsetup create test --table "0 1000000 linear /dev/sda 0" Create a new device mapping. dmsetup remove test Remove a device mapping. dmsetup suspend vg-lv Suspend I/O to a device. dmsetup resume vg-lv Resume I/O to a suspended device. dmsetup table vg-lv Show the table for a device.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    Dmsetup Command Overview: The dmsetup command is a low-level tool used to manage logical devices that use the Device Mapper (DM) framework. Device Mapper is a Linux kernel framework that provides a generic way to create virtual layers of block devices. It's the foundation for Logical Volume Management (LVM), software RAID, and other advanced storage technologies. Key Features: - Creates, removes, and modifies device mappings - Displays information about mapped devices - Suspends and resumes I/O to devices - Manages device tables and targets - Supports various Device Mapper targets (linear, striped, mirror, etc.) Common Device Mapper Targets: - linear: Maps linear ranges of a device - striped: Stripes data across multiple devices - mirror: Mirrors data across multiple devices - snapshot: Creates point-in-time copies of devices - error: Returns errors on any I/O operation - zero: Returns blocks of zeros on reads - crypt: Provides transparent encryption (used by dm-crypt) - multipath: Provides I/O failover and load balancing Relationship to LVM: LVM (Logical Volume Manager) uses Device Mapper as its underlying framework. The dmsetup tool provides direct access to Device Mapper functionality, while LVM commands (like lvcreate, lvremove) provide a higher-level interface. When to Use Dmsetup: - Debugging LVM issues - Creating custom device mappings - Performing advanced storage operations - Managing device mappings directly - Recovering from LVM problems This command is primarily used by system administrators and storage specialists who need fine-grained control over block device management.

    Related Commands

    These commands are frequently used alongside dmsetup or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the dmsetup command works in different scenarios.

    $ dmsetup
    View All Commands