In the following examples we are going to use sdb and sdc for the disc to use in the RAID. Adapt it to your situation.
Create the partitions
fdisk /dev/sdb |
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1 mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb2 /dev/sdc2 |
cat /proc/mdstat |
mkfs.ext3 /dev/md0 mkfs.ext4 /dev/md1 |
mkdir /mnt/md0 mkdir /mnt/md1 mount /dev/md0 /mnt/md0/ mount /dev/md1 /mnt/md1/ |
cd /home tar c * | tar x -C /mnt/md1 |
blkid /dev/md1: UUID="3968404e-6571-4671-a157-9113a9f2fcba" TYPE="ext4" |
emacs /etc/fstab # /home was on /dev/sda9 during installation UUID=3968404e-6571-4671-a157-9113a9f2fcba /home ext3 defaults 0 2 |
Connect the new hard disk and boot a system.
This will create on the new drive a partition table identical to the one of the existing working drive (this will also copy GRUB).
(Assuming that /dev/sda is the existing working drive and /dev/sdb is the newly added drive)
dd if=/dev/sda of=mbr.bin bs=512 count=1 dd if=mbr.bin of=/dev/sdb bs=512 count=1 |
Check the status of the RAID devices to see the device numbers
cat /proc/mdstat |
Add the appropriate partition of the new drive to the RAID devices, repeat for each RAID device.
mdadm --manage --add /dev/md0 /dev/sdb1 |
Some linux system integrated an mdadm tool called mdadm-startall. You can install it if not already done.
It doesn't require any argument and will assemble all the md drives found.
mdadm-startall |