4

I have a CentOS 7 server. It is running a software RAID 1 mirroring three disks. I want to add a 4th disk to act as a hot spare. My intention is that in the event of a failure of one of the three disks being mirrored that the hot spare would automatically be populated from one of the remaining working disk, and take its place from the failure drive.

For the hot spare, other than formatting the new drive what else needs to be done to it? I assume it remains with no data on it until it is needed and starts syncing to replace the bad drive?

4
  • 3
    Can’t you just expand to raid10 Sep 26 '19 at 18:30
  • 3
    Instead of having it as a hot spare, why not just have a four-way mirror? That way you save the rebuild time if one of the original three disks fails. I'm not sure I've ever run an application that needs that kind of redundancy at the disk level however.
    – doneal24
    Sep 26 '19 at 18:57
  • Is there a problem with the -x option of the mdadm command?
    – Bass
    Sep 27 '19 at 2:13
  • Did you read the manual? not a CentOS 7 user here ,but that sounds like one of those "how do I turn the car on" questions. Adding a hot spare i a standard operation and should be very clearly described in the man pages for mdadm.
    – TomTom
    Oct 7 '19 at 9:58
11
+50

If you really want to use 4 disks for a RAID1 array, I suggest you to go with a 4-way RAID1 array. In this manner, should a disk fail, you continue to have triple-protection (3-way array) without needing any rebuild.

If you really want a 3-way mirror + hot spare, you can use mdadm --manage --add-spare to add a spare to the RAID1 array. For example, lets start from this 3-way array (note: I am using loopback devices, while you want to use real disks):

[root@localhost test]# cat /proc/mdstat 
Personalities : [raid1] 
md127 : active raid1 loop2[2] loop1[1] loop0[0]
      7168 blocks super 1.2 [3/3] [UUU]

Adding a spare is quite simple:

[root@localhost test]# mdadm --manage /dev/md127 --add-spare /dev/loop3
mdadm: added /dev/loop3

Lets check /proc/mdstat now:

[root@localhost test]# cat /proc/mdstat 
Personalities : [raid1] 
md127 : active raid1 loop3[3](S) loop2[2] loop1[1] loop0[0]
      7168 blocks super 1.2 [3/3] [UUU]

Again, be sure to use the correct device name (rather than blindly copy/pasting the above commands). And take a confirmed-working backup first.

However, I consider a 4-way or 3-way+hotspare RAID1 array overkill. While for extremely important data a 3-way RAID1 mirror can be justified, you should really plan for failure scenarios in which the entire server is down. In other words, don't skip on regular backups simply because you have mirrored disks.

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.