old-www/LDP/LG/issue17/raid.html

193 lines
5.9 KiB
HTML

<HTML>
<HEAD><TITLE>Linux RAID Functions Issue 17</TITLE></HEAD>
<BODY BGCOLOR="#EEE1CC" TEXT="#000000" LINK="#0000FF" VLINK="#0020F0"
ALINK="#FF0000">
<!--endcut ============================================================-->
<H4>
&quot;Linux Gazette...<I>making Linux just a little more fun!</I>&quot;
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H1>Linux RAID Functions</H1>
<H5>by Jay Painter</H5>
</center>
<P><HR> <P>
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:
</P>
<UL>
<LI>Mirroring: Two hard disk partitions are used to create one
partition, which is the size of the smallest component partition. Each
of the component partitions contain the same information, so if one disk
fails, the other takes over without any loss of data.
<LI>Appending(Linear): Two hard disk partitions are used to create one
partition, which is the combined size of the two component partitions.
In this method, one partition is just added on to the end of another.
<LI>Stripping(RAID-0): Two hard disk partitions are used to create one
partition, which is the combined size of the two component partitions.
In this method, the combined partition alternates between the two
component partitions. This turns out to be quit a bit faster than
linear appending, because the hard drives are now accessed in parallel.
</UL>
<P>
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.
</P>
<P>
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: <code>Multiple
Devices Driver Support</code>. Below is a few lines out of a Linux 2.0.27 RAID
kernel configuration.
</P>
<PRE>
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
</PRE>
<P>
After booting up with the new kernel, there will be a
new entry in the <code>/proc</code> directory: <code>mdstat</code>. This file
contains:
</P>
<pre>
Personalities : [1 linear] [2 raid0]
read_ahead not set
md0 : inactive
md1 : inactive
md2 : inactive
md3 : inactive
</PRE>
<P>
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.
</P>
<P>
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: <code>sweet-smoke.ufr-info-p7.ibp.fr /pub/Linux</code>.
<P>
<P>
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:
<code>/dev/sdb1</code> and <code>/dev/sdc1</code> to create the appended(Linear)
meta disk <code>/dev/md0</code> which will be mounted as
<code>/morespace</code>.
</P>
<P>
The file <code>/etc/mdtab</code> is usually used to define the
configuration for the meta-disks. The format of this file is:
</P>
<PRE>
meta-device RAID Mode Disk Partition 1 Disk Partition 1
</PRE>
<P>
So the example's <code>mdtab</code> file would be:
</P>
<PRE>
/dev/md0 linear /dev/sdb1 /dev/sdc1
</PRE>
<P>
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
</P>
<P>
Now the <code>mdadd</code> program is used to enter this meta-disk
configuration into the kernel, and the <code>mdrun</code> program is used to
start the meta device:
</P>
<PRE>
mdadd -a
mdrun -a
</PRE>
<P>
The <code>/proc</code> file <code>mdstat</code> now reads:
</P>
<PRE>
Personalities : [1 linear] [2 raid0]
read_ahead 120 sectors
md0 : active linear sdb1 sdc1 2938880 blocks 4k rounding
md1 : inactive
md2 : inactive
md3 : inactive
</PRE>
<P>
The meta-disk is now ready to be formatted:
</P>
<PRE>
mke2fs /dev/md0
</PRE>
<P>
And mounted:
</P>
<PRE>
mount /dev/md0 /morespace
</PRE>
<P>
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
<code>/etc/fstab</code>. The commands <code>mdadd -a</code>, and <code>mdrun
-a</code> must be executed before <code>/dev/md0</code> can be mounted. It is
best to put these commands in the <code>rc.boot</code> file, before the root
filesystem is re-mounted read-write.
</P>
<!--===================================================================-->
<P> <hr> <P>
<center><H5>Copyright &copy; 1997, Jay Painter <BR>
Published in Issue 17 of the Linux Gazette, May 1997</H5></center>
<!--===================================================================-->
<P> <hr> <P>
<A HREF="./index.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../index.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./expo.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./enl.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P>
<!--startcut ==========================================================-->
</BODY>
</BODY>
</HTML>