Create Linux RAID 1 (Mirroring) Array After Installation on ClarkConnect 

  • Notes
    • Hard drives are sda and sdb, if you have an IDE drives, replace it with hda and hdb
    • Drive sda is up and running, adding new drive sdb
    • Swap partition will not be RAIDed
  • Change Partition Type of the Old Drive to RAID
    • sfdisk --change-id /dev/sda 1 fd
    • sfdisk --change-id /dev/sda 2 fd
  • Copy Partition table to the New Drive 
    • sfdisk -d /dev/sda | sfdisk /dev/sdb
  • Create swap on the New Drive 
    • mkswap /dev/sdb3
  • Create Raid and add New Drive 
    • mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb1
    • mdadm --create /dev/md2 --level=1 --raid-devices=2 missing /dev/sdb2
  • Format RAID 
    • mke2fs -j /dev/md1
    • mke2fs -j /dev/md2
  • Modify Kernel
    • mkinitrd -f /boot/initrd-`uname -r`.img `uname -r`
  • Change Drives
    • Edit /etc/fstab
      • Change LABEL=/ to /dev/md2
      • Change LABEL=/boot to /dev/md1
    • Edit /boot/grub/menu.lst
      • Change LABEL=/ to /dev/md2
  • Copy files to new drive
    • mkdir /mnt/tmp
    • mount /dev/md1 /mnt/tmp
    • cp -axu /boot/* /mnt/tmp
    • sync
    • umount /dev/md1
    • mount /dev/md2 /mnt/tmp
    • cp -axu / /mnt/tmp
  • Reboot
  • Add old drive to Raid Array
    • Add old Drive
      • mdadm /dev/md1 --add /dev/sda1
      • mdadm /dev/md2 --add /dev/sda2
    • Monitor build status
      • watch -n 1 cat /proc/mdstat
  • Create stage 1 grub on sdb
    • grub
    • root (hd0,0)
    • setup (hd0)
    • root (hd1,0)
    • setup (hd1)
    • quit
  • Clean up
    • rm -vfR /mnt/tmp
  • Reboot
  • Useful RAID command