Mini Raid Software howto

Prologue

The second disk is already installed and the partition Table is empty

else remove the partitions on the second disk by hand pbefore starting this procedure

create the correct partitions we need

start fdisk and follow these commands

 fdisk /dev/sdb
 n
 p
 1
 [enter]
 +100M
 n
 p
 2
 [enter]
 +2048M
 n
 p
 3
 [enter]
 [enter]
 t
 2
 82
 t
 3
 fd
 w

now we need to create the raid 1 partitions for the boot and the other partitions

 mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
 mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb3
 echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > /etc/mdadm.conf
 mdadm --detail --scan >> /etc/mdadm.conf

the /dev/md0 partition will be used flat for the boot partitions

  mkfs.ext3 /dev/md0

the /dev/md1 partition will be splitted using the lvm layer

  pvcreate /dev/md1
  vgcreate vg1 /dev/md1
  lvcreate --name root -L 4G vg1
  lvcreate --name usrlocal -L 4G vg1
  lvcreate --name var -L 4G vg1
  lvcreate --name export -L <bigger than the disk>G vg1
  lvcreate --name export -l <extens available reported by the previous command> vg1
  mkfs.ext3 /dev/vg1/root
  mkfs.ext3 /dev/vg1/usr/local
  mkfs.ext3 /dev/vg1/var
  mkfs.ext3 /dev/vg1/export

time to mount the partitions to copy the system from the original disk

  mkdir /1
  mount /dev/vg1/root /1
  cd /1
  mkdir -p boor usr/local var export proc sys dev
  mount /dev/md0 boot
  mount /dev/vg1/usrlocal usr/local
  mount /dev/vg1/var var
  mount /dev/vg1/export export
  rsync -aH --exclude=/1 --exclude=/proc --exclude=/sys --exclude=/dev / /1/

Create the new initrd image file

vi /1/etc/fstab

/dev/vg1/root           /                       ext3    defaults        1 1
/dev/md0                /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/vg1/export         /export                 ext3    defaults        1 2
/dev/vg1/var            /var                    ext3    defaults        1 2
/dev/vg1/usrlocal       /usr/local              ext3    defaults        1 2
#LABEL=SWAP-sda2         swap                    swap    defaults        0 0
LABEL=SWAP-sdb2         swap                    swap    defaults        0 0
mkinitrd --preload raid1 --preload raid456 --preload sata_nv --fstab /1/etc/fstab /boot/initrd-$(uname -r)-raid.img $(uname -r)

Edit the grub configuration file in the original disk

title Fedora (2.6.23.15-80.fc7) RAID
        root (hd0,0)
        kernel /vmlinuz-2.6.23.15-80.fc7 ro root=/dev/vg1/root vga=791 selinux=0 noipv6 panic=30
        initrd /initrd-2.6.23.15-80.fc7.img
title Fedora (2.6.23.15-80.fc7) RAID
        root (hd0,0)
        kernel /vmlinuz-2.6.23.15-80.fc7 ro root=/dev/vg1/root vga=791 selinux=0 noipv6 panic=30
        initrd /initrd-2.6.23.15-80.fc7-2.img

title Fedora (2.6.23.15-80.fc7) RAID
        root (hd1,0)
        kernel /vmlinuz-2.6.23.15-80.fc7 ro root=/dev/vg1/root vga=791 selinux=0 noipv6 panic=30
        initrd /initrd-2.6.23.15-80.fc7-2-raid.img

Install the boot loader on the second disk

  grub
  root (hd1,0) [enter]
  setup (hd1) [enter]
  quit [enter]

update the data on the second disk

* we need to copy the changes from the original disk to the new one

  rsync -aH /boot/ /1/boot/

Reboot

  reboot

The New System

Deleting the old lvm partitions

 lvchange -a n vg0/root
 lvchange -a n vg0/usrlocal
 lvchange -a n vg0/var
 lvchange -a n vg0/export
  lvremove vg0/root
  lvremove vg0/usrlocal
  lvremove vg0/var
  lvremove vg0/export
  vgremove vg0
  pvremove /dev/sda3

Creating the new partition table form the second disk

* now we can recreate the new partition table copying the partition of /dev/sdb to /dev/sda

 sfdisk -d /dev/sdb | sfdisk /dev/sda

add the second disk to the raid system .....

  mdadm --manage /dev/md0 --add /dev/sda1
  mdadm --manage /dev/md1 --add /dev/sda3

.... and update the grub code

  grub
  root (hd0,0)
  setup (hd0)
  quit

the last task is to create the second swap partition

  mkswap -L SWAP-sda2 /dev/sda2
  swapon /dev/sda2

Kernel upgrade

During Kernel upgrade the grub file must be manually modified in order to add the reference to the second disk