• 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. Nginx load balancing
  2. dmidecode Command Examples in Linux
  3. How to Set Resource Limits for a Process with Systemd in CentOS/RHEL 7 and 8
  4. How to avoid ssh from prompting key passphrase for passwordless logins
  5. CentOS / RHEL : How to configure alias (virtual interface) of bond interface (bondx:y)
  6. physlock: command not found
  7. Troubleshooting common NFS issues in Linux
  8. hcitool: command not found
  9. tvservice: command not found
  10. How To Create Virtual Data Optimizer(VD0) in CentOS/RHEL 7 and 8

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright