Redhat Link:- Cannot run devicemapper commands

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 5

Issue

  • Getting the below error while running commands.
# dmsetup ls
/dev/mapper/control: open failed: No such device
Failure to communicate with kernel device-mapper driver.
Check that device-mapper is available in the kernel.
Incompatible libdevmapper 1.02.135-RHEL7 (2016-11-16) and kernel driver (unknown version).

# lvscan
  /dev/mapper/control: open failed: No such device
  Failure to communicate with kernel device-mapper driver.
  Check that device-mapper is available in the kernel.
  Incompatible libdevmapper 1.02.135-RHEL7 (2016-11-16) and kernel driver (unknown version).
  inactive          '/dev/testvg/testlv' [100.00 GiB] inherit

Resolution

  • Reinstall the kernel
#  yum reinstall <affected-kernel>
  • Check if the right ko files are present, rebuild modules.dep if necessary.
# depmod -a
# depmod -a <kernel-version>
Example: 
# depmod -a 3.10.0-514.16.1.el7

Root Cause

  • The device mapper kernel modules aren’t loaded which are necessary for the commands to run.

Diagnostic Steps

  • Check if the necessary modules are loaded and present on the system.
# cat lsmod | grep -i dm_ | wc -l
0
  • Try to load modules manually since this module is currently not loaded in the system and monitor for errors.
#  modprobe -v dm_mod 
#  modprobe -v dm_log
#  modprobe -v dm_region_hash
  • Check for inconsistencies in system files and binaries on the system.
#  rpm -Va > /tmp/rpm.out
  • Check if the affected module entries are present in modules.dep and modules.alias file inside /lib/modules/<kernel>/