Generally, RAID (Redundant Array of Inexpensive Disks) is found on expensive
corporate servers, where performance and reliability matter most. Such servers
generally use SCSI RAID cards that allow RAID modes 0-5 on SCSI disks.
For the home user, SCSI drives and SCSI RAID cards are often overkill, not to
mention very expensive. The alternative is IDE RAID, which requires either
an add-on RAID controller card (approx. $100 retail), or an integrated
motherboard RAID controller. The latter usually tends to be a form of software
RAID (that only works in Windows), not true hardware raid.
There are multiple modes of RAID, each with tradeoffs between speed and data
redundancy. The highest-performing mode is RAID 0, which evenly distributes disk
writes and reads across all member disks of the RAID array. While this mode
offers zero redundancy, it boosts the speed of two drives working together to
greatly outperform a single drive acting alone.
This tutorial will show you how to create a high-performance RAID-0 setup using
two IDE hard drives and NO hardware RAID controller. The Linux community has
created a form of software RAID that is available for free, and is not tied to any
specific vendor hardware. This should result in a huge jump in I/O performance
on your system.
The price of this performance boost is some additional CPU usage; however
most Gentoo systems are built on modern CPU's of a gigahertz or more,
which is more than enough power to drive the array without impacting system performance.
You'll need two IDE hard drives of equal (or almost equal) size. It does not
matter if the drives come from different hardware vendors, but they must be as
close to the same size as possible. (Note: if the size of each drive
differs substantially, the RAID array will shrink to be double the size of the
smallest drive in the array, regardless of whether one drive is larger.)
This document is meant to be used in tandem with the Gentoo Linux Installation
Instruction document. You will need to swap between that document and this one
during installation, paying attention to where the steps differ.
(Note: I owe a great deal of credit for this document to Chris Atwood,
whose RAID-1 directions got me started.)
This tutorial assumes you have both drives connected to your IDE controller. The
ideal setup for maximum performance is for each drive to be set as "master" and
connected to a separate IDE channel. If you have other devices (such as a CDROM)
as slave drives on the same channel, you may experience some performance degradation.
Let's walk through it:
1) Boot the Gentoo LiveCD.
2) Load the module for multi-device support:
# modprobe md
3) Configure networking
4) Set your system date/time.
5) Filesystems, partitions and block devices step:
Follow the Gentoo guidelines of creating /boot, swap, and / partitions, but
create IDENTICAL partitions of the SAME SIZE on BOTH drives. Each physical drive
should look identical to the other, in terms of partitioning. When choosing
the partition type, be certain to select type 83 Linux for the /boot partition.
DO NOT make it a RAID partition. Make the swap partition a type 82 swap, and
make the large / partition type FD (Linux RAID autodetect).
(Note: A software RAID array is not bootable, so you need to use a separate
/boot partition that is not part of the array)
6) Create an /etc/raidtab file. This file maps virtual RAID drives to physical
partitions, and is required for your array to function. If your drives are of
different sizes (which is not recommended), the smaller of the two drives should
be raid-disk 0 in this file.
# / partition
raiddev /dev/md0 # raid device name
raid-level 0 # raid 0
nr-raid-disks 2 # number of disks in the array
chunk-size 32 # stripe size in kilobytes
persistent-superblock 1
device /dev/hda3 # device that comprises the raid array
raid-disk 0 # disk positing index in array
device /dev/hdc3 # device that comprises the raid array
raid-disk 1 # disk position index in array
For more information on the parameters of this configuration file, see the man
page here:
http://leaf.sourceforge.net/devel/cstei ... .5.man.htm
7) Creating filesystems step:
Run the mkdraid command to create the RAID device
# mkraid --really-force /dev/md0
(ignore the scary warnings here)
Type the command cat /proc/mdstat to verify the success of this operation:
# cat /proc/mdstat
Personalities : [raid0]
read_ahead 1024 sectors
md0 : active raid0 ide/host0/bus1/target0/lun0/part3[1]
ide/host0/bus0/target0/lun0/part3[0]
74100352 blocks 32k chunks
This command will show you detail on your RAID drive.
Next create standard EXT3 filesystems for the /boot and RAID virtual drive
partitions:
# mke2fs -j /dev/md0
# mke2fs -j /dev/hda1
Create the swap space on each physical drive and turn it on:
# mkswap /dev/hda2
# swapon /dev/hda2
# mkswap /dev/hdc2
# swapon /dev/hdc2
Note, swap space will not be RAID'ed, but used efficiently by the kernel
via an entry we will make in /etc/fstab.
# mount /dev/md0 /mnt/gentoo
# mkdir /mnt/gentoo/boot
# mount /dev/hda1 /mnt/gentoo/boot
9) Stage tarballs and chroot step:
Copy the /etc/raidtab file your created into the Gentoo chroot:
# cp /etc/raidtab /mnt/gentoo/etc/raidtab
10) Follow all usual Gentoo bootstrapping steps until you come to the Installing
the kernel and a System Logger stage.
In addition to what is normally needed in the kernel by Gentoo, you must compile
in support for RAID devices and raid level 0. Do NOT compile them as modules.
These settings can be found under:
Multi-device support (RAID and LVM)" section. In this section, enable the
following:
Multiple devices driver support (RAID and LVM)
RAID support
RAID-0 (striping) mode
Follow all normal kernel compilation steps.
11) Modifying /etc/fstab for your machine step:
You must alter the /etc/fstab file to account for the RAID virtual devices,
rather than the usual method of specifying physical devices. Your fstab should
look like the one below:
/dev/hda1 /boot ext2 noatime 1 2
/dev/md2 / ext3 noatime 0 1
/dev/hda2 swap swap defaults,pri=1 0 0
/dev/hdc2 swap swap defaults,pri=1 0 0
/dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro 0 0
Note that the two swap partions have the "pri=1" flag set. Setting a
priority of 1 tells the kernel to use each swap space with equal priority, and
to balance the load between them on a round-robin basis.
Continue following all standard instructions for Gentoo install.
12) The Configure a Bootloader section:
The grub.conf file needs to look like this:
default 0
timeout 10
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title=Gentoo Linux RAID
root (hd0,0)
kernel (hd0,0)/boot/bzImage root=/dev/md0
Note that we specify the kernel root as the RAID multiple device.
13) Your are done!! Reboot and you will be logged into your new RAID 0 system.
To verify everything is working, issue the "cat /proc/mdstat" command again, and
review the information provided.
You may now use your RAID'ed filesystem like any other standard Linux filesystem. Have fun with your "reborn" system!!



