So, I'd like to know, is is possible to do the following with mdadm:
- I start with RAID0 configuration on 2 disks:
sda
andsdb
. - I would like to add one more disk to array,
sdc
and move all data fromsdb
to it. - Disconnect
sdb
.
Right now I see only one option – I stop the array, copy sdb
to sdc
with dd
or any other block-copy tool and start the array back.
Do I miss something? Is it possible to do this with mdadm?
Best Answer
First of all: to those, who still believes in "RAID0 has no hot spare". It could have a manual spare, done by human, who understand RAID levels and mdadm. mdadm is software RAID, so it could do a lot of interesting things.
Credits to Zoredache for the idea!
So, the situation:
If the downtime is acceptable, you always can just make a block copy of disk with dd and reassemble the array, mdadm will do OK.
Solution: use RAID4 as intermediate solution
RAID0 -> RAID4 -> RAID0
So, if you don't remember RAID4, it is simple. It has a parity block, but unlike RAID5 it is not distributed across the array, but resides on ONE disk. That's the point, this is important and this is the reason RAID5 will not work.
What you'll need: two more disks of the same size, as the disk you would like to replace.
Environment:
The ultimate RAID0 hot-spare mdadm guide ;)
We've created raid0 array, it looks sweet.
This is our check point - if even one bit will differ in resulting
/dev/md0
- we've failed.So, we've grown our array to be RAID4. We haven't added the parity disk yet, so let's do it. The grow will be instant - there is nothing to recompute or recalculate.
We've added
sdd
as parity disk. This is important to remember - the order of disks in the first row is not syncronized with the picture in second row! [UU_]sdd
is displayed first, but in fact it is last one, and holds not the data, but the parity.We've made our disk sdb faulty, to remove it in the next steps.
Details show us the removal of the first disk and here we can see the true order of the disks in the array. It's important to track the disk with parity, we should not leave it in the array when going back to RAID0.
sdb
is completely removed, could be taken away.We have added the replacement for our sdb disk. And here we go: now the data of sdb is being recovered using parity. Sweeeeet.
Done. Right now we are completely safe - all data from sdb are recovered, and now we have to remove sdd (remember, it holds parity).
Made sdd faulty.
Removed sdd from our array. We are ready to become RAID0 again.
Aaaaaaand bang!
Done. Let's look at md5 checksum.
Any more questions? So RAID0 could have a hot spare. It's called "user" ;)