[NBLUG/talk] non raid to raid move... on the fly ?

Kyle Rankin greenfly at greenfly.net
Thu Mar 27 10:57:01 PST 2003


On Thu, Mar 27, 2003 at 10:30:36AM -0800, Dave Cooper wrote:
> OK, I blew it...
>  RedHat 8 server, put into production a little to fast. I have 2 18G 
> drives that I wanted to raid 1 with.. Instead I have mount points on both 
> drives not in raid 1.. I dont have a local backup device.. Anyone want to 
> recommend ( or tell me "I'm Screwed" ) a way to : on the fly convert a 
> running system from /dev/sda and /dev/sdb to /dev/rd0...
> 
<snip>

Okay, now if you have duplicate data on both drives (or can make it so that all
of the data is only on one drive) you can save this.  This is how:

The key to this whole thing is the idea of creating your filesystem on this
RAID, only with the first drive being considered as a "failed-disk" in your
raidtab.  You create the RAID on the second disk (it doesn't touch the first
disk because it's failed).  And then once that RAID is set up and you can boot
on it (so it will require a reboot) you hot-add the first drive. 

Note that I'm more or less following the instructions given in section 4.12.2 of
the Software-RAID-HOWTO.  You can find that in your system docs (provided you
installed the HOWTOs) otherwise you can find it here:
http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Software-RAID-HOWTO.html#ss4.12

Be sure to skip down to Method 2

1) Make sure all of the data you would need for this server is residing all on
one of the drives so that you can wipe out the second drive with no data loss.

2) Set up the partitions so that they are of type "Linux RAID".  The RAID
HOWTO goes over how to do this.

3) In your raidtab, set up your RAID1, with the first partition listed as a
"failed-disk" and the second, wiped out partition as a "raid-disk"

4) With your raidtab setup, run mkraid to create the raid.  Then format that
raid with whatever filesystem you are using.  For instance, for XFS (hurrah) you
would run

mkfs -t xfs /dev/rd0

5) Mount your new raid somewhere on your system and copy all the files from your
first system onto the new raid drive mounted somewhere like /mnt/foo.  I prefer the

find / -xdev -print0 | cpio -pa0V /mnt/foo

method for fully copying root properly.  If you have a lot of files that are
changing on this running server, you may need to re-run this adding a
2>/dev/null at the end so that it will copy any new files across (and you won't
fill up your screen with "file already exists" warnings)

6) Wait a long time.  If you are using my method for copying, note that a dot is
output to the screen for each file copied.

7) Set up your fstab and lilo/grub configuration so that it will be using the
raid drive /dev/rd0 as the root drive.

8) Reboot, and upon reboot make sure that you are indeed booting off the raid
device.

9) Now, edit your raidtab so that the failed-disk is listed as a regular
raid-disk and then raidhotadd the disk to your RAID.  It might require that you
blank out that drive before it will properly add it (or you could possibly force
it as well).

10) Wait a long time.  You can, however use the system while the raid is
hotadding the new partition.

Hope this helps.  I've used a similar system in the past for both RAID1 and
RAID5 drives I've wanted to migrate my system to.

-- 
Kyle Rankin (greenfly)
http://greenfly.org



More information about the talk mailing list