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

Fri Jul 25 01:07:38 UTC 2014
Les Mikesell <lesmikesell at gmail.com>

On Thu, Jul 24, 2014 at 7:11 PM, 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/
>
> 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...
>

Even if I found the magic place to change to make the drive think it
was a raid member, I don't think I would trust getting it right with
my only copy of the data.  Note that you don't really have to be
offline for the full duration of an  rysnc to copy it.  You can add
another drive as a raid with a 'missing' member, mount it somewhere
and rsync with the system live to get most of the data over.  Then you
can shut down all the applications that might be changing data for
another rsync pass to pick up any changes - and that one should be
fast.   Then move the raid to the real mount point and either (safer)
swap a new disk, keeping the old one as a backup or (more dangerous)
change the partition type on the original and add it into the raid set
and let the data sync up.

-- 
   Les Mikesell
     lesmikesell at gmail.com