Ubuntu – /dev/md127 refuses to stop. No open files

lvmmdadmUbuntu

So I'm trying to stop /dev/md127 on my Ubuntu 12.10 box. It was set up as RAID1, but I'm trying to move everything (well, rename) to md0. I read that renaming isn't possible, so I'm trying to remove the drives and put them into a new array as md0. I've been able to remove one drive (sdb) by using –fail and –remove, but sdc isn't responding, nor will md127 respond to –stop –force.

I've run fuser and lsof, and neither show anything using md127. I was running LVM on top of md127, but I've umounted the LVs and I've done "{lv,vg}change -an vg_Name".

I'm at a loss for what to try next. And for those who want to know why I want to rename/move, I'm a little OCD over things like that.

If it's relevant, here are the exact commands I've used, though the stop/fail/remove commands have been tried multiple times:

mdadm --stop --force /dev/md127 # this failed with the error message "mdadm: Cannot get exclusive access to /dev/md127:Perhaps a running process, mounted filesystem or active volume group?"
fuser /dev/md127 # no output
lsof /dev/md127 # no output
mdadm --fail /dev/md127 /dev/sdb # succeeded
mdadm --remove /dev/md127 /dev/sdb # succeeded
mdadm --fail /dev/md127 /dev/sdc # this failed - "device or resource busy"
mdadm --remove /dev/md127 /dev/sdc # this failed - "device or resource busy"
lvchange -an vg_Name
vgchange -an vg_Name

Best Answer

If all you're trying to do is change the device number, add the array to your config file with the device number of our choice using the following command:

    echo "ARRAY /dev/md0 level=raid1 num-devices=2 UUID=$(blkid -s UUID -o value /dev/md127) devices=/dev/sdb,/dev/sdc" >> /etc/mdadm.conf

Once you've put your raid in /etc/mdadm.conf, just reboot and the raid should automatically reassemble using the device number you've specified. This has the added benefit of ensuring that your raid will be built with the same device name at every boot.

Related Question