17

I am having trouble going from a single disk to raid 10

The command issued is:

mdadm --create /dev/md0 --level=10 --raid-devices=8 /dev/sd[abcdefgh]1

The output is:

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

I have verified this has nothing to do with DM:

]# dmsetup status

No devices found

The file system is GPT, I used sgdisk --backup=table /dev/sda followed by sgdisk --load-backup=table /dev/sdb through to sdh to copy the partitions table

The table looks like:

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  525MB   524MB   ext3                  boot
 2      525MB   86.4GB  85.9GB  ext4
 3      86.4GB  90.7GB  4295MB  linux-swap(v1)
 4      90.7GB  1000GB  909GB

I have created the other arrays fine however I cannot create the raid for the 1st and 2nd partition.

current status:

]# cat /proc/mdstat
Personalities : [raid10]
md3 : active raid10 sdh3[7] sdg3[6] sdf3[5] sde3[4] sdd3[3] sdc3[2] sdb3[1] sda3[0]
      16766976 blocks super 1.2 512K chunks 2 near-copies [8/8] [UUUUUUUU]
        resync=DELAYED

md4 : active raid10 sdh4[7] sdg4[6] sdf4[5] sde4[4] sdd4[3] sdc4[2] sdb4[1] sda4[0]
      3552147456 blocks super 1.2 512K chunks 2 near-copies [8/8] [UUUUUUUU]
      [========>............]  resync = 42.5% (1513033344/3552147456) finish=76.2min speed=445722K/sec

unused devices: <none>

Can anyone offer any advice, do I need to boot in to a rescue disk and create the arrays for / and /boot while they are not mounted?

1
  • You are likely trying this in a running system while /dev/sda1 is mounted. Naturally, this can't work, also things are a lot more complicated than just to convert the partitions into a RAID (you need to update the initramfs, the boot loader and /etc/fstab). If you don't understand this, you shouldn't continue before reading up on this matter.
    – Sven
    Apr 13, 2013 at 13:58

4 Answers 4

5

do I need to...create the arrays for / and /boot while they are not mounted?

Precisely.

I hope you also realised that the old contents will be wiped in the process, so you might want to create a new array with one device missing (use mdadm --level=10 --raid-devices=8 --missing /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 /dev/sdg1 /dev/sdh1). Then format the filesystem on the new array volume and copy all data from /dev/sda1 to it. Then reboot from the array (thus NOT using the /dev/sda1 root) and actually add /dev/sda1.

Do not forget to adjust the bootloader accordingly.

3
  • Ah ok thanks, usually I would not be doing it this way at all, the server was taken on with 8 drives with the OS on 1 disk only and the others untouched, it might be worth just setting it up again from scratch with the KVMoIP I suppose. I thought it may have been an option to simply dd sda1 and sda2 over to sd[bcdefgh]1 and sd[bcdefgh]2 then create the arrays even with sda1 and sda 2 mounted, I suppose I could still try that with sda1,2 missing then add them to the arrays in resuce mode unmounted but if that is going to wipe everything I might as well just reinstall.
    – Backtogeek
    Apr 13, 2013 at 14:36
  • Ubuntu is not CentOS, but it is close enough that several of the answers on A.U. also apply. Exaples: askubuntu.com/questions/252795/convert-running-system-to-raid-5 (In your case it is RAID 10 and not RAID5, but the idea is the same: Create the new array and format it, copy data, fix bootloader to boot from the RAID, test, add old partition to the RAID (thus loosing the old content on it).
    – Hennes
    Apr 13, 2013 at 14:51
  • There was enough information in that link to give me the answers and order of things I needed all sorted now and booting+running on raid 10 Thanks.
    – Backtogeek
    Apr 13, 2013 at 16:22
11

Just try to stop before reassambling array :

sudo mdadm -Esv
sudo mdadm  --stop /dev/md*
sudo mdadm --misc --scan --detail /dev/md0
sudo mdadm -v --assemble "$array" "$disk1$part" "$disk2$part"
1
  • I used this code without assembling the disk that was corrupted, then I could recover my data, thank you very much
    – ZiTAL
    Apr 26, 2019 at 18:32
2

I had the same issue. Replaced a faulty drive (after failing and removing from RAID 1), but then could not add it back. Was getting resource busy all the time.

SOLVED AS FOLLOWS...

The problem was that the system had mapped my new disk as md126 and md127 (not sure why). So I had these two extra drives showing up unconnected, but present in cat /proc/mdstat.

When I did mdadm --stop /dev/md*, it removed the md126 and md127 entries. Then the resource in use error went away and when I did the mdadmin --manage /dev/md0 --add /dev/sdb1 it was working. Yay :-)

0

First open this file /proc/mdstat and check if your block device /dev/sda1 is part of any md* if you see it there try to remove it using : mdadm --stop md* (* means the number after md that /dev/sda belong to )

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .