Preparing a RAID system of 2 disks and 2 partitions
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
- p check the partition table
- n create partition (ex +128M)
- t filesystem
- a bootflag
- w write
Set the RAID1 system on the 2 partitions
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
Check the RAID-DEVICES
cat /proc/mdstat
Make the file system
mkfs.ext3 /dev/md0 mkfs.ext4 /dev/md1
Mount the disks
mkdir /mnt/md0 mkdir /mnt/md1 mount /dev/md0 /mnt/md0/ mount /dev/md1 /mnt/md1/
Copy the data of Home
cd /home tar c * | tar x -C /mnt/md1
Find the UUID of the 1st partition
blkid /dev/md1: UUID="3968404e-6571-4671-a157-9113a9f2fcba" TYPE="ext4"
Make md1 be the home directory
emacs /etc/fstab # /home was on /dev/sda9 during installation UUID=3968404e-6571-4671-a157-9113a9f2fcba /home ext3 defaults 0 2
Add new Hard drive
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
Start the arrays at once
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