[CentOS] Convert "bare partition" to RAID1 / mdadm?

Mon Jul 28 23:36:27 UTC 2014
Robert Nichols <rnicholsNOSPAM at comcast.net>

On 07/25/2014 12:32 PM, Benjamin Smith wrote:
> On 07/25/2014 06:56 AM, Robert Nichols wrote:
>> Unless you can figure out some way to move the start of the partition back
>> to make room for the RAID superblock ahead of the existing filesystem, the
>> answer is, "No." The version 1.2 superblock is located 4KB from the start
>> of the device (partition) and is typically 1024 bytes long.
>>
>>        https://raid.wiki.kernel.org/index.php/RAID_superblock_formats
>
> Sadly, this is probably the authoritative answer I was hoping not to
> get. It would seem technically quite feasible to reshuffle the partition
> a bit to make this happen with a special tool (perhaps offline for a bit
> - you'd only have to manage something less than a single MB of data) but
> I'm guessing nobody has "felt the itch" to make such a tool.

In thinking about this some more, I had an idea that (a) I'm not totally
sure would work, and (b) strikes me as dangerous.

1. Use dmsetup to create a logical device that consists of an 8 KiB
prefix followed by your existing partition with the ext4 filesystem.

2. Create your RAID1 array using the above logical device as the first
member and with the second member missing.

3. Unmount the current filesystem and mount the RAID device in its place.

4. Add a new device to the (currently degraded) RAID array, and let the
RAID system spend the next couple of days recovering data onto the new
device.

Eventually, you would remove the dmsetup device from the RAID array and
add a new device in its place.

I have a feeling you will not want to risk your data to the above
procedure. ;-)  Trying to reboot a system with that cobbled together
RAID member might prove an interesting exercise.

-- 
Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.