Loading...
 

How to create a Raid1 rootdevice on Linux without moving data or reinstalling

This Howto is a working example to convert a non-raid root-filesystem to a mirrored root filesystem. This example worked for SuSE 9.2 and i think it should work for newer versions or other distros too. This tutorial is based on a older RedHat based howto: Converting a non-RAID RedHat System to run on Software RAIDQuestion

Here are the steps:

1. Suse usually uses reiserfs as standard filesystem. You can shrink reiserfs or ext3 filesystems (and probably other too). Since we need some bytes for the md state at the end of a partition, we should shrink every filesystem before we create the md devices. 10MB should be enough. You can resize the filesystem later to get the remaining space back.

2. Create a /etc/raidtab file. Here is a example:

raiddev /dev/md0
    raid-level              1
    nr-raid-disks           2
    nr-spare-disks          0
    chunk-size              4
    persistent-superblock   1
    device                  /dev/sda1
    raid-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
    raid-disk               1


The disk /dev/sda contains the original data while sdb will get overwritten later! The md driver always syncs from the first device to the second.
Be sure to have the same partition sizes on each disk. Use fdisk to prepare the second disk.

3. Prepare config files: The /etc/fstab should be changed to the to be created md devices. Change /boot/grub/menu.lst and change the "root=/dev/sdaX" to "root=/dev/mdY". If you try to boot now, you won't be able any more. Use the rescue system if you want to get back from here.

3. Boot your system from the install CD in recovery mode. Mount the root filesystem at /mnt and copy the /etc/raidtab to the /etc of your rescue system.

4. Umount /mnt and start syncing:
mkraid --really-force /dev/md0
mkraid --really-force /dev/md1
Watch /proc/mdstat for all md devices to finish resyncing.

5. Use fdisk to change the partition types of all affected partitions to 0xFD.

6. mount /dev/mdY (your root mirror) at /mnt and all other partitions you need for a working system (/usr, ...) and chroot to it (chroot /mnt). Then change the line in /etc/sysconfig/kernel /example)
INITRD_MODULES="piix aic7xxx reiserfs"
to
INITRD_MODULES="piix aic7xxx reiserfs raid1"
and rebuild the initrd with mkinitrd. Otherwise the kernel will not be able to boot from a raid1 device.

6. Reboot should work now as expected.

Created by admin. Last Modification: Wednesday 14 of December, 2005 20:45:59 UTC by admin.

Flattr me!