Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Problem:

# ls /dev/md*
/dev/md0  /dev/md1

# dd if=/dev/zero of=/dev/sdb3 bs=1M count=1
# dd if=/dev/zero of=/dev/sdd3 bs=1M count=1
# mdadm --zero-superblock /dev/sdb3
# mdadm --zero-superblock /dev/sdd3

# mdadm --create -l 1 -n 2 /dev/md2 /dev/sdb3 /dev/sdd3
mdadm: cannot open /dev/sdb3: Device or resource busy

# ls /dev/md*
/dev/md0  /dev/md1  /dev/md127  /dev/md2

# mdadm -D /dev/md127
mdadm: md device /dev/md127 does not appear to be active.

I did not ask it to auto detect and assemble anything. I didn't reboot either.

I moved around partitions many times on these disks to try different setups. So there are probably traces of those experiments things everywhere.

sdb3 is not busy. I just created it seconds before like this:

swapoff -a
parted /dev/sdb rm 4        (my old raid10 + lvm)
parted /dev/sdb rm 3        (my old swap)
parted /dev/sdd unit s mkpart root4 503808 5860533118 (start here is same as swap start, and end is same as raid10+lvm end)
parted /dev/sdd set 3 raid on

Also, if I created a device that had only /dev/sdd3, the --create command would also print this:

mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.

But it also prints that now, after "-l 1" works again, without the "device or resource busy" message. (and that disk has a bios_grub and boot raid1 partition that has metadata 0.90, but this sdd3 is not related to boot).

I can't reproduce this now though... I tried several times and reproduced it fine, but after trying with "-l 0" instead, it works. "-l 10" has the same effect as "-l 1".

Questions:

Why does md127 appear?

Why also md2 if it failed to create it?

In the future, other than using:

  • dd to zero the start of the block device
  • mdadm --zero-superblock
  • and creating with "-l 0" (which is a nonsense solution)

what else can I do to clean up the disk to prepare it for "--create"?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

It is hard to explain why md127 appeared from just the output you have posted on the screen. But what you can do next time is check what cat /proc/mdstat says - it will tell you if md127 is really a kernel device or not. If it is not there, you can just delete /dev/md127.

Related to that, and to answer the second question, the mdadm tool would try to create the device nodes under /dev but it will not clean them up if it fails for some reason.

To answer the third question - make sure the disk is really not in use. cat /proc/mdstat, stop any md devices with mdadm --stop, run mdadm --zero-superblock, and then make sure that there is no md metadata by running mdadm --examine /dev/sd....

share|improve this answer
    
I like your answer, but I hope someone can clarify it at some later date (particularly the mda127 thing and cleaning the disk or verifying that examine is enough and will show some results even after zero-superblock). Thanks for the input. –  Peter May 10 '12 at 6:59
add comment

md127 is what results when you "split brain" a RAID1 array. The kernel starts numbering them in reverse to avoid conflicts with existing configured devices. It is counting that spare disk as a member of an unknown RAID1 array. I don't know why it assigned the other one as md2. That's a mystery.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.