Software RAID - adding already-used disk

Caporegime
Joined
16 May 2003
Posts
25,367
Location
::1
I've got a disk that's been used outside any kind of RAID config (call it sda).

Is it possible to add it to a md RAID-1 without blowing away the data that's already on it?
 
Sort of, yes. I did this quite a while ago - but unfortunately I can't remember the details (helpful, aren't I?), but the general approach was:

- Create an array on the new disk, but mark the second disk as missing
- Copy data from sda to the new array of one disk
- Add sda to the array - causing the array to be rebuilt on it.

There's probably a more efficient way of doing it, but that was good enough for me.
 
Thanks - that's probably the option I'll fall back to if there isn't an alternative :)

Mucking about with a VM and virtual disks, I seem to have got it to play ball by doing something similar.

  • mdadm --build (vs create) with the second disk and missing
  • doing mdadm --add /dev/sda

The array then rebuilds and when I mount it the "data" (for the purposes of this, a text file with some random, but known, stuff) is all present and correct.

The man page for mdadm says this for build mode though:
Build Build an array that doesn't have per-device metadata (superblocks). For these sorts of arrays, mdadm cannot differentiate between initial creation and subsequent assembly of an array. It also cannot perform any checks that appropriate components have been requested. Because of this, the Build mode should only be used together with a complete understanding of what you are doing.

Which...really inspires confidence :eek: because I don't completely understand what I'm doing :p
 
Back
Top Bottom