Next Previous Contents

31. Software RAID 0 (striping) Hard drives

If you didn't notice in Section 4, this TrinityOS enabled server (Roadrunner) has (7) hard drives and (2) CD-ROMS running on it now. Four IDE HDs are in the main system case and the other (3) SCSI HDs and (1) tape drive is in an old AT-style computer case.

To pull this off, I ordered a SCSI cable that has (2)external HD50pin SCSI-2-Fast connectors on it and 8 internal SCSI 50-pin internal ribbon cable connectors in the middle. I bought this from http://www.corpsys.com [part num: SCSI28] for ~$59. I then used one of my old AT-style cases with its power supply. With all this, I now have a external RAID box! It's no hot-swap cage but it works. Anyway, the following section will tell you how to implement RAID 0 (Striping) in software. Changing the configs to Linear, RAID-1, or RAID-5 won't be hard as long as you can afford the lost capacity or afford the extra disks.

- Download ALL the various version of the RaidTools from the URL in Section 5

The reason to download ALL of the available versions is that I've noticed that some of the versions in the past would NOT compile. Other versions didn't have all the docs, etc. In the past, the Raidtools has been in in a sad state right now but it DOES work nicely once you put it all together.

NOTE:

You will notice that there is both a Software-RAID HOWTO and a Software-RAID-0.4x on the various Linux mirrors. The reason for this is that the 0.4x HOWTO only covered the 2.0.x kernels and was more of a FAQ. The new howto covers the newer 2.2.x Software RAID (via a patch) or the 2.4.x kernels.

Anyway, from here on out, assume I'm using the new Raidtools-0.90 system

- Download and install the newest available kernel found in Section 5 into /usr/src/kernel/linux

- Next, download the newest Raidtools patch for your kernel (URL is in section 5 and also put it in /usr/src/kernel/linux. Don't worry about this code being in the "Alpha" directory, this stuff is VERY stable.

- Apply the patch by running the following comment (for a 2.2.19 kernel): patch -p1 < raid-2.2.19-A1

- Now run "make config" (if you haven't already done this as shown in Section 11)

- Configure the kernel as you normally would but, in the HD hardware support section, enable the following (you can make these modules if you wish but I recommend the monolithic approach):


Multiple devices driver support (CONFIG_BLK_DEV_MD) [Y/n/?] Y
Autodetect RAID partitions (CONFIG_AUTODETECT_RAID) [Y/n/?] Y
   Linear (append) mode (CONFIG_MD_LINEAR) [N/y/m/?] N 
   RAID-0 (striping) mode (CONFIG_MD_STRIPED) [Y/m/n/?] Y
   RAID-1 (mirroring) mode (CONFIG_MD_MIRRORING) [Y/m/n/?] Y
   RAID-4/RAID-5 mode (CONFIG_MD_RAID5) [Y/m/n/?] Y
   Translucent mode (CONFIG_MD_TRANSLUCENT) [Y/m/n/?] N
   Hierarchical Storage Management support (CONFIG_MD_HSM) [N/y/m/?] N
      Boot support (linear, striped) (CONFIG_MD_BOOT) [Y/n/?] Y

- Now make the kernel as normal with either "make dep; make clean; make bzImage; make modules; make modules_install" or just use TrinityOS's "built-it" script.

- Now, install the kernel into lilo, LOADLIN, etc. and reboot (shown in Section 13 & [ Section 14]).

- Once the box has rebooted, you might not need to compile up the Raidtools-0.90 archive. To verify this, try running "/sbin/mkraid -V". If the program is found and it reports version 0.90.0 then you don't need to do anything. If the program is NOT found, please follow these instructions:

- Uncompress the raidtools-0.90 archive ("tar -xzvf" for .tar.gz or "tar xvIf" for tar.bz2)

- cd into the created directory and run "./configure"

- Then run run "make all" and "make install"

- Hopefully everything went ok

- Now that you have the utilities and your kernel is ready to do, you need to edit your system init files to properly bring up the md0 software-raid service.

!!!NOTE!!! These example configs ASSUME that the partitions to be RAIDed are /dev/hda1 and /dev/sda1. Modify your configs to reflect your own environment!!!

!!!NOTE #2 Some distributions support Software-RAID automatically. To verify if this is so, look in the /etc/rc.d directory with this command:

"rgrep -r -i raid /etc/rc.d"

If anything is found (Redhat and Mandrake have it configured in /etc/rc.d/rc.sysinit), you can just use that setup though they are out of date with the use of "Auto-Dectection" partitions.

- To create a "Auto-Detected" RAID partition, you need to set each one of the HD's RAID partition to type "fd" and NOT the normal ext2, reiserfs, etc.


# /sbin/fdisk /dev/hda

The number of cylinders for this disk is set to 1860.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hda: 255 heads, 63 sectors, 1860 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1      1860  14940418+  fd  Linux raid autodetect

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.

- For users that don't want to use Auto-Detect RAID or those users without a RAID-enabled distro, create the following file:

/etc/rc.d/rc.raid


#!/bin/sh

# See how we were called.
case "$1" in

    start)
       #Start up the RAID subsystem - not needed for auto-detect
       /sbin/mkraid /dev/md0 
       echo "Disks added"
       /sbin/raidstart /dev/md0
       echo "Raid -RAID0- started on /dev/md0"
    ;;

    manual)
       #Start up the RAID subsystem - not needed for auto-detect
       /sbin/mkraid /dev/md0 
       echo "Disks added to /dev/md0"
       /sbin/raidstart /dev/md0
       echo "Raid RAID0 started on /dev/md0"
       /bin/mount -t ext2 /dev/md0 /mnt/raid
    ;;

    stop)
       echo "/dev/md0 umounted"
       /bin/umount /dev/md0
       echo "/dev/md0 stopped"
       /sbin/raidstop /dev/md0
    ;;
                        
    *)
       echo "Usage: rc.raid {start|stop}"
       exit 1

esac
exit 0

Once you have created this script file, make it executable by running "chmod 700 rc.raid"

+++ Older Redhat users ( 5.0-5.2), edit the /etc/rc.d/rc.sysinit (find the following lines and insert the following lines (around line 159):


                        /etc/rc.d/rc.sysinit  
                        --
                        if [ -x /sbin/kerneld -a -n "$USEMODULES" ]; then
                            if [ -f /proc/sys/kernel/modprobe ]; then
                                # /proc/sys/kernel/modprobe indicates built-in kmod instead
                                echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
                            else
                                /sbin/kerneld
                                KERNELD=yes
                            fi
                        fi

                        # Start the initialization of the MD0 RAID service
                        /etc/rc.d/rc.raid start

                        # Check filesystems
                        if [ ! -f /fastboot ]; then
                        echo "Checking filesystems."
                        fsck -R -A -V -a $fsckoptions
                        .
                        .
                        .
                        --

+++ Slackware users, edit the /etc/rc.d/rc.S file, find the following text and append the following:


                        /etc/rc.d/rc.S
                        --
                        # remove /etc/mtab* so that mount will create it with a root entry
                        /bin/rm -f /etc/mtab* /etc/nologin /var/run/utmp \
                          /etc/shutdownpid /var/run/*.pid

                        # Start the initialization of the MD0 RAID service
                        /etc/rc.d/rc.raid start
                        --

All Distributions:

Though I recommend to read the Software-RAID HOWTO to get all the details, here is an example for:

- A RAID-0 (striped or additive capacity) RAID setup - with (2) HDs on - /dev/hda1 - /dev/sda1

/etc/raidtab


raiddev /dev/md0

#Linear is "linear", RAID0-stripe = "0", RAID1-mirror = "1", RAID5-volume = "5"
raid-level      0

#Number of drives you are RAIDing together
nr-raid-disks   2

#File system stuff
persistent-superblock 1

#Changing this will change performance for your system based on file
# sizes, placement, etc.  Dont change this unless you plan to reformat
# the RAID volume.
chunk-size     4

#List and number the drives in the RAID volume
device          /dev/hda1
raid-disk       0
device          /dev/sda1
raid-disk       1

NOTE: There is several raidtab options that can increase performance, etc (stripe size, Inodes..). For now.. I'm just shooting for functionality but the stock performance is pretty good. Please see the Software-RAID howto for more details.

- Ok, so lets start things up MANUALLY to make sure things are ok.

- FIRST, triple check the /etc/raidtab file!! If you have the wrong drive or partition in there, KISS THAT DATA GOODBYE!

- Ok, run the command "/sbin/mkraid /dev/md0". You should see something like the following:


handling MD device /dev/md0
analyzing super-block
disk 0: /dev/hda1, 14940418kB, raid superblock at 14940352kB
disk 1: /dev/sdb1, 8890352kB, raid superblock at 8890240kB

- Next, make sure the kernel thinks things are ok


# cat /proc/mdstat 

Personalities : [raid0] [raid1] [raid5] [translucent] 
read_ahead 1024 sectors
md0 : active raid0 sdb1[1] hda1[0] 23830592 blocks 4k chunks
unused devices: >none<

- Ok, if all is well, just format the /dev/md0 device with your filesystem of choice. For me, I still use EXT2. So, as an example, just run:

mke2fs /dev/md0

NOTE: There is some mke2fs options to increase performance, etc (stripe size, Inodes..). For now.. I'm just shooting for functionality but the stock performance is pretty good. Please see the mke2fs man page for details.

- Once things are formatted, mount it:

mkdir /mnt/raid mount /dev/md0 /mnt/raid

if things went ok, you should have just received the UNIX prompt. So.. check it with the "df" command:


               # df
               Filesystem       1k-blocks      Used Available Use% Mounted on
               /dev/sda7          2055600   1470712    480468  75% /
               /dev/md0          23456268        20  22264720   0% /mnt/raid

- Ok, so lets make sure this is mounted after reboots, etc. edit the /etc/fstab file to automatically mount this new RAID setup to some mount point. Please note that TrinityOS does NOT cover booting root partitions ( / ) off of Software-RAID setups. Please see the Software-RAID howto on how to do this.

Anyway, here is an example of mounting the RAID setup on /mnt/raid:


#RAID volume    mount point     FileSys  FS options   Dump fsck order
/dev/md0        /mnt/raid0       ext2    defaults        1 2

- For older setups or people NOT using Auto-Detect RAID:

- Go ahead and type in "/etc/rc.d/rc.raid start"

- If you get any errors about /dev/md0 not existing, run the command "/dev/MAKEDEV md0" and the run the script again. Yes.. use the CAPs.

- Ok, things are cool! Reboot! Make sure things are STILL cool!


Next Previous Contents