~ubuntu-branches/ubuntu/karmic/mdadm/karmic

« back to all changes in this revision

Viewing changes to debian/patches/80-rootraiddoc.dpatch

  • Committer: Package Import Robot
  • Author(s): Scott James Remnant
  • Date: 2007-12-12 22:35:09 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20071212223509-10l2hitpp068jr53
Tags: 2.6.3+200709292116+4450e59-3ubuntu1
* Merge from debian unstable, remaining changes:
 * md activation:
  - We now have a single udev rule for both the real system and the
    initramfs, since doing things differently there will only result in bugs
    and confusion.
  - This rule runs "mdadm --assemble --scan --no-degraded", automatically
    activating any non-degraded device as their components are detected.
  - Drop the mdadm-raid init script, since this does the same thing.
  - Also drop mdadm-startall which uses the mdadm-raid init script, and its
    associated sgml file (thus dropping the build-dep on docbook-to-man)
  - Simplify the configuration, since we always autostart all devices so do
    not need to specify any required root devices, etc.
  - Drop the deprecated mdrun entirely.
  - Since udev autostarts arrays, much of the initramfs script can be
    dropped.
 * Install a new udev rule at 65 which runs vol_id on clean raid arrays.
   This will cause lvm, etc. to be run (since there is vol_id information
   present for the enclosed filesystem).
 * Depend on initramfs-tools, specifically a version that doesn't ship
   the mdrun script.  This way we can clean out a lot of the upgrade handling
   from the initramfs hook.
 * Just get initramfs to load the modules for us

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh /usr/share/dpatch/dpatch-run
2
 
## 99-rootraiddoc.dpatch by martin f. krafft <madduck@debian.org>
3
 
##
4
 
## All lines beginning with `## DP:' are a description of the patch.
5
 
## DP: No description.
6
 
 
7
 
@DPATCH@
8
 
diff -urNad trunk~/rootraiddoc.97.html trunk/rootraiddoc.97.html
9
 
--- trunk~/rootraiddoc.97.html  1970-01-01 01:00:00.000000000 +0100
10
 
+++ trunk/rootraiddoc.97.html   2006-07-20 17:22:59.366389277 +0100
11
 
@@ -0,0 +1,1333 @@
12
 
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
13
 
+       <html>
14
 
+       <head>
15
 
+       <title>Convert Root System to Bootable Software RAID1 (Debian)</title>
16
 
+       <style type="text/css">
17
 
+body   {
18
 
+       color: black;
19
 
+       background-color: #ffffcc;
20
 
+       margin: 0% 6% 6%;
21
 
+       }
22
 
+h1     {
23
 
+       color: green;
24
 
+       margin: 3% 0% 2% -3%;
25
 
+       }
26
 
+h2     {
27
 
+       margin: 4% 0% 1% -3%;
28
 
+       font-weight: normal;
29
 
+       }
30
 
+.toc   {
31
 
+       padding: 0% 6% 6%;
32
 
+       border: solid #cccccc 1px;
33
 
+       }
34
 
+div.up {
35
 
+       cursor: pointer;
36
 
+       cursor: hand;
37
 
+       margin: 6% 0% 0% 0%;
38
 
+       padding: 4% 0% 0%;
39
 
+       border-bottom: solid #cccccc 1px;
40
 
+       }
41
 
+a.up   {
42
 
+       color: #cccccc;
43
 
+       text-decoration: none;
44
 
+       }
45
 
+.reboot        {
46
 
+       color: red;
47
 
+       background-color: white;
48
 
+       }
49
 
+.code  {
50
 
+       font-family: monospace;
51
 
+       margin: 0% 1% 2% 2%;
52
 
+       }
53
 
+.todo  {
54
 
+       color: green;
55
 
+       background-color: yellow;
56
 
+       padding: 1%;
57
 
+       }
58
 
+.note  {
59
 
+       border: dashed gray 1px;
60
 
+       padding: 1%;
61
 
+       margin: 0% 0% 2% 0%;
62
 
+       }
63
 
+p      {
64
 
+       margin: 1% 0%;
65
 
+       }
66
 
+       </style>
67
 
+       </head>
68
 
+       <body>
69
 
+
70
 
+
71
 
+
72
 
+
73
 
+
74
 
+
75
 
+       <!-- Header -->
76
 
+
77
 
+       <div style="background-color: #ffffcc; color: green; padding: 1%; border: double #66cc99 4px; margin: 2% 0%;">
78
 
+       <h1 style="margin: 1% 0%;">
79
 
+Convert Root System to Bootable Software RAID1 (Debian)</h1>
80
 
+       <p>
81
 
+How to convert a Debian system to bootable Software RAID 1 with a second hard drive, 'mdadm' and a few standard UNIX tools</p>
82
 
+       </div>
83
 
+
84
 
+       <p style="font-size: 80%">
85
 
+Version 0.97 (2004-06-03) Lucas Albers -- admin At cs DOT montana dot edu and Roger Chrisman <br />
86
 
+Home of most recent version: <a href="http://alioth.debian.org/projects/rootraiddoc" target="_blank">
87
 
+http://alioth.debian.org/projects/rootraiddoc</a><br />
88
 
+Thanks to: Alvin Olga, Era Eriksson, Yazz D. Atlas, James Bromberger, Timothy F Nagy, and alioth.debian.org<br />
89
 
+       <p><b>
90
 
+WARNING: No warranty of any kind. Proceed at your own risk.</b> A typo, especially in lilo.conf, can leave your system unbootable. <b>Back-up data and make a boot floppy <i>before starting this procedure</i>.</b></p>
91
 
+       </div> 
92
 
+
93
 
+       <!-- Table of Contents -->
94
 
+       <div id="TOC" class="toc">
95
 
+
96
 
+       <h1>Table of Contents</h1>
97
 
+
98
 
+       <h3><a href="#summary">
99
 
+Summary</a></h3>
100
 
+      
101
 
+       <h3><a href="#1">
102
 
+Procedure</a></h3>
103
 
+
104
 
+      <ol>
105
 
+        <li style="margin: 1% 0%;"><a href="#1">
106
 
+Install Debian</a><br />
107
 
+on your Primary Master disk -- hda. Or if you already have Debian installed, go to step 2.</li>
108
 
+        <li style="margin: 1% 0%;"><a href="#2">
109
 
+Upgrade to RAID savvy Kernel</a><br />
110
 
+and install 'mdadm'.</li>
111
 
+        <li style="margin: 1% 0%;"><a href="#3">
112
 
+Setup RAID 1</a><br />
113
 
+declaring disk-one 'missing' and disk-two hdc.</li>
114
 
+        <li style="margin: 1% 0%;"><a href="#4">
115
 
+Copy your Debian system</a><br />
116
 
+from hda to /dev/md0 ('missing' + 'hdc').</li>
117
 
+        <li style="margin: 1% 0%;"><a href="#5">
118
 
+Reboot to RAID device.</a><br /></li>
119
 
+        <li style="margin: 1% 0%;"><a href="#6">
120
 
+Reformat hda as 'fd' and declare it as disk-one of your RAID,</a><br />
121
 
+and watch the booted RAID system automatically mirror itself onto the new drive. Done.</li>
122
 
+       </ol>
123
 
+
124
 
+<h3>Alternate grub/initrd procedure</h3>
125
 
+<ol>
126
 
+        <li style="margin: 1% 0%;"><a href="#7">
127
 
+Part II. RAID using initrd and grub</a><br /> </li>
128
 
+</ol>
129
 
+
130
 
+       <h3><a href="#I">
131
 
+Appendix</a></h3>
132
 
+
133
 
+       <ol style="list-style-type: upper-roman;">
134
 
+               <li><a href="#I">
135
 
+RAID Introduction</a></li>
136
 
+               <li><a href="#II">
137
 
+Drive designators (hda, hdb, hdc, hdd), jumpers and cables</a></li>
138
 
+               <li><a href="#III">
139
 
+Setting up software RAID for multiple partitions</a></li>
140
 
+               <li><a href="#IV">
141
 
+Lilo</a></li>
142
 
+               <li><a href="#V">
143
 
+Copying Data</a></li>
144
 
+               <li><a href="#VI">
145
 
+Rebooting</a></li>
146
 
+               <li><a href="#VII">
147
 
+Initrd</a></li>
148
 
+               <li><a href="#VIII">
149
 
+Verify that system will boot even with one disk off-line</a></li>
150
 
+               <li><a href="#IX">
151
 
+Setting up a RAID 1 Swap device</a></li>
152
 
+               <li><a href="#X">
153
 
+Performance Optimizations</a></li>
154
 
+               <li><a href="#XI">
155
 
+Disaster Recovery</a></li>
156
 
+               <li><a href="#XII">
157
 
+Quick Reference</a></li>
158
 
+               </a></li>
159
 
+               <li><a href="#XIII">
160
 
+Troubleshooting </a></li>
161
 
+               <li><a href="#XIIII">
162
 
+Raid Disk Maintenance </a></li>
163
 
+       </ol>
164
 
+
165
 
+       <h3><a href="#references">
166
 
+References</a></h3>
167
 
+
168
 
+       </div>
169
 
+
170
 
+       <!-- Summary -->
171
 
+
172
 
+       <div id="summary" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
173
 
+^</a></div>
174
 
+       <h1>
175
 
+Summary</h1>
176
 
+       <p>
177
 
+We begin with Debian installed on the Primary Master drive, hda (<a href="#1">step 1</a>). We need RAID support in our Kernel (<a href="#2">step 2</a>). We add another disk as Secondary Master, hdc, set it up for RAID (<a href="#3">step 3</a>), and copy Debian to it (<a href="#4">step 4</a>). Now we can reboot to the RAID device (<a href="#5">step 5</a>) and declare hda part of the RAID and it automatically syncs with hdc to complete our RAID 1 device (<a href="#6">step 6</a>).</p>
178
 
+       <p>
179
 
+If all goes well</p>
180
 
+       <ul>
181
 
+        <li>You do not need a rescue disk or to boot off anything except the hard drive.</li>
182
 
+        <li>You can do this operation completely remotely.</li>
183
 
+        <li>And you will not lose any data.</li>
184
 
+       </ul>
185
 
+       <p style:"font-weight: bold; font-style: italic;">
186
 
+Use this HowTo at your own risk. We are not responsible for what happens!</p>
187
 
+       <p>
188
 
+First things first</p>
189
 
+      <ul>
190
 
+        <li>Backup your data.</li>
191
 
+        <li>Create a boot floppy.</li>
192
 
+      </ul>
193
 
+       <p>
194
 
+Whenever you change your partitions, you need to reboot! (If you know what you are 
195
 
+doing, ignore this advice.)</p>
196
 
+       <p>
197
 
+I assume you will mess up a step so wherever possible, we include verification.</p>
198
 
+       <p>
199
 
+I use 'mdadm' because it is easier than 'raidtools' or 'raidtools2'.</p>
200
 
+       <p>
201
 
+<br>We now have grub and lilo directions, grub directions are still in beta form. 
202
 
+<br>Read the grub directions, and comment on them.</p>
203
 
+
204
 
+
205
 
+
206
 
+
207
 
+       <!-- Procedure -->
208
 
+     
209
 
+
210
 
+       <div id="1" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
211
 
+^</a></div>
212
 
+       <h1 style="padding-bottom: 6%;">
213
 
+Procedure</h1>
214
 
+
215
 
+
216
 
+       <h1>
217
 
+1. Install Debian</h1>
218
 
+       <p>
219
 
+Do a fresh install the normal way on your first drive, hda (the Primary  Master drive in your computer).
220
 
+Or, if you already have a running Debian system that you want to use on hda; skip ahead to step 2. 
221
 
+If you need Debian installation instructions, see:</p>
222
 
+       <p>
223
 
+<a href="http://www.debian.org/releases/stable/installmanual" target="_blank">
224
 
+Debian Installation HowTo</a> &raquo;  http://www.debian.org/releases/stable/installmanual</p>
225
 
+        <p>
226
 
+<a href="http://d-i.alioth.debian.org/manual/" target="_blank">
227
 
+Sarge Debian Installation HowTo</a> &raquo;  http://d-i.alioth.debian.org/manual/</p>
228
 
+      
229
 
+       <div id="2" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
230
 
+^</a></div>
231
 
+       <h1>
232
 
+2. Upgrade to a RAID savvy Kernel</h1> 
233
 
+
234
 
+
235
 
+       <h2>
236
 
+2.1 Compile and install a RAID savvy Kernel.</h2> 
237
 
+       <p>
238
 
+RAID must be <i>compiled</i> into the Kernel, not added as a module, for you to boot from the RAID device (unless you use a RAID savvy initrd kernel or boot from a non-RAID boot drive. (I now cover initrd methods!). You need RAID 1 but I usually include RAID 5, too. For step by step Kernel compile and install instructions, see:</p>
239
 
+       <p><a href="http://newbiedoc.sourceforge.net/system/kernel-pkg.html" target="_blank">
240
 
+Creating custom Kernels with Debian's kernel-package system</a> &raquo; http://newbiedoc.sourceforge.net/system/kernel-pkg.html</p>    
241
 
+
242
 
+<br>
243
 
+
244
 
+       <h2>
245
 
+2.2 Verify your RAID savvy Kernel.</h2> 
246
 
+       <p class="code">
247
 
+cat /proc/mdstat</p>
248
 
+       <p>
249
 
+(You should see the RAID "personalities" your Kernel supports.)</p>
250
 
+Something like this:
251
 
+       
252
 
+<p class="code">
253
 
+Personalities : [linear] [raid0] [raid1] [raid5] 
254
 
+read_ahead 1024 sectors
255
 
+md4 : active raid5 hdh4[3] hdg4[2] hdf4[1] hde4[0]
256
 
+      356958720 blocks level 5, 64k chunk, algorithm 2 [4/4] [UUUU]
257
 
+      
258
 
+unused devices: <none>
259
 
+       <p>
260
 
+
261
 
+<p class="code">
262
 
+YOU MUST VERIFY you have raid support via /proc/mdstat.
263
 
+This is the most important item to verify before going any farther.
264
 
+So the kernel has to support it or you have to load the modules in initrd.
265
 
+<p>
266
 
+
267
 
+
268
 
+(This will show you if raid is compiled into kernel, or detected as a module from initrd.)
269
 
+/etc/modules will not list RAID if Kernel has RAID compiled in instead of loaded as modules. 
270
 
+       <br>
271
 
+       Use lsmod to list currently loaded modules, this will show raid modules loaded.
272
 
+       <p class="code">
273
 
+       reiserfs <br>
274
 
+raid1 <br>
275
 
+ext2 <br>
276
 
+ide-disk <br>
277
 
+raid5 <br>
278
 
+ext3 <br>
279
 
+       <p>
280
 
+cat /etc/modules</p>
281
 
+       <p>
282
 
+(IF YOU SEE ANY RAID LISTED IN /etc/modules, then you probably have your Kernel loading RAID via modules. That will prevent you from booting from your RAID device, unless you use initrd. To boot from your RAID device, unless you use a RAID savvy initrd, you need RAID <i>compiled into</i> Kernel, not added <i>as a module.</i>)</p>
283
 
+       <h2>
284
 
+
285
 
+
286
 
+<h2> 2.3 Install 'mdadm':</h2> 
287
 
+       <p class="code">
288
 
+apt-get install mdadm</p>
289
 
+2.4 List what IDE devices you have:</h2>
290
 
+<p class="code">
291
 
+ls /proc/ide</p>
292
 
+     
293
 
+       <div id="3" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
294
 
+^</a></div>
295
 
+       <h1>
296
 
+3. Setup RAID 1</h1> 
297
 
+       <p>
298
 
+Setup RAID 1 and declare disk-one of your RAID to be 'missing' and disk-two of your RAID to be 'hdc'.</p>
299
 
+
300
 
+
301
 
+       <h2>
302
 
+3.1 Create RAID (fd) partition on hdc</h2>
303
 
+       <p>
304
 
+Warning: ALWAYS give the partition when editing with cfdisk. By default cfdisk will select the first disk in the system. I accidentally wiped the wrong partition with cfdisk, once.</p>
305
 
+       <p>
306
 
+Do A or B, either way will work:</p>
307
 
+       <p>
308
 
+A. Create partitions on new disk.</p>
309
 
+       <p class="code">
310
 
+cfdisk /dev/hdc</p>
311
 
+
312
 
+       <p>or</p>
313
 
+
314
 
+       <p>B. copy existing partitions to new disk with sfdisk.</p>
315
 
+       <p class="code">
316
 
+sfdisk -d /dev/hda | sfdisk /dev/hdc</p>
317
 
+
318
 
+<br>NOTE: On some disks you cannot copy over the partitions correctly using this method 
319
 
+<br>It will detect the new partition as 0 size or a strange size.
320
 
+<br>You will need to manually create the partitions, making them the same size with cfdisk.
321
 
+<br>
322
 
+<h2>
323
 
+3.2 Create correct partition type signatures on new partition.</h2>
324
 
+       <p class="code">
325
 
+cfdisk /dev/hdc</p>
326
 
+
327
 
+      <ul>
328
 
+        <li>Select Type, then hit enter, then type 'fd' (this means RAID type partition).</li>
329
 
+        <li>Select Write</li>
330
 
+        <li>Select Quit.</li>
331
 
+      </ul>
332
 
+
333
 
+       <p class="code">
334
 
+<span class="reboot">reboot</span></p>
335
 
+       <p>
336
 
+(To verify that everything is working ok.)
337
 
+
338
 
+
339
 
+       <h2>
340
 
+3.3 Create RAID device</h2>
341
 
+       <p>
342
 
+that has two members and one of the members does not exist yet. md0 is the RAID partition we are creating, /dev/hdc1 is the initial partition. We will be adding /dev/hda1 back into the /dev/md0</p>
343
 
+       <p>
344
 
+RAID set after we boot into /dev/md0.</p>
345
 
+       <p class="code">
346
 
+mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/hdc1</p>
347
 
+       <p>
348
 
+If this gives errors then you need to zero the super block, see useful mdadm commands.</p>
349
 
+
350
 
+
351
 
+       <h2>
352
 
+3.4 Format RAID device </h2>
353
 
+       <p>
354
 
+You can use reiserfs or ext3 for this, both work, I use reiserfs for larger devices. Go with what you trust.</p>
355
 
+       <p class="code">
356
 
+mkfs.ext3 /dev/md0</p>
357
 
+       <p>
358
 
+or</p>
359
 
+       <p class="code">
360
 
+mkfs -t reiserfs /dev/md0</p>
361
 
+
362
 
+
363
 
+       <div id="4" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
364
 
+^</a></div>
365
 
+       <h1>
366
 
+4. Copy your Debian system</h1>
367
 
+       <p>
368
 
+Copy your Debian system from hda to /dev/md0 ('missing' + 'hdc'). Then, check to 
369
 
+make sure that the new RAID device is still setup right and can be mounted 
370
 
+correctly. We do this with an entry in hda's /etc/fstab and a reboot. Note that 
371
 
+by editing hda's /etc/fstab after the copy, instead of before, we leave the copy 
372
 
+on md0 unaltered and only are editing hda's /etc/fstab. </p>
373
 
+      
374
 
+
375
 
+       <p>
376
 
+<b>NB: THIS IS A BRANCH IN OUR SYSTEM CONFIGURATION (eg temporary!)</b>, but it 
377
 
+will overwritten later by the md0 version of /etc/fstab by the sync in step 6.</p>
378
 
+      
379
 
+
380
 
+       <h2>
381
 
+4.1 Create a mount point. </h2>
382
 
+       <p class="code">
383
 
+mkdir /mnt/md0</p>
384
 
+
385
 
+
386
 
+       <h2>
387
 
+4.2 Mount your RAID device. </h2>
388
 
+       <p class="code">
389
 
+mount /dev/md0 /mnt/md0</p>
390
 
+
391
 
+
392
 
+       <h2>
393
 
+4.3 Copy your Debian system to RAID device. </h2>
394
 
+       <p class="code">
395
 
+cp -axu / /mnt/md0</p>
396
 
+Please refer to the Copying data section to verify you copied the data correctly.
397
 
+<br>See <a href="#V">Copying Data</a>
398
 
+       <p>
399
 
+You don't need the -u switch; it just tells cp not to copy the files again if they exist. If you are running the command a second time it will run faster with the -u switch.</p>
400
 
+
401
 
+
402
 
+       <h2>
403
 
+4.4 Edit /etc/fstab so that you mount your new RAID partition on boot up.</h2>
404
 
+<p>
405
 
+This verifies that you have the correct partition signatures on the partition and that your partition is correct. Sample Line in <span class="code">/etc/fstab</span>:</p>
406
 
+       <p class="code">
407
 
+/dev/md0 /mnt/md0 ext3 defaults 0 0</p>
408
 
+       <p>
409
 
+Then</p>
410
 
+       <p class="code">
411
 
+<span class="reboot">reboot</span></p>
412
 
+       <p>
413
 
+And see if the RAID partition comes up.</p>
414
 
+       <p class="code">
415
 
+mount</p>
416
 
+       <p>
417
 
+Should show /dev/md0 mounted on /mnt/md0.</p>
418
 
+
419
 
+
420
 
+       <div id="5" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
421
 
+^</a></div>
422
 
+       <h1>
423
 
+5. Reboot to RAID device</h1>
424
 
+       <p>
425
 
+For step 5 reboot, we will tell Lilo that
426
 
+<ul>
427
 
+<li>as before, /boot and MBR are still on hda,<br />
428
 
+<li>and now we want root (/) to mount on md0.<br />
429
 
+</ul></p>
430
 
+       <p>
431
 
+We will, as before, be using hda's MBR (Master Boot Record is the first 512 bytes on a disk and is what the BIOS reads first in determining how to boot up a system) and hda's /boot dir (the kernel-image and some other stuff live here), but instead of mounting root (/) from hda, we will mount md0's root (/) (the root of our RAID device, currently running off of only hdc because we declared the first disk 'missing').
432
 
+
433
 
+
434
 
+       <h2>
435
 
+5.1 Configure Lilo to boot to the RAID device </h2>
436
 
+       <p>
437
 
+(Later we will configure Lilo to write the boot sector to the RAID boot device also, so we can still boot even if either disk fails.)</p>
438
 
+       <p>
439
 
+Add a stanza labeled 'RAID' to /etc/lilo.conf on hda1 so that we can boot with /dev/md0, our RAID device, as root (/):</p>
440
 
+       <p class="code">
441
 
+#the same boot drive as before.<br />
442
 
+boot=/dev/hda<br />
443
 
+image=/vmlinuz<br />
444
 
+label=RAID<br />
445
 
+read-only<br />
446
 
+#our new root partition.<br />
447
 
+root=/dev/md0</p>
448
 
+       <p>
449
 
+That makes an entry labeled 'RAID' specific to the RAID device, so you can still boot to /dev/hda if /dev/md0 does not work.</p>
450
 
+sample complete lilo.conf file:</p>
451
 
+       <p class="code">
452
 
+#sample working lilo.conf for raid.<br />
453
 
+#hda1,hdc1 are boot, hda2,hdc2 are swap<br />
454
 
+#hda3,hdc3 are the partition used by array<br />
455
 
+#root partition is /dev/md3 on / type reiserfs (rw)<br />
456
 
+#I named the raid volumes the same as the partition numbers<br />
457
 
+#this is the final lilo.conf file of a system completely finished,<br />
458
 
+#and booted into raid.<br />
459
 
+<br />
460
 
+<br />
461
 
+lba32<br />
462
 
+boot=/dev/md1<br />
463
 
+root=/dev/hda3<br />
464
 
+install=/boot/boot-menu.b<br />
465
 
+map=/boot/map<br />
466
 
+ prompt<br />
467
 
+ delay=50<br />
468
 
+ timeout=50<br />
469
 
+ vga=normal<br />
470
 
+ raid-extra-boot=/dev/hda,/dev/hdd<br />
471
 
+ default=RAID<br />
472
 
+ image=/boot/vmlinuz-RAID<br />
473
 
+ label=RAID<br />
474
 
+ read-only<br />
475
 
+ root=/dev/md3<br />
476
 
+ alias=1<br />
477
 
478
 
+ image=/vmlinuz<br />
479
 
+ label=Linux<br />
480
 
+ read-only<br />
481
 
+ alias=2<br />
482
 
+ <br />
483
 
+ image=/vmlinuz.old<br />
484
 
+ label=LinuxOLD<br />
485
 
+ read-only<br />
486
 
+ optional</p>
487
 
+
488
 
+
489
 
+       <h2>
490
 
+5.2 Test our new lilo.conf </h2>
491
 
+       <p class="code">
492
 
+lilo -t -v</p>
493
 
+       <p>
494
 
+(With a RAID installation, always run<span class="code"> lilo -t </span>first just to have Lilo tell you what it is about to do; use the<span class="code"> -v </span>flag, too, for verbose output.)</p>
495
 
+
496
 
+
497
 
+       <h2>
498
 
+5.3 Run Lilo </h2>
499
 
+       <p>
500
 
+Configure a one time Lilo boot via the<span class="code"> -R </span>flag and with a reboot with Kernel panic</p>
501
 
+       <p>
502
 
+The<span class="code"> -R &lt;boot-parameters-here&gt;</span> tells Lilo to only use the specified image for the next boot. So once you reboot it will revert to your old Kernel. </p>
503
 
+       <p>
504
 
+From 'man lilo':<br /><b>
505
 
+-R command line</b><br /> 
506
 
+This option sets the default command for the boot loader the next time it executes. The boot loader will then erase this line:  this  is  a once-only command. It is typically used in reboot scripts, just before calling `shutdown -r'.  Used without any arguments, it will cancel a lock-ed or fallback command line.</p>
507
 
+       <p> Before you can do the 'lilo -v -R RAID' command, you must first do a 'lilo' command to update the Lilo boot record with the contents of your new lilo.conf. Otherwise Lilo does not know what you mean by 'RAID' and you just get a 'Fatal: No image "RAID" is defined' error message when you do 'lilo -v -R RAID'. So,</p>
508
 
+       <p class="code">
509
 
+lilo<br />
510
 
+lilo -v -R RAID</p>
511
 
+
512
 
+
513
 
+       <h2>
514
 
+5.4 Edit /mnt/md0/etc/fstab and reboot</h2>
515
 
+       <p>
516
 
+to have /dev/md0 mount as root (/), when Lilo boots from our RAID device, /dev/md0.</p>
517
 
+       <p>
518
 
+Previous root (/) in fstab was:</p>
519
 
+       <p class="code">
520
 
+/dev/hda1 / reiserfs defaults 0 0</p>
521
 
+       <p>
522
 
+Edit it to:</p>
523
 
+       <p class="code">
524
 
+/dev/md0 / ext3 defaults 0 0</p>
525
 
+       <p>
526
 
+Note: edit /mnt/md0/etc/fstab, not /etc/fstab, because at the moment we are booted with hda1 as root (/) but we want to change the /etc/fstab that we currently have mounted on /mnt/md0/etc/fstab, our RAID device.</p>
527
 
+       <p>
528
 
+Reboot to check if system boots our RAID device, /dev/md0, as root (/). If it does not, just reboot again and you will come up with your previous boot partition courtesy of the<span class="code"> -R </span>flag in step 5.3 above.</p>
529
 
+       <p class="code">
530
 
+<span class="reboot">reboot</span></p>
531
 
+       <p>
532
 
+Verify /dev/md0 is mounted as root (/)</p>
533
 
+       <p class="code">
534
 
+mount</p>
535
 
+       <p>
536
 
+should show:</p>
537
 
+               
538
 
+       <p class="code">
539
 
+/dev/md0 on / type reiserfs (rw)<br />
540
 
+proc on /proc type proc (rw)<br />
541
 
+devpts on /dev/pts type devpts (rw,gid=5,mode=620)</p>
542
 
+       <p>
543
 
+'type reiserfs' is just my example; you will see whatever your file system type is.</p>
544
 
+       <p>
545
 
+Now we are booted into the new RAID device -- md0 as root (/). Our RAID device only has one disk in it at the moment because we earlier declared the other disk as 'missing'. That was because we needed that other disk, hda, to install Debian on or because it was our pre-existing Debian system.</p>
546
 
+
547
 
+
548
 
+       <div id="6" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
549
 
+^</a></div>
550
 
+       <h1>
551
 
+6. Reformat hda as 'fd' and declare it as disk-one of your RAID</h1>
552
 
+
553
 
+       <p>
554
 
+For step 6 reboots, we tell Lilo that
555
 
+<ul>
556
 
+<li>as in step 5 above, our root (/) is now on md0.</li>
557
 
+<li>and now, /boot is also on md0,</li>
558
 
+<li>and MBR is on both hda and hdc.</li>
559
 
+</ul></p>
560
 
+       <p>
561
 
+Here we not only use md0's root (/) as in step 5, but also md0's /boot (it contains an identical kernel-image to the one on hda because we copied it here from hda in step 4, but we will be overwriting everything on hda in step 6 and can't continue relying on the stuff on hda) and MBR from either hda or hdc, whichever the BIOS can find (they will be identical MBRs and the BIOS will still find hda's MBR but in case the hda disk were to fail down the road we would want the BIOS to look on hdc as a fail over so that it could still boot up the system).</p>
562
 
+
563
 
+
564
 
+       <h2>
565
 
+6.1 Change the signature on /dev/hda to software RAID</h2>
566
 
+       <p class="code">
567
 
+cfdisk /dev/hda</p>
568
 
+       <ul>
569
 
+        <li>Select "/dev/hda1" </li>
570
 
+        <li>Then select "[Type]" </li>
571
 
+        <li>Then hit "enter". </li>
572
 
+        <li>Then type "FD". </li>
573
 
+       <li>We are setting partition to "Software RAID" </li>
574
 
+        <li>Should already be set. </li>
575
 
+        <li>Then Select "Boot" if not set, so that you can boot
576
 
+off the device. </li>
577
 
+       <li>All the boot partitions that are members of your bootable RAID device (hda1 and hdc1) should have the bootable flag set. If one is not set, set it here now</li>
578
 
+       <li>Then select "Write" and enter 'yes'. </li>
579
 
+       <li>Then select "Quite". </li>
580
 
+       </ul>
581
 
+       <p>
582
 
+My two hard disks are from different manufacturers and as it happens, while both are roughly 40G, they have different architectures in terms of sectors and precise size. So cfdisk was unable to make the partitions precisely the same size and I had hda1 29,997.60MB and hdc1 30,000MB. This didn't work when I get to the 'mdadm --add /dev/md0 /dev/hda1' step. I got a, "failed: no space left on device!" error. So I ran cfdisk again and made hda1 slightly larger than hdc1, since I could not make them both exactly the same size. Now hda1 is 30,005.83MB and the 'mdadm -add /dev/md0 /dev/hda1' step works :-). (The remaining 10,000MB on each disk I am using for other purposes, including a md1 of 1,000MB composed of hda2 and hdc2.)</p>
583
 
+
584
 
+
585
 
+       <h2>
586
 
+6.2 Add the first-disk to our existing RAID device</h2>
587
 
+       <p>
588
 
+And watch the booted RAID system automatically mirror itself onto the new drive. We are currently booted from MBR and /boot device on /dev/hdc1, with /dev/md0 as root (/).</p>
589
 
+       <p class="code">
590
 
+mdadm --add /dev/md0 /dev/hda1</p>
591
 
+       <p>
592
 
+Note: We are adding /dev/hda1 into our existing RAID device. See if it is syncing.</p>
593
 
+       <p class="code">
594
 
+cat /proc/mdstat</p>
595
 
+       <p>
596
 
+should show that it is syncing.</p>
597
 
+
598
 
+
599
 
+       <h2>
600
 
+6.3 Write new /etc/lilo.conf settings</h2>
601
 
+       <p>
602
 
+these are from when we are booted onto RAID.</p>
603
 
+       <p class="code">
604
 
+boot=/dev/md0<br />
605
 
+root=/dev/md0<br />
606
 
+#this writes the boot signatures to either disk.<br />
607
 
+raid-extra-boot=/dev/hda,/dev/hdc<br />
608
 
+image=/vmlinuz<br />
609
 
+label=RAID<br />
610
 
+read-only</p>
611
 
+       <p>
612
 
+YOU NEED THE raid-extra-boot to have it write the boot loader to all the disks.</p>
613
 
+       <p>
614
 
+YOU ARE OVERWRITING THE BOOT LOADER ON BOTH /dev/hda and /dev/hdc.</p>
615
 
+       <p>
616
 
+You can keep your old boot option to boot /dev/hda so you can boot RAID and /dev/hda.</p>
617
 
+       <p>
618
 
+But remember you don't want to boot into a RAID device in non RAID as it will hurt the synchronization. If you make changes on one disk and not the other.</p>
619
 
+
620
 
+
621
 
+       <h2>
622
 
+6.4 Run Lilo with -R option and reboot</h2>
623
 
+       <p>
624
 
+(we are currently booted into RAID)</p>
625
 
+       <p class="code">
626
 
+lilo -t -v</p>
627
 
+       <p class="code">
628
 
+lilo -R RAID</p>
629
 
+       <p>
630
 
+The -R option tells Lilo it to use the new Lilo setting only for the next reboot, and then revert back to previous setting.</p>
631
 
+       <p>
632
 
+       <div class="note">
633
 
+<b>Note 1:</b> Step 6.4 returned an error, "Fatal: Trying to map files from unnamed device 0x0000 (NFS/RAID mirror down ?)."</p>
634
 
+       <p>
635
 
+So I waited for the synchronization, started in Step 6.2, to finish (checking it with 'cat /proc/mdstat'). Once it was done, did 'lilo -t -v' again. No "Fatal" error; Lilo seems happy now (no "Fatal" message).</p>
636
 
+
637
 
+<b>Note 1a:</b> The synchronization however took two hours! I checked with 'hdparm' and it seems I have <b>DMA</b> turned off. Perhaps the synchronization would go faster with DMA turned on. Some examination of my system revealed that I did not have my computer's PCI chipset support compiled into my custom kernel. I recompiled the kernel (kernel 2.6.4) and selected the correct PCI chipset support for my computer and now DMA works correctly :-) and by default. For DMA to be default is also configurable in the PCI area of 'make menuconfig' during kernel compile configuration, and I chose it.</p>
638
 
+       <p>
639
 
+So I can now do Lilo with '-R <boot-parameter-here>' switch and reboot.</p>
640
 
+       <p>
641
 
+<b>Note 2:</b> another error, "Fatal: No image "RAID" is defined."</p>
642
 
+       <p>
643
 
+As in Step 5.3 above, I need to do 'lilo' first so that Lilo reads my new /etc/lilo.conf, otherwise Lilo does not know about my stanza labeled "RAID" which is new in my lilo.conf. (Yes I told Lilo about it on hda1 in step 5.3, but that was after I had copied the hda1 root (/) system to here, md0, which branched my system into two separate system configurations. So it needs to be done here, too. Then I can do 'lilo -R RAID'.</p>
644
 
+       <p>
645
 
+<b>Note 2a:</b> However, the '-R' switch is pointless here unless the lilo.conf stanza labeled "RAID" is *not* the first kernel-image stanza in my lilo.conf. Because if it *is* the first stanza, then it is the default stanza anyway, with or without the '-R'.</p>
646
 
+       <p>
647
 
+       </div>
648
 
+Then</p>
649
 
+       <p class="code"><span class="reboot">
650
 
+reboot</span></p>
651
 
+       <p>
652
 
+and check</p>
653
 
+       <p class="code">
654
 
+cat /proc/mdstat
655
 
+       <p>
656
 
+and check</p>
657
 
+       <p class="code">
658
 
+mount</p>
659
 
+       <p>
660
 
+to be sure all is as expected.</p>
661
 
+
662
 
+
663
 
+       <h2>
664
 
+6.5 Now run Lilo normally (without -R) and reboot</h2>
665
 
+       <p>
666
 
+See what Lilo will do.</p>
667
 
+       <p class="code">
668
 
+lilo -t -v</p>
669
 
+       <p>
670
 
+If it looks okay, do it:</p>
671
 
+       <p class="code">
672
 
+lilo</p>
673
 
+       <p class="code"><span class="reboot">
674
 
+reboot</span></p>
675
 
+       <p>
676
 
+and check</p>
677
 
+       <p class="code">
678
 
+cat /proc/mdstat</p>
679
 
+       <p>
680
 
+and check</p>
681
 
+       <p class="code">
682
 
+mount</p> 
683
 
+       <p>
684
 
+as a final system check.</p>
685
 
+      
686
 
+       <h2>
687
 
+Done.</h2>
688
 
+
689
 
+
690
 
+
691
 
+       <!-- Grub+initrd -->
692
 
+
693
 
+       <div id="7" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">^</a></div>
694
 
+
695
 
+<h1>Part II. RAID using initrd and grub</h1><font size -3>- Ferdy Nagy</font>
696
 
+<p>I used the following procedure with stock Debian 2.6.5, which has an initrd with all the modules ready to boot 
697
 
+into RAID. The procedure also covers using grub as the boot loader.  I built this from a bare install of Sarge 
698
 
+using the new installer with grub as the boot loader, but most of this document is distro independent.  My file system
699
 
+throughout is ext3 and it shouldn't take too much to use reiserfs.</p>
700
 
+<p>These steps reference back to the procedure sections outlined above and indicate where things differ due to initrd or 
701
 
+grub, so you will have to read/do/be familiar with the above steps.  Also, make sure you currently use grub
702
 
+as your boot loader, if you are using LILO, install grub and make sure it works before proceeding!</p>
703
 
+
704
 
+
705
 
+<h2>Section - 2. Upgrade to a RAID savvy kernel</h2>
706
 
+
707
 
+<a href="#2">Section 2</a>
708
 
+<p>When using initrd the kernel does not need to have the RAID compiled in, they will be loaded as modules.  Make sure
709
 
+the kernel loads the RAID modules.</p>
710
 
+
711
 
+<p>Edit <span class="code">/etc/modules</span> and add</p>
712
 
+<p class="code">md<br/>
713
 
+raid1</p>
714
 
+
715
 
+
716
 
+<h2>Section - 3. Setup RAID 1</h2>
717
 
+Follow <a href="#3">section 3</a> to setup the RAID 1.
718
 
+
719
 
+
720
 
+<h2>Section - 4. Copy your Debian system</h2>
721
 
+Follow <a href="#4">section 4</a> to copy the debian system.
722
 
+
723
 
+
724
 
+<h2>Section - 5. Reboot to RAID device</h2>
725
 
+
726
 
+<p>Instead of section 5 using LILO, grub is used as the boot loader, and initrd used to load the kernel.  A new kernel 
727
 
+entry in the grub menu is created that refers to an initrd that is created which will start the md [raid] device.  
728
 
+The original kernel entry will remain and can be reverted to if something goes wrong until RAID is running. This will 
729
 
+still use grub loaded installed on the /dev/hda MBR.</p>
730
 
+
731
 
+<h3>5.1 Build a new RAID initrd</h3>
732
 
+
733
 
+<p>A) Make sure the initrd has the modules it needs, by editing <span class="code">/etc/mkinitrd/modules</span>.  Add the 
734
 
+following [you can see what modules are available by mounting the initrd and looking in the lib/modules - see section 8.]:</p>
735
 
+<p class="code">
736
 
+       md<br/>
737
 
+       raid1</p>
738
 
+
739
 
+<p>B) Update the initrd so that the root device loaded is the raid device, not probed.  Edit the <span class="code">/etc/mkinitrd/mkinitrd.conf</span>, and update the ROOT line<br/>
740
 
+<span class="code">ROOT=/dev/md0</span></p>
741
 
+
742
 
+<p>C) Create the new initrd and a link to it.</p>
743
 
+<p class="code">mkinitrd -o /boot/initrd.img-2.6.5-raid</p>
744
 
+
745
 
+
746
 
+<h3>5.2 Update the grub boot menu</h3>
747
 
+
748
 
+<p>edit <span class="code">/boot/grub/menu.lst</span> </p>
749
 
+<p>1. Add the following entry</p>
750
 
+<p class="code">
751
 
+<pre>
752
 
+title           Debian GNU/Linux, kernel 2.6.5-1-686 RAID
753
 
+root            (hd0,0)
754
 
+kernel          /boot/vmlinuz-2.6.5-1-686 root=/dev/md0 ro
755
 
+initrd          /boot/initrd.img-2.6.5-1-686-raid
756
 
+savedefault
757
 
+boot
758
 
+</pre>
759
 
+</p>
760
 
+<p>2. Update the following kernel root option in the file.  <b>Note:</b> the grub known issues, so 
761
 
+this option will not be used anyway.</p>
762
 
+<p class="code"># kopt=root=/dev/md0 ro<br/>
763
 
+
764
 
+
765
 
+<h3>5.3 Do the above 5.4 Edit /mnt/md0/etc/fstab and reboot</h3>
766
 
+
767
 
+<p>[Copied from Part I 5.4 above]</p>
768
 
+<p>to have /dev/md0 mount as root (/), when grub boots from our RAID device, /dev/md0:</p>
769
 
+<p>Previous root (/) in fstab was:</p>
770
 
+<p class="code">/dev/hda1 / ext3 defaults 0 0</p>
771
 
+<p>Edit it to:</p>
772
 
+<p class="code">/dev/md0 / ext3 defaults 0 0</p>
773
 
+<p>Note: edit /mnt/md0/etc/fstab, not /etc/fstab, because at the moment we are booted with hda1 as root (/) but we 
774
 
+want to change the /etc/fstab that we currently have mounted on /mnt/md0/etc/fstab, our RAID device.</p>
775
 
+<p>Reboot and choose the RAID kernel to check if system boots our RAID device, /dev/md0, as root (/). If it does not, just reboot again and choose the
776
 
+original pre-read kernel image</p>
777
 
+<p class="code"><span class="reboot">reboot</span></p>
778
 
+<p>Verify /dev/md0 is mounted as root (/)</p>
779
 
+<p class="code">mount</p>
780
 
+<p>should show something similar to:</p>
781
 
+               
782
 
+<p class="code">/dev/md0 on / type ext3 (rw)<br />
783
 
+proc on /proc type proc (rw)<br />
784
 
+devpts on /dev/pts type devpts (rw,gid=5,mode=620)</p>
785
 
+
786
 
+<p>Now we are booted into the new RAID device -- md0 as root (/). Our RAID device only has one disk in it at the 
787
 
+moment because we earlier declared the other disk as 'missing'. That was because we needed that other disk, hda, to 
788
 
+install Debian on or because it was our pre-existing Debian system.</p>
789
 
+
790
 
+<span class="code">cat /proc/mdstat</span> shows the [degraded] array is up and running, note the [_U] - second disk is up.</p>
791
 
+
792
 
+
793
 
+<h2>Section - 6. Reformat hda as fd and declare it as disk-one of your raid</h2>
794
 
+
795
 
+<h3>6.1/2 Setup hda and add to array</h3>
796
 
+<p>Follow <a href="#6">steps 6.1, and 6.2</a>.  <b>Wait</b> and make sure the drives are fully synced before proceeding.
797
 
+
798
 
+<h3>6.3 re-run mkinitrd again, and reboot.</h3>
799
 
+
800
 
+<p>This is needed to make sure that mkinitrd starts the newly built array with all drives.  mkinitrd uses mdadm -D to 
801
 
+discover what drives to assemble in the array during startup, this is contained in a script in the initrd image.  If this 
802
 
+step is not done the next time you reboot the array will be degraded.</p>
803
 
+
804
 
+<p> Do the following</p>
805
 
+<p class="code">mkinitrd -o /boot/initrd-2.6.5-raid.img</p>
806
 
+
807
 
+<p><span class="reboot">reboot</span></p>
808
 
+
809
 
+<p>and check the array is fully up, look for the [UU]</p>
810
 
+
811
 
+<p class="code">cat /proc/mdstat</p>
812
 
+
813
 
+<p>and check /dev/md0 is mounted</p>
814
 
+
815
 
+<p class="code">mount</p>
816
 
+
817
 
+
818
 
+<h2>7. Put grub into the MBR of the second disk</h2>
819
 
+
820
 
+<p>grub refers to the boot(ed) device as hd0, so if the primary hard drive (/dev/hda) fails the system will look for 
821
 
+the next bootable device (/dev/hdc) and loads it's MBR, which grub will still refer to as hd0.  So, the grub
822
 
+configuration can still use hd0 even when the primary device fails.</p>
823
 
+
824
 
+<h3>7.1 Put grub into the MBR</h3>
825
 
+
826
 
+<p>These steps temporarily tell grub the second device is hd0 and then loads the MBR.</p>
827
 
+
828
 
+<p>start the grub command line, then run the load commands.  <b>Note:</b> grub partition references
829
 
+are offset by 1, so in the following with a partition of /dev/hdc1, the root is (hd0,0) [previous line tells 
830
 
+grub to set hdc as hd0].  If the partition was /dev/hdc2, the root would be (hd0,1)!</p>
831
 
+<p class="code">grub<br/>
832
 
+grub> device (hd0) /dev/hdc<br/>
833
 
+grub> root (hd0,0)<br/>
834
 
+grub> setup (hd0)<br/>
835
 
+</p>
836
 
+
837
 
+<h3>7.2 Testing</h3>
838
 
+
839
 
+<p>reboot, verify the /proc/mdstat devices always start.  Follow <a href="VIII">section VIII</a> and verify the 
840
 
+system boots with one disk off line.</p>
841
 
+
842
 
+
843
 
+<h2>8. Known Issues</h2>
844
 
+
845
 
+<h3>grub</h3>
846
 
+<p>grub will already be installed on hda, and you will manually force grub to be installed on hdc so the MBRs are
847
 
+ok; however, <span class="code">install-grub</span> and <span class="code">update-grub</span> will fail because 
848
 
+grub does not understand the md0 device.  This is not a problem with install-grub as it will not be executed again 
849
 
+after it has been installed, but update-grub is executed after an updated kernel is apt'd, causing an error to be
850
 
+reported by apt.  The update-grub error is ok, the kernel gets installed and the initrd is created with all
851
 
+the md array information, provided the array was not degraded during the kernel upgrade.  <b>But</b> you will have
852
 
+to <b>manually</b> update the grub menu.lst and add the new kernel information before you reboot, or the new
853
 
+kernel will not appear in the grub menu.</p>
854
 
+
855
 
+<h3>mkinitrd</h3>
856
 
+<p>When using mdadm, mkinitrd will only detect disks in the array that are running at the time of execution. You should
857
 
+not install a new kernel while the array is degraded, otherwise, even if you do an mdadm --add, the next reboot will
858
 
+still be degraded!  The array is started at boot time by <span class="code">script</span>.  You can see what 
859
 
+is in the script of the initrd by mounting it, e.g.</p>
860
 
+<p class="code">mount /boot/initrd.img-<b>X.X.X</b> /mnt -o loop<br/> 
861
 
+cat /mnt/script</p>
862
 
+<p>And look for the array start line similar to</p>
863
 
+<p class="code">mdadm -A /devfs/md/0 -R -u 23d8dd00:bc834589:0dab55b1:7bfcc1ec /dev/hda1 /dev/hdc1</p>
864
 
+
865
 
+       <!-- Appendix -->
866
 
+
867
 
+       <div id="I" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
868
 
+^</a></div>
869
 
+       <h1>
870
 
+Appendix</h1>
871
 
+
872
 
+
873
 
+       <h2>
874
 
+I. RAID 1 Introduction</h2>
875
 
+       <p>
876
 
+Redundant Array of Inexpensive Disks (RAID) refers to putting more than one hard disk to work together in various advantageous ways. Hardware RAID relies on special hardware controllers to do this and we do not covered in this HowTo. Software RAID, this HowTo, uses software plus the ordinary controllers on your computer's motherboard and works excellently.</p>
877
 
+       <p>
878
 
+RAID 1 is where you use two hard drives as if they were one by mirroring them onto each other. Advantages of RAID 1 are (a) faster data reads because one part of the data can be read from one of the disks while simultaneously another part of the data is read from the other disk, and (b) a measure of fail over stability -- if one of the disks in the RAID 1 fails, the system will usually stay online using the remaining drive while you find time to replace the failed drive.</p>
879
 
+       <p>
880
 
+To achieve the speed gain, the two disks that comprise your RAID 1 device must be on separate controllers (in other words, on separate drive cables). The first part of the data is read from one disk while simultaneously the second part of data is read from the other disk. Writing data to a RAID 1 device takes twice as long apparently. However, under most system use data is more often read from disk than written to disk. So RAID 1 almost doubles the effective speed of your drives. Nice.</p>
881
 
+       <p>
882
 
+RAID is not a substitute for regular data back ups. Many things can happen that destroy both your drives at the same time.</p>
883
 
+
884
 
+
885
 
+       <div id="II" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
886
 
+^</a></div>
887
 
+       <h2>
888
 
+II. Drive designators (hda, hdb, hdc, hdd), jumpers and cables</h2>
889
 
+       <p>
890
 
+<b>Drive designators.</b></p>
891
 
+       <p>
892
 
+Drives on IDE 1 -- Primary Controller</p>
893
 
+       <ul>
894
 
+        <li>
895
 
+hda, Primary Master drive</li> 
896
 
+        <li>
897
 
+hdb, Primary Slave drive</li> 
898
 
+       </ul>
899
 
+       <p>
900
 
+Drives on IDE 2 -- Secondary Controller</p>
901
 
+       <ul>
902
 
+        <li>
903
 
+hdc, Secondary Master drive</li> 
904
 
+        <li>
905
 
+hdd, Secondary Slave drive</li> 
906
 
+       </ul>
907
 
+       <p><b>
908
 
+Jumpers.</b> When moving drives around in your computer, be sure to set the jumpers on your drives correctly. They are the little clips that connect two of various pins on your drive to set it to Cable Select, Master, or Slave. IDE drives usually have a diagram right on their case that shows where to set the clip for what setting. Different brands sometimes use different pin configurations.
909
 
+       <p><b>
910
 
+Cables.</b> Use 80 wire 40 pin IDE drive cables, not 40 wire 40 pin or you will slow down your hard drive access. For best results, cables should be no longer than the standard 18". If your cable has a blue end, that's the end to attach to the mother board (I don't know why). I don't think it matters which of the two drive connectors on the cable you plug your drive into, the middle or end one, unless you use Cable Select in which case I believe the sable's end plug is Master and its middle plug is Slave.</p>
911
 
+
912
 
+
913
 
+       <div id="III" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
914
 
+^</a></div>
915
 
+       <h2>
916
 
+III. Setting up software RAID for multiple partitions.</h2>
917
 
+       <p>
918
 
+You can have a multi-partition RAID system if you prefer. You just need to create multiple RAID devices.</p>
919
 
+       <p>
920
 
+I have found it useful when setting software RAID on multiple partitions to set the RAID device to the same name as the disk partition.</p>
921
 
+       <p>
922
 
+If you have 3 partitions on /dev/hda and I want to add /dev/hdc for software RAID, then boot /dev/hdc and add /dev/hda back into the device, exactly what I did earlier, but with 3 partitions which are: hda1=/boot, hda2=/, hda3=/var</p>
923
 
+       <p class="code">
924
 
+sfdisk -d /dev/hda | sfdisk /dev/hdc;<br />
925
 
+reboot<br />
926
 
+mdadm --zero-superblock /dev/hda1<br />
927
 
+mdadm --zero-superblock /dev/hda2<br />
928
 
+mdadm --zero-superblock /dev/hda3<br />
929
 
+mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/hdc1<br />
930
 
+mdadm --create /dev/md2 --level=1 --raid-disks=2 missing /dev/hdc2<br />
931
 
+mdadm --create /dev/md3 --level=1 --raid-disks=2 missing /dev/hdc3<br />
932
 
+mkfs.reiserfs /dev/md1;mkfs.reiserfs /dev/md2; mkfs /dev/md3;<br />
933
 
+mkdir /mnt/md1 /mnt/md2 /mnt/md3;<br />
934
 
+cp -ax /boot /mnt/md1;cp -ax / /mnt/md2; cp -ax /var /mnt/md3;</p>
935
 
+       <p>
936
 
+add entry in current fstab for all 3 and REBOOT.</p>
937
 
+       <p>
938
 
+Sync data again, only copying changed stuff.
939
 
+       <p class="code">
940
 
+cp -aux /boot /mnt/md1;cp -aux / /mnt/md2; cp -aux /var /mnt/md3;</p>
941
 
+       <p>
942
 
+edit lilo.conf entry in this case:
943
 
+       <p class="code">
944
 
+boot=/dev/md1<br />
945
 
+root=/dev/md2</p>
946
 
+       <p>
947
 
+Edit /mnt/md2/etc/fstab to have / set to /dev/md2.</p>
948
 
+       <p>
949
 
+REBOOT into RAID.</p>
950
 
+       <p>
951
 
+Add devices in:
952
 
+       <p class="code">
953
 
+mdadm --add /dev/md1 /dev/hda1<br />
954
 
+mdadm --add /dev/md2 /dev/hda2</p>
955
 
+       <p>
956
 
+Wait for sync, write Lilo permanently, and REBOOT into your setup.</p>
957
 
+       <p>
958
 
+It is not harder to include more devices in a software RAID device.</p>
959
 
+
960
 
961
 
+       <div id="IV" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
962
 
+^</a></div>
963
 
+       <h2>
964
 
+IV. Lilo</h2>
965
 
+       <p>
966
 
+You need special entries to use Lilo as your boot loader, I couldn't get grub to work, but nothing prevents you from using grub.  Just standard Lilo/grub entries WILL NOT WORK FOR RAID.</p>
967
 
+       <p>
968
 
+Entries in /etc/lilo.conf:
969
 
+       <p class="code">
970
 
+raid-extra-boot=&lt;option&gt;</p>
971
 
+       <p>
972
 
+That option only has meaning for RAID 1 installations. The &lt;option&gt; may be specified as none, auto, mbr-only, or a comma-separated list of devices; e.g., "/dev/hda,/dev/hdc6".</p>
973
 
+       <p><span class="code">
974
 
+panic='' </span>line in lilo.conf tells Lilo to automatically boot back to the old install if something goes wrong with the new Kernel.</p>
975
 
+      
976
 
977
 
+       <div id="V" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
978
 
+^</a></div>
979
 
+       <h2>
980
 
+V. Copying data</h2>
981
 
+       <p>
982
 
+Use "cp -aux" to just copy updated items. if you are copying a partition that is not root you need to copy the subdirectories and not the mount point, otherwise it will just copy the directory over. To copy boot which is a separately mounted partition to /mnt/md1 which is our new software RAID partition we copy as thus:  "cp -aux /boot/* /mnt/md1" NOTE THE DIFFERENCE when copying mount points and not just /.  If you just do cp -aux /boot /mnt/md1 it will just copy over boot as a subdirectory of /mnt/md1.</p>
983
 
+       <p>
984
 
+Or, alternatively, you could copy the root system with 'find' piped to 'cpio', like this:</p>
985
 
+       <p><p class="code">
986
 
+cd /<br />
987
 
+find . -xdev -print | cpio -dvpm /mnt/md0</p>
988
 
+
989
 
+
990
 
+
991
 
+       <div id="VI" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
992
 
+^</a></div>
993
 
+       <h2>
994
 
+VI. Rebooting</h2>
995
 
+       <p>
996
 
+You should always reboot if you have changed your partitions, otherwise the Kernel will not see the new partitions correctly.  I have changed partitions and not rebooted, and it caused problems.  I would rather have the simpler longer less potentially troublesome approach.  Just because it appears to work, does not mean it does work.  You really only need to reboot if you are CHANGING or rebooting a new Lilo configuration.  Don't email me if you hose yourself because you did not feel the urge to reboot. Trust me.</p>
997
 
+
998
 
999
 
+       <div id="VII" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1000
 
+^</a></div>
1001
 
+       <h2>
1002
 
+VII. initrd</h2>
1003
 
+       <p>
1004
 
+initrd: Use RAID as initrd modules. </p>       
1005
 
+       <p>
1006
 
+The Kernel that is installed when you first build a system does not use an initrd.img. 
1007
 
+However the default kernel uses initrd. So you can use a stock kernel for with 
1008
 
+software raid.</p>
1009
 
+       <p> 
1010
 
+The new Kernel by default won't contain the right modules for creating a RAID savvy initrd, but they can be added.</p>
1011
 
+       <p> 
1012
 
+&nbsp;<p> 
1013
 
+(Per James Bromberger)<p> 
1014
 
+Now we need to prepare for running a RAID setup. Our packages need an update. 
1015
 
+Use apt, because it rocks, and install the following: <br>
1016
 
+<p class="code">
1017
 
+DevFSd <br>
1018
 
+kernel-image-2.4.x (whatever suits you) <br>
1019
 
+reiserfsprogs <br>
1020
 
+less <br>
1021
 
+screen <br>
1022
 
+vim <br>
1023
 
+<p>
1024
 
+...Anything else you need and can't live without for the next 10 minutes <br>
1025
 
+<br>
1026
 
+You might already have some of these modules in the kernel, eg ext2.
1027
 
+Edit /etc/modules and add the following modules: <br>
1028
 
+<p class="code">
1029
 
+reiserfs <br>
1030
 
+md <br>
1031
 
+raid1 <br>
1032
 
+ext2 <br>
1033
 
+ide-disk (might not need this one.)<br>
1034
 
+raid5 <br>
1035
 
+ext3 <br>
1036
 
+ide-probe-mod (might not need this one.)<br>
1037
 
+ide-mod (might not need this one.) <br>
1038
 
+<p>
1039
 
+<br>
1040
 
+Edit /etc/mkinitrd/modules, and add the same modules to this list. Your initrd 
1041
 
+image needs to be able to read and write to your RAID array, before your 
1042
 
+filesystem is mounted. Initrd is the trick here. You probably also want to see 
1043
 
+if you need to edit /etc/mkinitrd/mkinitrd.cfg and set the variable ROOT=probe 
1044
 
+to be ROOT=/dev/md0, or possibly, if using DevFS, ROOT=/dev/md/0. <br>
1045
 
+<br>
1046
 
+Regenerate your initrd image for your new kernel with 
1047
 
+<p class="code">
1048
 
+
1049
 
+mkinitrd -o /tmp/initrd-new /lib/modules/2.4.x-... .
1050
 
+
1051
 
+<p> If all is good, move this to /boot/initrd-2.4.x-... and 
1052
 
+edit your /etc/lilo.conf to add initrd=/boot/initrd against the &quot;Linux&quot; kernel 
1053
 
+entry. Run lilo, and you should see an asterisk next to the boot image &quot;Linux&quot;.<p> 
1054
 
+With those modules you should be able to install the new kernel-image package. The install will add those modules to the initrd.img that. Now you can do for example (I actually only tested with kernel-image-2.4.24-1-686-smp on a machine using testing and unstable listed in the /etc/apt/source.list)
1055
 
+       <p class="code"> 
1056
 
+apt-get install kernel-image-2.4.24-1-686-smp</p>
1057
 
+       <p> 
1058
 
+You will need to modify /etc/lilo.conf to include the right stuff. Otherwise the post install scripts for the package will likely fail.
1059
 
+       <p class="code"> 
1060
 
+image=/vmlinuz<br />
1061
 
+label=Linux<br />
1062
 
+initrd=/initrd.img</p>
1063
 
+       <p>
1064
 
+(The above is all one line)</p>
1065
 
+       <p> 
1066
 
+Run Lilo and REBOOT.</p>
1067
 
+       <p> 
1068
 
+You should now have the modules loaded. Check with:<span class="code"> cat /proc/mdstat </span></p>
1069
 
+
1070
 
+
1071
 
+       <div id="VIII" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1072
 
+^</a></div>
1073
 
+       <h2>
1074
 
+VIII. Verify that system will boot even with one disk off-line</h2>
1075
 
+       <p>
1076
 
+Roger did it this way.</p>
1077
 
+     <ol>
1078
 
+       <li>Shutdown and power-off your computer.</li>
1079
 
+       <li>Open up computer and unplug the power to Primary Master disk (/dev/hda).</li>
1080
 
+       <li>Start up your computer. It should boot up from the other disk.</li>
1081
 
+       <li>Now look at<br />
1082
 
+       <span class="code">cat /proc/mdstat</span><br />
1083
 
+       you should see that one of the disks in your md0 has "failed".</li>
1084
 
+       <li>Shutdown and then unplug the power to you computer, again.</li>
1085
 
+       <li>Reconnect the power to Primary Master disk.</li>
1086
 
+       <li>Start up your computer, again. It should boot up from the other disk still. It wont try to access the disk that it now has on record as "failed" until you re-add it to your RAID. Look again at<br />
1087
 
+       <span class="code">cat /proc/mdstat</span><br />
1088
 
+       you should still see one of the disks in your md0 listed as "failed". If this were not a simulation it probably would be failed and you would want to replace it with a new one. But for the simulation we just un-plug and later re-plug the power connector to the disk.</li>
1089
 
+       <li>Now that you have re-connected the power to the disk (or replaced it with a new one were it really was a failed disk) bring it back online with mdadm,<br />
1090
 
+       <span class="code">mdadm --add /dev/md0 /dev/hda1</span><br />
1091
 
+       and check its status with,
1092
 
+       <span class="code">cat /proc/mdstat</span><br />
1093
 
+       you should see that it is being synchronized the the other disk in your RAID 1.</li>
1094
 
+       <li><b>WAIT until the synchronization has completed.</b> Then you can try the above again but unplugging the other disk in your RAID 1. <b>WARNING</b> if you do not wait for synchronization to fully complete (check with '/proc/mdstat') you will have a <b>real problem</b> because your system is only partially rebuild on the "new" disk until synchronization has finished.</li> 
1095
 
+    </ol>
1096
 
+       <p class="note">
1097
 
+NB: I (Roger) had to disconnect power to my CD-ROM drive (because my CD-ROM was on /dev/hdd -- Secondary Slave) in order to boot with my Secondary Master disconnected. Otherwise my BIOS refused to boot the machine because my CD-ROM was then a Slave on a cable without any Master. Your mileage may vary. :-) So I decided to leave my CD-ROM disconnected, as this is a server and I need it to boot even with a failed drive more than I need the convenience of keeping the CD-ROM connected. I can of course connect the CD-ROM when I need it as long as I have a working Master drive on its cable with it or set it to Master.</p>
1098
 
+
1099
 
+
1100
 
+        <div id="IX" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')?  location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1101
 
+^</a></div>
1102
 
+        <h2>
1103
 
+IX. Setting up a RAID 1 Swap device</h2>
1104
 
+       <p>
1105
 
+I created a swap RAID device as follows:</p>
1106
 
+       <p>
1107
 
+(I have a 1000MB hda2 and a 1000MB hdc2, both as type 'fd' created with 'cfdisk', that I will use as md1 for swap.)</p>
1108
 
+       <p>
1109
 
+       (Or you can just create the swap parttions on the actual disk, don't put swap on raid.
1110
 
+       Just put a swap partition on each disk in your raid set on an empty partition.)
1111
 
+
1112
 
+       <p class="code">
1113
 
+
1114
 
+       <p>
1115
 
+Add a Swap entry in /etc/fstab, just after root (/) partition line. Example line to add to /etc/fstab:
1116
 
+       <p class="code">
1117
 
+/dev/md1        none            swap    sw                      0       0</P>
1118
 
+       <p>
1119
 
+Reboot and the boot sequence should start up the Swap when it reads /etc/fstab.</p>
1120
 
+       <p class="code"><span class="reboot">
1121
 
+reboot</span></p>
1122
 
+       <p class="todo">
1123
 
+       You can argue whether swap should be on raid. A large colo admin mentions that he does not use swap on  raid. Keep it as simple as possible. You decide.</p> 
1124
 
+       
1125
 
+
1126
 
+        <div id="X" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')?  location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1127
 
+^</a></div>
1128
 
+        <h2>
1129
 
+X. Performance Optimizations </h2>
1130
 
+        For every ide drive turn on hdparm.
1131
 
+       <br>
1132
 
+       <p class="code">&nbsp;<p class="code">hdparm -d1 -c3 /dev/hda /dev/hdc<p>
1133
 
+       <br>You need to use bonnie++ to measure software raid performance 
1134
 
+    <br>You want all your devices to be as masters. As your limited to total bandwidth on that chain of
1135
 
+    <br>hard drives.
1136
 
+    <br> I just stick as many hard drives in the system as possible, 
1137
 
+    <br> I have not encountered problems where having disks on the same master
1138
 
+    <br> slave channel caused a slowdown. 
1139
 
+    
1140
 
+      <div id="XI" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')?  location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1141
 
+^</a></div>
1142
 
+    <h2>
1143
 
+XI. Disaster Recovery
1144
 
+       </h2>
1145
 
+
1146
 
+    <h2>
1147
 
+    <p class="todo">
1148
 
+(These directions are untested, I need to adopt them to mdadm instead of raid2 --luke)</p></h2>
1149
 
+
1150
 
+       <P>So what to do if you can't get your root RAID1 filesystem to boot? Here is a 
1151
 
+straightforward way to get to your md0:</P>
1152
 
+<UL>
1153
 
+<br>Find the 2.4 kernel install media from $DEBIAN/dists/unstable/main/disks-i386, 
1154
 
+<br> and download the <STRONG>bf2.4</STRONG> set of disks.
1155
 
+<br> You only need the rescue and root images. 
1156
 
+<br>Find the corresponding kernel-image-2.4.18-bf2.4_2.4.18-4_i386.deb or 
1157
 
+<br>similar; and unpack this somewhere with 
1158
 
+<p class="code"> &nbsp;</p>
1159
 
+<p class="code"> dpkg-deb -x kernel-image-2.4.yy-bf45.deb temp/ </p>
1160
 
+<br>In the temp directory, find the md.o and raid1.o modules. 
1161
 
+<br>Copy them to a new floppy in /floppy/boot. 
1162
 
+<br>Copy /sbin/raid* to the root of the floppy disk (/floppy). You'll notice 
1163
 
+<br>that all the raid programs are symlinks to the same binary; doesn't matter, 
1164
 
+<br>since you probably have a vfat disk that doesn't know about symlinks. Just make 
1165
 
+<br>multiple copies. (Or be smart here and use an ext2 disk). 
1166
 
+<br>Boot with the rescue, then with the root disk 
1167
 
+<br>After choosing a language and keyboard from the installer, choose to preload 
1168
 
+<br>some modules. Grab that third disk you just put those modules and binaries on, 
1169
 
+<br>and put it in the floppy drive. 
1170
 
+<br>Load up md.o first, and then raid1.o. 
1171
 
+<br>Press Alt-F2 to get a text console. 
1172
 
+<p class="code">
1173
 
+<br>mount /floppy 
1174
 
+<br>cp /etc/raid* /sbin  
1175
 
+<p class="code">
1176
 
+# (Ie: copy to the ramfs /sbin) 
1177
 
+<br>mkdir /etc/raid<p class="code">
1178
 
+cp /floppy/raidtab /etc/raid  
1179
 
+<p class="code">
1180
 
+ln -s /etc/raid/raidtab /etc/raidtab  
1181
 
+<p class="code">
1182
 
+raidstart /dev/md0<p class="code">
1183
 
+mount -t reiserfs /dev/md0 /target </UL>
1184
 
+</p>
1185
 
+
1186
 
+       <div id="XII" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1187
 
+^</a></div>
1188
 
+       <h2>
1189
 
+XII. Quick Reference</h2>
1190
 
+       <p><b>
1191
 
+DON'T JUST LOOK AT THIS QUICK REFERENCE. Understand the rest of the document.</b></p>
1192
 
+       <h3 style="font-style: italic; margin: 3% 1% 2% -2%;">
1193
 
+Quick Reference -- setting up bootable system on /dev/md0 using /dev/hda and /dev/hdc as RAID 1 component disks</h3>
1194
 
+       <p>
1195
 
+Verify RAID savvy Kernel. (1) You should see the RAID "personalities" your Kernel supports:</p>
1196
 
+       <p class="code">
1197
 
+cat /proc/mdstat</p>
1198
 
+       <p class="code">
1199
 
+       dmsg|grep -i RAID
1200
 
+       <p>
1201
 
+(This will show you if raid is compiled into kernel, or detected as a module from initrd.)
1202
 
+/etc/modules will not list RAID if Kernel has RAID compiled in instead of loaded as modules.
1203
 
+Use lsmod to list currently loaded modules this will show raid modules loaded. 
1204
 
+       <p>
1205
 
+(2) You should NOT see any RAID modules in /etc/modules (If you do, review step 2 of Procedure):</p>
1206
 
+       <p class="code">
1207
 
+cat /etc/modules</p>
1208
 
+       <p>
1209
 
+Copy partitions hda to hdc:
1210
 
+       <p class="code">
1211
 
+sfdisk -d /dev/hda | sfdisk /dev/hdc </p>
1212
 
+       <p>
1213
 
+Create array:
1214
 
+       <p class="code">
1215
 
+mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/hdc1 </p>
1216
 
+       <p>
1217
 
+Copy data:
1218
 
+       <p class="code">
1219
 
+cp -ax  / /mnt/md0 </p>
1220
 
+       <p>
1221
 
+Example /etc/lilo.conf entry for 1 disk RAID device:
1222
 
+       <p class="code">
1223
 
+boot=/dev/hda<br />
1224
 
+image=/vmlinuz<br />
1225
 
+label=RAID<br />
1226
 
+read-only<br />
1227
 
+#our new root partition.<br />
1228
 
+root=/dev/md0</p>
1229
 
+       <p>
1230
 
+Add second disk to array:
1231
 
+       <p class="code">
1232
 
+mdadm --add /dev/md0 /dev/hdc1 </p>
1233
 
+       <p>
1234
 
+Example final /etc/lilo.conf entry:
1235
 
+       <p class="code">
1236
 
+boot=/dev/md0<br />
1237
 
+root=/dev/md0<br />
1238
 
+#this writes the boot signatures to either disk.<br />
1239
 
+raid-extra-boot=/dev/hda,/dev/hdc<br />
1240
 
+image=/vmlinuz<br />   
1241
 
+label=RAID<br />       
1242
 
+read-only</p>
1243
 
+     
1244
 
+
1245
 
+       <h3 style="font-style: italic; margin: 3% 1% 2% -2%;">
1246
 
+Useful 'mdadm' commands</h3>
1247
 
+       <p> 
1248
 
+Always zero the superblock of a device before adding it to a RAID device. Why? Because the disks decide what array they are in based on the disk-id information written on them. Zero the superblock first in case the disk was part of a previous RAID device. Also, if a partition was part of a previous RAID device, it appears to store the size of it's previous partition in the signature. Zeroing the superblock before adding it to a new RAID device takes care of cleaning up that, too.</p>
1249
 
+       <p>
1250
 
+Erase the MD superblock from a device:
1251
 
+       <p class="code">
1252
 
+mdadm --zero-superblock /dev/hdx</p>
1253
 
+       <p>
1254
 
+Remove disk from array:</p>
1255
 
+       <p class="code">
1256
 
+mdadm --set-faulty /dev/md1 /dev/hda1 <br />
1257
 
+mdadm --remove /dev/md1 /dev/hda1</p>
1258
 
+       <p>
1259
 
+Replace failed disk or add disk to array:
1260
 
+       <p class="code">
1261
 
+mdadm --add /dev/md1 /dev/hda1</p>
1262
 
+       <p>
1263
 
+(that will format the disk and copy the data from the existing disk to the new disk.)</p>
1264
 
+       <p>
1265
 
+Create mdadm config file:
1266
 
+       <p class="code">
1267
 
+echo "DEVICE /dev/hda /dev/hdc" &gt; /etc/mdadm/mdadm.conf<br /> 
1268
 
+mdadm --brief --detail --verbose /dev/md0 &gt;&gt; /etc/mdadm/mdadm.conf<br />
1269
 
+mdadm --brief --detail --verbose /dev/md1 &gt;&gt; /etc/mdadm/mdadm.conf</p>
1270
 
+       <p>
1271
 
+To stop the array completely:
1272
 
+       <p class="code">
1273
 
+mdadm -S /dev/md0</p>
1274
 
+
1275
 
+
1276
 
+       <div id="XIII" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1277
 
+^</a></div>
1278
 
+       <h2>
1279
 
+XIII. Troubleshooting </h2>
1280
 
+       <br>The main problems people encounter is:</br>
1281
 
+       <br>Kernel must have support for raid compiled in or loaded correctly in initrd.</br>
1282
 
+       <br>You will actually have 2 configurations of raid. You boot to the failed raid volume,</br> 
1283
 
+       <br>then add in the original disk, then boot the final raid configuration.</br>
1284
 
+
1285
 
+       <br>Performance is too slow:</br>
1286
 
+       <br>See <a href="#X"> Performance Optimizations</a>
1287
 
+       
1288
 
+       <div id="XIIII" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1289
 
+^</a></div>
1290
 
+       <h2>
1291
 
+XIIII. Raid Disk Maintenance. </h2>
1292
 
+<br>You need to configure raid to monitor for errors. </br>
1293
 
+<br>It will email you when it detects and error </br>
1294
 
+<br>Once a failed disk is detected, remove it and then add it back in.</br>
1295
 
+<br>Create an mdadm.conf file <br>
1296
 
+<br>See <a href="#XII"> mdadm commands</a>
1297
 
+<br>You can also configure hot spare, that will come online if a disk fails. </br>
1298
 
+<br><configure smart monitoring of disk diagnostics to detect pre-failing disks </br>
1299
 
+<p class="todo">
1300
 
+       Finish directions on smart monitoring and mdadm configuration to monitor disks,and hot spares.
1301
 
+<p>
1302
 
+
1303
 
+       <!-- References -->
1304
 
+
1305
 
+       <div id="references" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1306
 
+^</a></div>
1307
 
+       <h1>
1308
 
+References</h1>
1309
 
+       <p>
1310
 
+RAID 1 Root HowTo PA-RISC<br /><a href="http://www.parisc-linux.org/faq/raidboot-howto.html" target="_blank">
1311
 
+http://www.pa-RISC-linux.org/faq/RAIDboot-howto.html</a></p>
1312
 
+       <p>
1313
 
+Lilo RAID Configuration:<br /><a href="http://lists.debian.org/debian-user/2003/debian-user-200309/msg04821.html" target="_blank">
1314
 
+http://lists.debian.org/debian-user/2003/debian-user-200309/msg04821.html</a></p>
1315
 
+       <p>
1316
 
+Grub RAID Howto<br /><a href="http://www.linuxsa.org.au/mailing-list/2003-07/1270.html" target="_blank">
1317
 
+http://www.linuxsa.org.au/mailing-list/2003-07/1270.html</a></p>
1318
 
+       <p>
1319
 
+Building a Software RAID System in Slackware 8.0<br /><a href="http://slacksite.com/slackware/raid.html" target="_blank">
1320
 
+http://slacksite.com/slackware/RAID.html</a></p>
1321
 
+       <p>
1322
 
+Root-on-LVM-on-RAID HowTo<br /><a href="http://www.midhgard.it/docs/lvm/html/install.disks.html" target="_blank">
1323
 
+http://www.midhgard.it/docs/lvm/html/install.disks.html</a></p>
1324
 
+       <p>
1325
 
+Software RAID HowTo<br /><a href="http://unthought.net/Software-RAID.HOWTO/Software-RAID.HOWTO.txt" target="_blank">
1326
 
+http://unthought.net/Software-RAID.HOWTO/Software-RAID.HOWTO.txt</a></p>
1327
 
+       <p>
1328
 
+HowTo - Install Debian Onto a Remote Linux System<br /><a href="http://trilldev.sourceforge.net/files/remotedeb.html" target="_blank">
1329
 
+http://trilldev.sourceforge.net/files/remotedeb.html</a></p>
1330
 
+       <p>
1331
 
+Kernel Compilation Information and good getting started info for Debian<br /><a href="http://newbiedoc.sourceforge.net/" target="_blank">
1332
 
+http://newbiedoc.sourceforge.net</a></p>
1333
 
+       <p>
1334
 
+Initrd information and Raid Disaster Recovery, </p>
1335
 
+       <p>
1336
 
+<a href="http://www.james.rcpt.to/programs/debian/raid1/">
1337
 
+http://www.james.rcpt.to/programs/debian/raid1/</a></p>
1338
 
+
1339
 
+       <div id="bottom" class="up" onMouseOver="status='^ up to Table of Contents';" onMouseOut="status=''" onClick="(location.hash == '#TOC')? location.reload(): location.hash = 'TOC'; return false;"><a class="up" href="#TOC">
1340
 
+^</a></div>
1341
 
+
1342
 
+
1343
 
+</body>
1344
 
+</html>