I have 4 disks in my server. sda and sdb were combined to RAID1 and had the operating system. sdc and sdd were a second RAID1 device that had a single volume group with a bunch of LVMs. sdd died so my data RAID got degraded. After replacing sdd (but before adding to the RAID), grub decided lose it's mind and refuse to boot. The fastest way to fix was to just reinstall the OS since there was nothing important on it.

I removed sdc and sdd during the install to make sure they were not overwritten by mistake. After the install was finished, I put the drives back in, and Centos found my volume group automatically. sdc was no longer part of a RAID array though.

It is partitioned /dev/sdc1 Linux raid auto detect

My question is - how can I use mdadm to recreate the sdc1,sdd1 RAID array without losing data already on sdc?

My best guess was to create the array with just sdc1 first, then add sdd1 after (so it rebuilds from sdc to sdd)

EDIT After looking at the output of /cat/mdstat again, I noticed something odd. My data disk was showing up as part of a RAID array, but one of my OS RAID arrays was missing (and fstab tried to link my swap to my data disk).

fdisk /dev/sda
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          32      257008+  fd  Linux raid autodetect
/dev/sda2              33        2072    16386300   fd  Linux raid autodetect
/dev/sda3            2073       30401   227552692+  fd  Linux raid autodetect

md1 should have been /dev/sda2 and /dev/sdb2 however it is missing

cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb1[1] sda1[0]
      256896 blocks [2/2] [UU]

md3 : active raid1 sdc1[0]
      1465135936 blocks [2/1] [U_]

md0 : active raid1 sdb3[1] sda3[0]
      227552576 blocks [2/2] [UU]

When I try to create md2, I get:

[root@xen2 ~]# mdadm --create /dev/md1 --level=1 --raid-disks=2 /dev/sda2 /dev/sdb2
mdadm: /dev/sda2 appears to be part of a raid array:
    level=raid1 devices=2 ctime=Wed Aug 15 02:48:06 2012
mdadm: /dev/sdb2 appears to be part of a raid array:
    level=raid1 devices=2 ctime=Wed Aug 15 02:48:06 2012
Continue creating array? n

mdadm scan also shows it missing

[root@xen2 ~]# mdadm --detail --scan
ARRAY /dev/md0 level=raid1 num-devices=2 metadata=0.90 UUID=51ef54bd:770bb58e:90183df1:d82a79c7
ARRAY /dev/md3 level=raid1 num-devices=2 metadata=0.90 UUID=2d7dfb1e:6b091396:a7558ec2:4d288e6f
ARRAY /dev/md2 level=raid1 num-devices=2 metadata=0.90 UUID=ecdd769b:c49d51b6:fe43f166:465b7073

I'm not sure why /dev/md1 decided to get lost after rebooting, but is it safe to rebuild the it?


Yes, you need to start the array in degraded mode using sdc drive. Then, you can re-add the failed drive sdd.

I usually use the command mdadm with option --assemble to assemble and start the array in degraded mode using one disk only. Something like this:

$ mdadm --assemble /dev/md1 /dev/sda2

You may need to use -f option to force starting degraded array.

If that works fine, you can proceed by re-adding the replaced drive.

$ mdadm --re-add /dev/md1 /dev/sdb2

I used these commands many times before and did not experience any data loss. They worked smoothly when the drives are OK.

Precaution: Please backup your disks before running such commands to avoid any possible data loss.

  • Added some more detail. Apparently my RAID config was detected on the data disk, but that seems to cause the RAID on /dev/md1 to have been lost. (Maybe the UUID was the same?) – John P Aug 15 '12 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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