File: raid.html

package info (click to toggle)
lg-issue17 3-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 2,480 kB
  • ctags: 182
  • sloc: makefile: 30; sh: 3
file content (192 lines) | stat: -rw-r--r-- 6,083 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<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="./lg_toc17.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif" 
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../lg_frontpage.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>