[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: converting ext2 to softraid 1 or 5



On Tue, 25 Sep 2001 14:55, Alson van der Meulen wrote:
> On Tue, Sep 25, 2001 at 02:17:46PM +0200, Kai Koehler wrote:
> > hello
> >
> > we want to install an software raid system on an existing debian server
> > the server contains his data on one partition/hd
> >
> > whats the easiest way to initialize an software raid 1 or 5 and convert
> > the existing data with the lowest downtime
>
> Put the RAID disks in the server, configure software RAID with these
> disks, copy your data (dump/restore, tar, cp, whatever), then remove the
> old disk.
> You could, if you want to use the original disk in your array, temporary
> insert an extra disk, mkraid, copy data, and remove the disk and raidhotadd
> the original disk.
>
> For more info look at the Software-RAID-HOWTO.

In "raidtools2" (kernel 2.4.x software RAID and the patches that you can 
apply to 2.2.x kernels) the RAID superblock is officially 64K (but can be as 
much as 96K in some of my tests - I don't know why) and is at the end of the 
disk.

So you can run "mke2fs /dev/whatever XXXX" where XXXX is the block count 
minus 96!

Then you can install Linux on that device.

After installing Linux and installing the raidtools2 package create a 
/etc/raidtab like the following:
raiddev /dev/md1
        raid-level      1
        nr-raid-disks   2
        nr-spare-disks  0
        chunk-size     4
        persistent-superblock 1
        device          /dev/hda1
        raid-disk       0
        device          /dev/hdb1
        failed-disk       1 

Note that the failed-disk line is after the device you haven't installed on, 
the device with your root FS should be the raid-disk (the above example 
presumes you have installed to /dev/hda1).

Then go to single user mode and umount the root fs.  Run mkraid to create the 
RAID device.  The documentation says that this will destroy all data on your 
devices, but for RAID-1 this is not the case.  For RAID-1 one of the disks 
will be taken as master and it's contents will be copied to the other at 
mkraid time.  If mkraid is run when one device is in "failed" state then the 
non-failed device is untouched apart from the last 64K - 96K.

Then you can mount the RAID device on /new-root and use pivot_root(8) to make 
it the root FS, then umount the old /dev/hda1.

Then you can use raidhotadd to add /dev/hdb1 to /dev/md1 while the machine is 
running (or switch to multi-user mode first if you like).

The above method is not something you want to do on a production machine 
without testing it first.  But it works, I've done it before but not with the 
root FS (so I skipped the pivot_root step and didn't have to have the FS 
mounted at the time mkraid was run).

The only potential problem is that mkraid might require an exclusive lock on 
the device, in which case you would need to boot from another device (or use 
pivot_root to change the root fs temporarily) to have it unlocked (umount'ing 
the root fs only mounted read-only).

-- 
http://www.coker.com.au/bonnie++/     Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/       Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/     My home page



Reply to: