• 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

mdadm: Cannot open /dev/sda1: Device or resource busy

by admin

The Problem

When trying to re-add a device to a raid, you get the following message:

# mdadm /dev/md2 --add /dev/sda1
mdadm: Cannot open /dev/sda1: Device or resource busy

Whereas the mdstat command indicates that the device is inactive.

# cat /proc/mdstat
Personalities :
md2 : inactive sda1[0](S)
      292928154 blocks super 1.2

unused devices: [none]

mdadm fail to create software raid device with Device or resource busy error message.

The solution

Pre-checks

Before we proceed, make sure that if partitions were part of any active FS.

mdadm --detail /dev/md2
mdadm: md device /dev/md2 does not appear to be active.
mdadm --detail --scan >> /etc/mdadm.conf
mdadm: md device /dev/md2 does not appear to be active.
# ls -l /etc/mdadm.conf
-rw-r--r-- 1 root bin 0 Sep 18 21:17 /etc/mdadm.conf
# cat /etc/mdadm.conf

The cause of issue

The cause of this issue can be that the device-mapper-multipath ( or other device-mapper modules ) has control over this device, therefore mdadm cannot access it. The command “dmsetup table” will show that this devices is controlled by the device-mapper ( see “man dmsetup” for more detailed information )

# dmsetup table

Workaround

As a workaround you can remove the device from the device-mapper table with the below command.

# dmsetup remove [device id]

Permanent solution

As a solution you can either start your server without certain device-mapper modules, for example dmraid you can add “nodmraid” to the kernel command line in /etc/grub.conf as shown below.

title Enterprise Linux Enterprise Linux Server (2.6.32-100.24.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-100.24.1.el5 ro root=/dev/vg00/lv00 console=tty0 nodmraid
        initrd /initrd-2.6.32-100.24.1.el5.img

or if device-mapper-multipath has control over this device you can add it to the blacklist section in /etc/multipath.conf

# vi /etc/multipath.conf
blacklist {

              wwid [your world-wide-id for this device]

}

Reload the multipathd for changes to take effect:

# service multipathd reload
# multipath -v2

Make sure multipath does not create maps for these devices in ‘multipath -ll’.

# multipath -ll

The device-mapper should not take control at boot time.

Verify

Once you have performed the steps mentioned above, you should be ableto create the software RAID. To verify:

# mdadm /dev/md2 --add /dev/sda1

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. dmesg Command Examples in Linux
  2. Linux OS Service ‘cups’
  3. Command line parameters in shell scripts
  4. How to Restart Network Services in CentOS/RHEL 8
  5. How to Configure a Fiber-Channel Over Ethernet (FCoE) Interface in CentOS/RHEL
  6. CentOS / RHEL 7 : Chrony V/s NTP (Differences Between ntpd and chronyd)
  7. Common Init.ora Parameters and Unix, Linux Kernel Parameters and Relationship Between Them
  8. How to check failed or bad login attempts in Linux
  9. lvresize command examples in Linux
  10. How to Customize Linux Password Expiration and Complexity Requirements

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright