[svlug] How to un-raid an raid/mirror?

Marc MERLIN marc_news at merlins.org
Tue May 27 11:41:58 PDT 2003

On Sun, May 04, 2003 at 12:33:23PM -0700, Scott Hess wrote:
> On Wed, 30 Apr 2003, Jos Laake wrote:
> > I have the opposite problem.  I am wondering if there is a way to set up
> > RAID-1 mirroring on an existing system without it. I have a second drive
> > identical to the first one.  Is there some way to just copy the drive
> > and then go RAID-1 from there?
> Setup the new drive as a RAID-1 array with a single device.  Build a 
> filesystem on it, copy everything over.  Then, taking a deep breath, add 
> the original drive as a new spare and it will rebuild the array on it.
Actually, there is better than that (more cow-boy sysadmin, but faster)
> One caveat is that you should make certain that the disks really are
> identical (fdisk -l should tell you what you need to know).  Even the same
> model number isn't necessarily always identical, depending on which

Size doesn't matter as long as the second drive is the same size or
bigger than the first one.

As to how to convert to Raid1 on the fly, here's the info.
I should note that this is dangerous as it will wipe the last 64 blocks
(or so) of your filesystem, but then again, those should be free unless
your partition is full.

01) Install your second disk
01) Do a normal install on one disk and reboot
02) Duplicate the disk partitions on the second disk
03) Set all the linux partition types to fd
04) Setup /etc/raidtab with failed-disk for the second disk
    raiddev     /dev/md0
        raid-level              1
        nr-raid-disks           2
        nr-spare-disks          0
        chunk-size              4
        persistent-superblock   1
        device                  /dev/sda1
        failed-disk             0
        device                  /dev/sdb1
        raid-disk               1
    raiddev     /dev/md1
        raid-level              1
        nr-raid-disks           2
        nr-spare-disks          0
        chunk-size              4
        persistent-superblock   1
        device                  /dev/sda2
        raid-disk               0
        device                  /dev/sdb2
        failed-disk             1
    (note that for the  root partition, the failed disk has  to be sda1, not

05) init 1
06/07) steps that don't apply here
08) umount -a

09) For each partition
    mkraid --really-force /dev/mdx
    e2fsck -f /dev/mdx (abort: no)
    resize2fs /dev/mdx

10) mke2fs -j /dev/md0
11) mount /dev/md0 /mnt
12) cp -avx / /mnt
13) Add a lilo entry to with root=/dev/md0
14) edit lilo.conf to mount /dev/mdx instead of /dev/sday
15) Reboot and make sure your new test lilo label works
16) echo 2048 > /proc/sys/dev/md/speed-limit (linux 2.4 uses another name)
17) For each raid device
    raidhotadd /dev/mdx /dev/sdby 
    (note that the root filesystem is raidhotadd /dev/md0 /dev/sda1)
18) Replace failed-disk with raid-disk in /etc/raidtab
19) Edit lilo.conf to set both boot=/dev/md0 and root=/dev/md0
20) Run lilo, reboot, and pray :-)

"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
Microsoft is to operating systems & security ....
                                      .... what McDonalds is to gourmet cooking
Home page: http://marc.merlins.org/   |   Finger marc_f at merlins.org for PGP key

More information about the svlug mailing list