"Linux Gazette...making Linux just a little more fun!"


Linux RAID Functions

by Jay Painter


RAID (Redundant Array of Inexpensive Disks) is used as a blanket term to describe a common set of functions which allow the manipulation of hard disk partitions. Some of the most common functions RAID provides are partition mirroring, appending, and stripping. These functions are described below:

RAID functions can either be implemented by software or by hardware. Hardware RAID arrays are embedded systems which are incredibly fast, and run in the $25,000-$50,000 price range. After they are configured, they plug into a normal SCSI port on the host computer and emulate a normal SCSI disk. Software implementations of RAID functions are not nearly as flexible or fast as hardware implementations, but software RAID is much cheaper.

The standard Linux kernel supports appending, and stripping RAID functions. Mirroring is available as a separate patch. Support for the RAID functions must be compiled into the kernel, and is referred as: Multiple Devices Driver Support. Below is a few lines out of a Linux 2.0.27 RAID kernel configuration.

Multiple devices driver support (CONFIG_BLK_DEV_MD) [Y/n/?] Y
   Linear (append) mode (CONFIG_MD_LINEAR) [Y/m/n/?] Y
   RAID-0 (striping) mode (CONFIG_MD_STRIPED) [Y/m/n/?] Y

After booting up with the new kernel, there will be a new entry in the /proc directory: mdstat. This file contains:

Personalities : [1 linear] [2 raid0]
read_ahead not set
md0 : inactive
md1 : inactive
md2 : inactive
md3 : inactive

md[0-3] are the default 4 meta-disk devices created by the Linux kernel. Although the number of meta-disk devices is configurable, the default is 4. Meta-disks are the combined RAID disks. They are formattable, and mountable like any other disk after they are configured and running.

Several software tools are also needed to configure and administrate RAID services. These are the 'md' tools: mdadd, mdrun, mdstop, and mdop. They are available at: sweet-smoke.ufr-info-p7.ibp.fr /pub/Linux.

The fist step in setting up a RAID disk is to choose two partitions on separate disks to use. This example will use the two SCSI disk partitions: /dev/sdb1 and /dev/sdc1 to create the appended(Linear) meta disk /dev/md0 which will be mounted as /morespace.

The file /etc/mdtab is usually used to define the configuration for the meta-disks. The format of this file is:

meta-device     RAID Mode     Disk Partition 1     Disk Partition 1

So the example's mdtab file would be:

/dev/md0        linear        /dev/sdb1            /dev/sdc1

Note that the order of the SCSI partitions is important. If the order is ever switched, all data will be lost and the meta-disk will have to be re-formatted

Now the mdadd program is used to enter this meta-disk configuration into the kernel, and the mdrun program is used to start the meta device:

mdadd -a
mdrun -a

The /proc file mdstat now reads:

Personalities : [1 linear] [2 raid0]
read_ahead 120 sectors
md0 : active linear sdb1 sdc1 2938880 blocks 4k rounding
md1 : inactive
md2 : inactive
md3 : inactive

The meta-disk is now ready to be formatted:

mke2fs /dev/md0

And mounted:

mount /dev/md0 /morespace

Now the meta-disk is ready for use. Only one detail remains: having the meta-disk started and running upon boot-up, so you can put the mount entry in /etc/fstab. The commands mdadd -a, and mdrun -a must be executed before /dev/md0 can be mounted. It is best to put these commands in the rc.boot file, before the root filesystem is re-mounted read-write.


Copyright © 1997, Jay Painter
Published in Issue 17 of the Linux Gazette, May 1997


[ TABLE OF CONTENTS ] [ FRONT PAGE ]  Back  Next