RAID1 setup

I decided it was about time I actually setup some redundancy for my data.  Having never done a full backup and only storing the odd chunk of data somewhere on a dvd.  Losing the HDD would be a severe PITA!  I purchased a Startech PEXSAT32 and popped it in.  As my current HDD is SATA and is running under AHCI, the card was picked up out of the box.

Before connecting any drives I ran a quick speed check (3 times) with the onboard SATA controller and got the following results.

# hdparm -tT /dev/sda
/dev/sda:
 Timing cached reads:   10954 MB in  2.00 seconds = 5479.70 MB/sec
 Timing buffered disk reads: 264 MB in  3.01 seconds =  87.64 MB/sec

# hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 11060 MB in 2.00 seconds = 5533.11 MB/sec
Timing buffered disk reads: 264 MB in 3.01 seconds = 87.71 MB/sec

# hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 10698 MB in 2.00 seconds = 5351.98 MB/sec
Timing buffered disk reads: 262 MB in 3.02 seconds = 86.71 MB/sec

Fairly poor for a SATAII controller and a SATAII drive!!!

Time to connect the drives...

At the risk of not losing any data and the fact that I just didn't have anything big enough to backup to, I just bought 2 x WD 1TB Eco.  The current drive is SATAII one of these :)

Due to the way the RAID is setup, both drives will be erased upon setup.  This rules out cloning the original drive and building the array. The way I had to do this was to setup the RAID1 and then clone the original drive...FAIL!  The original drive was a few blocks larger than the RAID drives :(
The work around was to mirror the partitions of the original.  This doesn't have to be an exact science, but does have to accommodate the data to be copied.  Once the partitions have been setup (done via a Gentoo minimal CD and fdisk) it was time to start migrating data.

I created 2 directories:
/mnt/master
/mnt/raid

/boot /dev/sda1    100M
swap /dev/sda2    2Gb
/ /dev/sda3    5Gb
/dev/sda4    Extended partition
/var /dev/sda5    10Gb
/usr /dev/sda6    20Gb
/tmp /dev/sda7    10Gb
/root /dev/sda8    1Gb
/home /dev/sda9    870Gb

/dev/sda being the original drive, I mounted the in the following order.

mount /dev/sda3 /mnt/master
mount /dev/sda1 /mnt/master/boot
mount /dev/sda5 /mnt/master/var
mount /dev/sda6 /mnt/master/usr
mount /dev/sda7 /mnt/master/tmp
mount /dev/sda8 /mnt/master/root
mount /dev/sda9 /mnt/master/home

I did the same with the raid drive (/dev/sdb) as above but mounted to /mnt/raid.

I then executed the following to copy the data:

cd /mnt/master
tar cf - . | (cd /mnt/raid; tar xfp -)

This took quite a few hours due to the sheer amount of data.  Although the tar command would be a little slower than say dd.  It does allow me to copy *ALL* files from each partition, including hidden files/folders.

Once that completed, I powered off the machine and removed the original drive.  Powered back up and booted into the Gentoo CD again.  I repeated the procedure and mounted the partitions (except sda1 or /boot).
Next we need to chroot into the drive's installed OS.  cd into /mnt/(where you mounted the / partition).
chroot /mnt/(where you mounted the / partition) /bin/bash
env-update
source /etc/profile

This has now put us into the OS installed on the drive.  As we have only copied the OS files, we need to install grub onto the MBR.  If you ignored me and mounted /dev/sda1 then you will fail and grub will complain!!
type "grub" to enter the grub command line interface.
type "root (hd0,0)"  This will return the format of the file system ie 0x83
type "setup (hd0)"  This will return several lines of "stage" files if successful.

That's it.. job done.  Exit the chroot by typing "exit" and "reboot".

Now... the pros and cons for me for this setup is although I now have the redundancy should a drive die, there is *NO* performance boost at all.  Infact, upgrading to SATAIII only gained me approx 10Mb/s increase.

# hdparm -tT /dev/sda

/dev/sda:
Timing cached reads:   11322 MB in  2.00 seconds = 5664.09 MB/sec
Timing buffered disk reads: 286 MB in  3.00 seconds =  95.26 MB/sec

# hdparm -tT /dev/sda

/dev/sda:
Timing cached reads:   10200 MB in  2.00 seconds = 5102.15 MB/sec
Timing buffered disk reads: 272 MB in  3.00 seconds =  90.56 MB/sec

# hdparm -tT /dev/sda

/dev/sda:
Timing cached reads:   10500 MB in  2.00 seconds = 5252.27 MB/sec
Timing buffered disk reads: 276 MB in  3.02 seconds =  91.33 MB/sec

I found the below info on a forum regarding slow performance, but I also read elsewhere that SATAIII is a complete waste of time with mechanical drives.

fdisk -H 224 -S 56 /dev/sdb

running fdisk with these parameters ensures that every partition you create is aligned to 4KiB boundaries.  I have not run the above command, this is something for me to test when I have time.