File: nielsen.html

package info (click to toggle)
lg-issue45 2-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,464 kB
  • ctags: 159
  • sloc: makefile: 36; sh: 4
file content (350 lines) | stat: -rw-r--r-- 11,418 bytes parent folder | download | duplicates (2)
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<title>Stripping and Mirroring RAID under RedHat 6.0 LG #45</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!--endcut ============================================================-->

<H4>
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>

<P> <HR> <P> 
<!--===================================================================-->

<CENTER>
<H1><font color="maroon">Stripping and Mirroring RAID under RedHat 6.0</font></H1>
<H4>By <a href="mailto:dude@linux.com">Mark Nielsen</a></H4>
</CENTER>
<P> <HR> <P>  


<h2>Index:</h2>

<ol>
<li> <a href="#Resources"> Resources</a>
<li><a href="#Intro"> Introduction to RAID</a>
<li><a href="#Strip"> Setting up a RAID Strip </a>
<li><a href="#Mirror"> Setting up a RAID Mirror </a>
<li><a href="#5"> RAID 5 with a spare device </a>
<li><a href="#Comments"> Comments</a>
</ol>

Future updates for this article will be located at
<a href="http://www.tcu-inc.com/mark/articles/Raid.html">
http://www.tcu-inc.com/mark/articles/Raid.html</a>.

<hr>
<a name="Resources"></a>
<h2>Resources</h2>
<ol>
<li> <a href="http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/">
http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/</a>
<li> /usr/doc/raidtools-0.90
</ol>

These links are hardware specific which go beyond the scope of this article.

<ol>
<li> Here is a DPT HOWTO,  
<a href="http://www.ram.org/computing/linux/dpt_raid.html">
 http://www.ram.org/computing/linux/dpt_raid.html</a>
</ol>

<hr>
<a name="Intro"></a>
<h2>Introduction to RAID</h2>
It is assumed that you will read the 
<a href="http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/">
The Software-RAID HOWTO</a> by jakob@ostenfeld.dk. Apparently, he comes
from Danmark (not Denmark), which is, of course, the best country in the world
where a lot of smart people are located. Anyways, he does such a good job
at his HOWTO, this article is probably not necessary. I only started
this because the documentation
used to suck really bad, which doesn't appear to be the case anymore. 
Also, this setup is specific for RedHat 6.0, but it should work
with any distribution. When am I going to switch to Debian for good?
Soon I hope. 
<p>
What is RAID? Well, it basically gives you the power to do some funky 
stuff with multiple hard drives. It lets you combine hard drives, split
data amongst several hard drives, and do other things. It can increase
the speed to write and read your data to your hard drives and it can make
backup copies of your hard drives so that if one hard drive crashes, you
can most likely retrieve all your data.    
Read more about the 
<a href="http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/Software-RAID.HOWTO-2.html#ss2.3">
RAID Levels</a> 

from 
<a href="http://ostenfeld.dk/~jakob/Software-RAID.HOWTO/Software-RAID.HOWTO-2.html#ss2.3">
The Software-RAID HOWTO
</a> right now to get a better idea about the different types of 
Software RAID. 
<p>
Also, you will need to setup several small partitions for this example. 
I suggest having 1 gig of diskspace free for an extended partition, and then
to make 100 meg logical partitions out of the extended partition. Also, PLEASE
PLEASE PLEASE only test raiding on a hard drive you don't care about. If you
screw it up, it is your fault, even if my documentation is incorrect. 

<hr>
<a name="Strip"></a>
<h2>Strip RAID</h2>
I am ONLY going to show you how to setup a strip for DATA only. This means,
I won't be stripping the main operating system. There can be problems
trying to strip an entire system, and so, I won't do it here. 

<p>
There are basically 4 steps to setup a Strip RAID on your Linux system. 
Stripping puts data on two or more hard drives (actually partitions) where
half the data is on one hard drive and the other half on the other. This
increases your speed since you use BOTH the hard drives at the same time to
get each half of the data. Again, please read more about this in the 
HOWTO. 
<p>
First, we need to configure /dev/md0, then we need to initialize the 
partitions, and then we need to configure /etc/rc.d/rc.local to activate
the raid, and then we need to configure /etc/rc.d/rc.local to mount the
stripped device to a directory. 

<p><b> The Steps</b>

Well, I am going to do a trick. Instead of actually using two hard drives, 
I am going to assume that most of the low-end users don't have two hard 
drives. Hence, I will use two partitions on the same hard drive. Make
an extended partition with two logical partitions, /dev/hda5 and /dev/hda6, 
which should be the same size. Stripping two partitions on the same hard drive
is almost pointless, and even on the same IDE controller it is almost
pointless. Still, this is just an EXERCISE. 
  
<ol> 
<li> Configure /etc/raidtab with this text 
<pre>
raiddev /dev/md0
          raid-level      0
          nr-raid-disks   2
          nr-spare-disks  0
          chunk-size     4
          persistent-superblock 1  
          device          /dev/hda5
          raid-disk       0
          device          /dev/hda6
          raid-disk       1
</pre>

<li> Format the partitions with the command
<pre>
mkraid /dev/md0
</pre>

If you have problems with using the "mkraid" command, it will tell you how
to get around any problems. Then issue this command
<pre>
mkfs -t ext2 /dev/md0
</pre>
Also, check out the status of your raid by looking at the "/proc/mdstat"
file/.
<pre>
cat /proc/mdstat
</pre>

<li> Execute this command which will add a line to /etc/rc.d/rc.local 
<pre>
echo "raidstart /dev/md0" >> /etc/rc.d/rc.local
</pre>

<li> Execute this command once. It will make you the directory for
the RAID device and add a command to /etc/rc.d/rc.local.
<pre>
mkdir /RAID
echo "mount /dev/md0 /RAID" >> /etc/rc.d/rc.local 
</pre>

<li> If you don't want to reboot your computer, and you want to activate
the raid now, 
<pre>
raidstart /dev/md0
mount /dev/md0 /RAID
</pre>
Also, check out the status of the mounted directory by issuing the single
command
<pre>
df
</pre>

</ol>

<hr>
<a name="Mirror"></a>
<h2>Mirror RAID</h2>

Like the example for stripping, I will use two partitions on the same
hard drive and I will only mirror partitions that are used for data. 
<p> 

<p>
First, we need to configure /dev/md0, then we need to initialize the
partitions, and then we need to configure /etc/rc.d/rc.local to activate
the raid, and then we need to configure /etc/rc.d/rc.local to mount the
mirrored device to a directory.

<ol>
<li> Configure /etc/raidtab with this text
<pre>
raiddev /dev/md0
          raid-level      1
          nr-raid-disks   2
          nr-spare-disks  0
          chunk-size     4
          persistent-superblock 1
          device          /dev/hda5
          raid-disk       0
          device          /dev/hda6
          raid-disk       1
</pre>

<li> Format the partitions with the command
<pre>
mkraid /dev/md0
</pre>

If you have problems with using the "mkraid" command, it will tell you how
to get around any problems. Then issue this command
<pre>
mkfs -t ext2 /dev/md0
</pre>
Also, check out the status of your raid by looking at the "/proc/mdstat" 
file/. 
<pre> 
cat /proc/mdstat
</pre> 

<li> Execute this command which will add a line to /etc/rc.d/rc.local
<pre>
echo "raidstart /dev/md0" >> /etc/rc.d/rc.local
</pre>

<li> Execute this command once. It will make you the directory for
the RAID device and add a command to /etc/rc.d/rc.local.
<pre>
mkdir /RAID
echo "mount /dev/md0 /RAID" >> /etc/rc.d/rc.local
</pre>

<li> If you don't want to reboot your computer, and you want to activate
the raid now, 
<pre>
raidstart /dev/md0
mount /dev/md0 /RAID
</pre>

Also, check out the status of the mounted directory by issuing the single
command
<pre>
df
</pre>


</ol>

<hr>
<a name="5"></a>
<h2>RAID 5 with a spare partition</h2>

Okay, RAID 5 with a spare device is a  VERY cool thing to do. Again, we will
just be using one hard drive. Generally, for experimenting, I would just
use 100 meg logical partitions. If you have a 1 gig extended partition, you
can have 10 logical partitions for goofing around with.   
<p>
Use the same steps for the Mirror or Strip, just change the config file to
this.  

<pre>
raiddev /dev/md0
        raid-level      5
        nr-raid-disks   7
        nr-spare-disks  1
        persistent-superblock 1
        parity-algorithm        left-symmetric
        chunk-size      32
        device          /dev/hda5
        raid-disk       0
        device          /dev/hda6
        raid-disk       1
        device          /dev/hda7
        raid-disk       2
        device          /dev/hda8
        raid-disk       3
        device          /dev/hda9
        raid-disk       4
        device          /dev/hda10
        raid-disk       5
        device          /dev/hda11
        raid-disk       6
   ### Also, let us have a spare device  
        device         /dev/hda12
        spare-disk     0
</pre>

<hr>
<a name="Comments"></a>
<h2>Comments</h2>

Mount the raid device in /etc/rc.d/rc.local and don't bother putting it
into /etc/fstab. If you want to put it into /etc/fstab, go ahead and try. 
It probably won't work, but sometimes people just like to see it for 
themselves (like I do). I like the power to shoot myself in the foot. It
makes the surgery interesting. 
<p>

Well, it is pretty freaking cool. The documentation used to really 
suck rocks, but that howto has been updated, the tools seem easier to use, 
and with these few examples, and amateur who knows how to use Linux can
probably setup a raid device. Hopefully this will reduce the overall cost
of RAID servers. 
<p>
If you really want to do Software raiding 
correctly, get an U2W SCSI controller, like
an Adaptec controller or other good brands, DPT, Mylex, etc. For cheap
raids where you are just mirroring and don't care about speed, IDE
hard drives are okay. If you want to go one step beyond software raid and
to get into hardware raid, then several companies support hardware raid
for Linux. 

<hr>
<i>
<a href="mailto:mark@tcu-inc.com">Mark</a>
 works as a receptionist (shorts and tee-shirt)
at 
<a href="http://www.tcu-inc.com"> The Computer Underground</a> 
and as a professional (suit and tie) consultant at 
<a href="http://www.800linux.com">
800linux.com</a>. In his spare time, he does volunteer stuff, like writing
these documents to help stop entities which thrive on the
ignorant. I wonder which company is like that? 
Edited using emacs and ispell.  
</i>
   
<!--===================================================================-->
<P> <hr> <P> 
<center><H5>Copyright &copy; 1999, Mark Nielsen <BR> 
Published in Issue 45 of <i>Linux Gazette</i>, September 1999</H5></center>

<!--===================================================================-->
<!--startcut ==========================================================-->
<P> <hr> <P> 
<A HREF="lg_toc45.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="gibbs/Linux_java.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="orr.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P> 
</BODY>
</HTML>
<!--endcut ============================================================-->