• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Examples of using dmsetup command in Linux

by admin

It is a command using which we can do low level logical volume management. So basically dmsetup is used to manage logical devices that use the device-mapper driver. The first argument to dmsetup is a command. The second argument is the logical device name or uuid.

The package which provides dmsetup command can be found out using:

# yum whatprovices /sbin/dmsetup
...

7:device-mapper-1.02.158-2.el7_7.2.x86_64 : Device mapper utility
Repo        : @updates
Matched from:
Filename    : /sbin/dmsetup

Examples of using dmsetup command

1. To list the device mapper devices:

# dmsetup ls 
# dmsetup ls
VG00-LV02       (253, 2)
VG00-LV01       (253, 1)
VG00-LV00       (253, 0)

2. To get information about any DM device:

# dmsetup info /dev/VG00/LV00 
# dmsetup info /dev/VG00/LV00
Name:              VG00-LV00
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        1
Event number:      0
Major, minor:      253, 0
Number of targets: 2
UUID: LVM-jUqeLC.....

3. To get DM device info in column wise:

# dmsetup info -c /dev/VG00/LV00
# dmsetup info -C /dev/VG00/LV00 
# dmsetup info -c /dev/VG00/LV00
Name             Maj Min Stat Open Targ Event  UUID
VG00-LV00        253   0 L--w    1    2      0 LVM-jUqeLvGB9........

4. To list the DM device dependencies:

# dmsetup deps /dev/VG00/LV00 
# dmsetup deps /dev/VG00/LV00
 2 dependencies  : (8, 48) (8, 32)

5. To get the status of a DM device:

# dmsetup status /dev/VG00/LV00 
# dmsetup status /dev/VG00/LV00
0 20963328 linear
20963328 8192 linear

6. To destroy the inactive table for a device:

# dmsetup clear /dev/VG00/LV00 

7. To send message to target:

# dmsetup device_name sector message
# dmsetup /dev/VG00/LV00 0 "My Logical device" 

8. To remove a device (this will cause data loss):

# dmsetup remove /dev/VG00/LV00 

9. To remove all the devices:

# dmsetup remove_all 

10. To rename the device:

# dmsetup /dev/VG00/LV00 /dev/VG00/LV04 

11. To suspend a device:

# dmsetup suspend --nolockfs /dev/VG00/LV00
# dmsetup suspend --noflush /dev/VG00/LV00

12. To un-suspend a device:

# dmsetup resume /dev/VG00/LV00 

13. To output the table for a device:

# dmsetup table /dev/VG00/LV00 
# dmsetup table /dev/VG00/LV00
0 20963328 linear 8:32 2048
20963328 8192 linear 8:48 2048

14. To get the dmsetup version info:

# dmsetup version 
# dmsetup version
Library version:   1.02.53 (2010-07-28)
Driver version:    4.17.0 

15. To display the help information:

# dmsetup -h

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 6 : How to disable Transparent Huge pages (THP)
  2. Set FTP Autologin with .netrc file in Linux
  3. Can’t start X11 applications after “su” or “su -” to another user
  4. DHCP configuration file /etc/dhcp/dhcpd.conf explained
  5. How to find and delete files older than some particular time period in Linux
  6. Configure VSFTPD Chroot Environment in CentOS and RHEL
  7. Linux OS Service ‘httpd’
  8. Magento 2.3.3 Redis cache grows unlimited
  9. CentOS / RHEL : How to extend Physical Volume in LVM by extending the Disk Partition used
  10. How to Use rpm2cpio Command in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright