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

Fri Jul 25 07:02:22 UTC 2014
Arun Khan <knura9 at gmail.com>

On Fri, Jul 25, 2014 at 5:41 AM, Lists <lists at benjamindsmith.com> wrote:
> I have a large disk full of data that I'd like to upgrade to SW RAID 1
> with a minimum of downtime. Taking it offline for a day or more to rsync
> all the files over is a non-starter. Since I've mounted SW RAID1 drives
> directly with "mount -t ext3 /dev/sdX" it would seem possible to flip
> the process around, perhaps change the partition type with fdisk or
> parted, and remount as SW RAID1?
>
> I'm not trying to move over the O/S, just a data paritition with LOTS of
> data. So far, Google pounding has resulted in howtos like this one
> that's otherwise quite useful, but has a big "copy all your data over"
> step I'd like to skip:
>
> http://sysadmin.compxtreme.ro/how-to-migrate-a-single-disk-linux-system-to-software-raid1/

For data partitions a lot of the stuff is not  applicable.

With respect to the madam steps, creating degraded arrays, filesystem
on those degraded arrays and then copy over the data etc. is spot on
IMO.

I would recommend the steps in the above tutorial to really be assured
that none of data is corrupted.

>
> But it would seem to me that a sequence roughly like this should work
> without having to recopy all the files.
>
> 1) umount /var/data;
> 2) parted /dev/sdX
>      (change type to fd - Linux RAID auto)
> 3) Set some volume parameters so it's seen as a RAID1 partition
> "Degraded". (parted?)
> 4) ??? Insert mdadm magic here ???
> 5) Profit! `mount /dev/md1 /var/data`
>
> Wondering if anybody has done anything like this before...
>

'mdadm' starts initializing the array (writing on the disk),
overwriting your file system on that partition.

I would not recommend it but you can try it and see what happens with
your experiment.  Should be a no brainer since you have secondary back
ups of the data elsewhere (stated in this thread).

-- Arun Khan