Skip to contentSkip to conversation

Hot adding active disk to RAID1?

DISCUSSION Mike Perry 4 participants 10 messages Feb 7, 2004 – Feb 15, 2004 MD RAID

lore
Share & tools
lore

Mike Perry

author
#0 lore raw

Well, this is probably a FAQ, but I've really looked around and can't seem to find how to do it..

So here's the story: I just created a RAID1 array. I did this by simply creating a single disk array, and then copying the data from the original disk onto the array, and then trying to raidhotadd the original disk once the array was created and the contents fully copied. I did NOT use a failed-disk directive for the original disk, as I have had at least one experience where the failed-disk directive was ignored and that drive was mirrored to anyways.. Luckily the failed-disk had no important data on it that time, but I didn't want to risk it this time..

At any rate, now it seems that my hotadded disk is NOT part of the active array, but is in fact a spare. Here's the relevant lines from mdadm --detail /dev/md0

Raid Disks : 1
Total Disks : 2
Preferred Minor : 0

Active Drives : 1
Working Drives : 2
Failed Drives : 0
Spare Drives : 1

It should be a simple matter to convert that spare to an active drive, right? Especially for RAID1. How do I go about doing that?

I've found a tool called raidreconf by the author of the RAID HOWTO, but I'm reluctant to just run that and hope for the best, especially since it seems to be written for just RAID0 and 5 (the rather scant manpage makes no mention of RAID1 whatsoever).

Does anyone have any experience with using raidreconf for RAID1, or have a way to hotadd a disk and have it become active, instead of being a spare?

Signature · 3 lines
Mike Perry
Mad Computer Scientist
fscked.org evil labs
author
#1 lore raw

Thus spake Mike Perry ([email protected]):

Quoted 4 lines

Well, this is probably a FAQ, but I've really looked around.. Does anyone have any experience with using raidreconf for RAID1, or have a way to hotadd a disk and have it become active, instead of being a spare?

Ok, in my impatience I grew some balls.. As it turns out, the RAID1 superblock is (seemingly?) independent of the contents of the volume. So I was able to simply mkraid --force /dev/md0, this time WITH a failed-disk directive. Once this was done, I was able to mount /dev/md0 right away, no reformatting or anything needed.

Then I hot-added the failed-disk, and it seems to be synching properly.

And also this time the failed-disk wasn't mirrored to immediately either (ie without the explicit hotadd).. I wonder why that happened the last time I did this.. Maybe I just miswrote the raidtab on that occasion.. Or possibly the partition type was raid autodetect and after the reboot the md driver saw this and decided to start mirroring, regardless of raidtab?

Anyways, sorry for the spam, but I imagine at least one other poor sap out there will find this useful ;)

P.S. I also looked at the src for raidreconf.. it in fact only supports raid0 and 5, and seems to be nice enough to refuse to do anything if you have a different raid level. So they got that going for them, which is nice.

Signature · 3 lines
Mike Perry
Mad Computer Scientist
fscked.org evil labs
#2 lore raw
Quoted 7 lines · Mike Perry

Thus spake Mike Perry ([email protected]):

Quoted 4 lines

Well, this is probably a FAQ, but I've really looked around.. Does anyone have any experience with using raidreconf for RAID1, or have a way to hotadd a disk and have it become active, instead of being a spare?

Quoted 5 lines

Ok, in my impatience I grew some balls.. As it turns out, the RAID1 superblock is (seemingly?) independent of the contents of the volume. So I was able to simply mkraid --force /dev/md0, this time WITH a failed-disk directive. Once this was done, I was able to mount /dev/md0 right away, no reformatting or anything needed.

Yes, the superblock is written at the end of the disk. Writing a superblock doesn't touch the data.

Quoted 8 lines

Then I hot-added the failed-disk, and it seems to be synching properly.

And also this time the failed-disk wasn't mirrored to immediately either (ie without the explicit hotadd).. I wonder why that happened the last time I did this.. Maybe I just miswrote the raidtab on that occasion.. Or possibly the partition type was raid autodetect and after the reboot the md driver saw this and decided to start mirroring, regardless of raidtab?

I use mdadm for managing my RAID. When creating a new array it lets you specify "missing" instead of a device to create an array with failed disks. No risk of overwriting anything there.

Signature · 7 lines
Måns Rullgård
[email protected]

-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
In reply to Mike Perry
Quoted 22 lines · Mike Perry

Thus spake Mike Perry ([email protected]):

Quoted 4 lines

Well, this is probably a FAQ, but I've really looked around.. Does anyone have any experience with using raidreconf for RAID1, or have a way to hotadd a disk and have it become active, instead of being a spare?

Ok, in my impatience I grew some balls.. As it turns out, the RAID1 superblock is (seemingly?) independent of the contents of the volume. So I was able to simply mkraid --force /dev/md0, this time WITH a failed-disk directive. Once this was done, I was able to mount /dev/md0 right away, no reformatting or anything needed.

Then I hot-added the failed-disk, and it seems to be synching properly.

And also this time the failed-disk wasn't mirrored to immediately either (ie without the explicit hotadd).. I wonder why that happened the last time I did this.. Maybe I just miswrote the raidtab on that occasion.. Or possibly the partition type was raid autodetect and after the reboot the md driver saw this and decided to start mirroring, regardless of raidtab?

Quoted 2 lines

Anyways, sorry for the spam, but I imagine at least one other poor sap out there will find this useful ;)

I'm that one.
I ended up at the same place but for another reason. I was in a hurry to build my system and knew that converting a ext3 to raid would cause some problem because of some extra raid info, so I defined a raid1 with only one disk. Later I bought the other disk and tried to add it by changing /etc/raidtab but that did of course not work and it was at this point I started to actually read the doc...
I saw reference to an old version of mkraid that would reinitialize the superblock only (--superblock-only) and keep the data, but newer raidtools doesn't do that. If that been there or some manpage in the later version describing it a bit clearer I could dear to do mkraid -f but with all incarnations of the raid software I no longer know what is safe in my version.

My current state is that I have root mounted as /dev/md0 created with one disk (/dev/hda5) as disk 0. I have since then added another disk and partitioned it equal. I now want to add /dev/hdc5 to md0 (was never mentioned before). If I add that to raidtab as failed-disk and do "mkraid -f", will I loose anything?

Quoted 5 lines

P.S. I also looked at the src for raidreconf.. it in fact only supports raid0 and 5, and seems to be nice enough to refuse to do anything if you have a different raid level. So they got that going for them, which is nice.

Signature · 4 lines
-------------------------------------------------------------------
Techwiz, Peter Sjoberg    PGP key (12F506C8) on keyserver & homepage
Key fingerprint =  3DC2 CEBA 1590 B41A 3780  955A DB42 02BB 12F5 06C8
mailto:peters AT techwiz.ca http://www.techwiz.ca/~peters
author
#4 lore raw

Thus spake Peter Sj?berg ([email protected]):

Quoted 11 lines · Mike Perry
Quoted 3 lines

Thus spake Mike Perry ([email protected]):
Anyways, sorry for the spam, but I imagine at least one other poor sap out there will find this useful ;)

I'm that one.
I ended up at the same place but for another reason. I was in a hurry to build my system and knew that converting a ext3 to raid would cause some problem because of some extra raid info, so I defined a raid1 with only one disk. Later I bought the other disk and tried to add it by changing /etc/raidtab but that did of course not work and it was at this point I started to actually read the doc...

Yeah, this sounds like my exact scenario, give or take a few details.

Quoted 6 lines

I saw reference to an old version of mkraid that would reinitialize the superblock only (--superblock-only) and keep the data, but newer raidtools doesn't do that. If that been there or some manpage in the later version describing it a bit clearer I could dear to do mkraid -f but with all incarnations of the raid software I no longer know what is safe in my version

I concur. The manpages really should clear up that raidhotadd (and mdadm -a) only add spares. And they should further clarify that spares are essentially useless and lie dormant.. The names of these commands/options are very deceptive to the new user...

Quoted 5 lines

My current state is that I have root mounted as /dev/md0 created with one disk (/dev/hda5) as disk 0. I have since then added another disk and partitioned it equal. I now want to add /dev/hdc5 to md0 (was never mentioned before). If I add that to raidtab as failed-disk and do "mkraid -f", will I loose anything?

I would put your data on both just in case. But yes, this should work just fine. The sync should start as soon as you raidhotadd a failed disk.

Sorry for the late reply.. Was away for the weekend (which was the cause of my original impatience and need to quickly find a solution..)

Signature · 3 lines
Mike Perry
Mad Computer Scientist
fscked.org evil labs
#5 lore raw
Quoted 5 lines · On Tuesday February 10, [email protected] wrote:

I concur. The manpages really should clear up that raidhotadd (and mdadm -a) only add spares. And they should further clarify that spares are essentially useless and lie dormant.. The names of these commands/options are very deceptive to the new user...

Patches are more that welcome.
It is very hard for someone how knows the system "inside-out" to see which areas aren't explained well.

NeilBrown

author
#6 lore raw

Thus spake Neil Brown ([email protected]):

Quoted 8 lines · On Tuesday February 10, [email protected] wrote:
Quoted 5 lines

I concur. The manpages really should clear up that raidhotadd (and mdadm -a) only add spares. And they should further clarify that spares are essentially useless and lie dormant.. The names of these commands/options are very deceptive to the new user...

Patches are more that welcome.

Is there a preferred version/cvs repository that I should diff against? The raidtools are kinda helter-skelter in their net presence, it seems..

Quoted 2 lines

It is very hard for someone how knows the system "inside-out" to see which areas aren't explained well.

Heh, ok. I'll put it on the TODO pile.

Signature · 3 lines
Mike Perry
Mad Computer Scientist
fscked.org evil labs
#7 lore raw
Quoted 9 lines · On Tuesday February 10, [email protected] wrote:

Thus spake Neil Brown ([email protected]):

Quoted 7 lines · On Tuesday February 10, [email protected] wrote:
Quoted 5 lines

I concur. The manpages really should clear up that raidhotadd (and mdadm -a) only add spares. And they should further clarify that spares are essentially useless and lie dormant.. The names of these commands/options are very deceptive to the new user...

Quoted 4 lines
Quoted 1 line

Patches are more that welcome.

Is there a preferred version/cvs repository that I should diff against? The raidtools are kinda helter-skelter in their net presence, it seems..

Sorry, I should have been more specific.
Patches *against mdadm* are welcome.
I have no interest in "raid-tools" - it seems to be unmaintained. Patches against the lastest source tar-ball are fine.

NeilBrown

author
#8 lore raw

Re: Hot adding active disk to RAID1? [PATCH]

Thus spake Neil Brown ([email protected]):

Quoted 7 lines
Quoted 2 lines

Is there a preferred version/cvs repository that I should diff against? The raidtools are kinda helter-skelter in their net presence, it seems..

Sorry, I should have been more specific.
Patches *against mdadm* are welcome.
I have no interest in "raid-tools" - it seems to be unmaintained. Patches against the lastest source tar-ball are fine.

Attached. Any plans to port that raidreconf tool into mdadm? Cause for now, the new manpage refers people to the deprecated raidtools.

Signature · 3 lines
Mike Perry
Mad Computer Scientist
fscked.org evil labs
mdadm.8 renamed from mdadm.8.old +10 -1
@@ -363,7 +363,16 @@
 .TP
 .BR -a ", " --add
 '''add, or
-hotadd listed devices.
+hotadd listed devices as spare disks. 
+
+To add active disks to an array, you will need to recreate the array. If it is
+RAID1, you can often get away with recreating the array using the same
+devices, plus one more, without destroying data (creating a RAID1 device only
+overwrites the superblock).  Note that backing up the array to a regular file
+system on your new disk first is strongly recommended, but if all goes well,
+you should not have to recopy any more data. For RAID0 and RAID5, adding
+active disks will require a raid-tools 1.0 utility called raidreconf. Please
+be aware that there are risks involved with these tools, and plan accordingly.
 
 .TP
 .BR -r ", " --remove
#9 lore raw

Re: Hot adding active disk to RAID1? [PATCH]

Quoted 5 lines · On Tuesday February 10, [email protected] wrote:

Thus spake Neil Brown ([email protected]):

Quoted 3 lines
Quoted 2 lines

Is there a preferred version/cvs repository that I should diff against? The raidtools are kinda helter-skelter in their net presence, it seems..

Quoted 7 lines
Quoted 4 lines

Sorry, I should have been more specific.
Patches *against mdadm* are welcome.
I have no interest in "raid-tools" - it seems to be unmaintained. Patches against the lastest source tar-ball are fine.

Attached. Any plans to port that raidreconf tool into mdadm? Cause for now, the new manpage refers people to the deprecated raidtools.

Thanks, though I'm not sure I want to mention raidreconf there. Maybe in a "see also" section.

I have thought about adding raidreconf functionality, but I think I'm more included to put it in the kernel, so you can reconfigure a live array.

I've just been testing some new that
a/ allows you to upgrade your raid1/5 to bigger drives on-line.
i.e. one at a time you
fail a drive, remove it, plug in a larger drive, and hot add it.
Once all the drives are larger, you can now tell the kernel to use the extra space.
b/ add/remove live drives from a raid1. It will automatically rebuild
onto an added drive, but won't automatically make a removed drive a spare yet (you can only reduce the size of a raid1 if the highest numbered slot is empty). So there is still a bit more work to do.

resizing a raid5 online wouldn't be too hard providing the chunk size isn't too big. but I'm not in any great hurry to do it just yet. (Converting raid0 to raid4, and then reshaping to raid5 would be interesting too :-)

NeilBrown