/[rootraiddoc]/rootraiddoc.html
ViewVC logotype

Contents of /rootraiddoc.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (show annotations) (download) (as text)
Fri Apr 2 05:04:28 2004 UTC (9 years, 1 month ago) by rogerhc-guest
Branch: MAIN
Changes since 1.19: +5 -0 lines
File MIME type: text/html
added a 'note' class to the style defenitions at top, and used a <div class="note"> tag to set appart my note in Step 6.4 so that it does not interfier with readability of the procedure.
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <title>Convert Root System to Bootable Software RAID1 (Debian)</title>
5 <style type="text/css">
6 body {
7 color: black;
8 background-color: #ffffcc;
9 margin: 0% 6% 6%;
10 }
11 h1 {
12 color: green;
13 margin: 3% 0% 2% -3%;
14 }
15 h2 {
16 margin: 4% 0% 1% -3%;
17 font-weight: normal;
18 }
19 .toc {
20 padding: 0% 6% 6%;
21 border: solid #cccccc 1px;
22 }
23 div.up {
24 cursor: pointer;
25 cursor: hand;
26 margin: 6% 0% 0% 0%;
27 padding: 4% 0% 0%;
28 border-bottom: solid #cccccc 1px;
29 }
30 a.up {
31 color: #cccccc;
32 text-decoration: none;
33 }
34 .reboot {
35 color: red;
36 background-color: white;
37 }
38 .code {
39 font-family: monospace;
40 margin: 0% 1% 2% 2%;
41 }
42 .todo {
43 color: green;
44 background-color: yellow;
45 padding: 1%;
46 }
47 .note {
48 border: dashed gray 1px;
49 }
50 p {
51 margin: 1% 0%;
52 }
53 </style>
54 </head>
55 <body>
56
57
58
59
60
61
62 <!-- Header -->
63
64 <div style="background-color: #ffffcc; color: green; padding: 1%; border: double #66cc99 4px; margin: 2% 0%;">
65 <h1 style="margin: 1% 0%;">
66 Convert Root System to Bootable Software RAID1 (Debian)</h1>
67 <p>
68 HowTo convert a Debian system to bootable Software RAID 1 with a second hard drive, 'mdadm' and a few standard UNIX tools</p>
69 </div>
70
71 <p style="font-size: 80%">
72 Version 0.91 (2004-03-27) Lucas Albers -- admin At cs DOT montana dot edu<br />
73 Home of most recent version: <a href="http://alioth.debian.org/projects/rootraiddoc" target="_blank">
74 http://alioth.debian.org/projects/rootraiddoc</a><br />
75 Thanks to: Alvin Olga, Era Eriksson, Yazz D. Atlas, especially Roger Chrisman, and alioth.debian.org<br />
76 <p><b>
77 WARNING: No warrantee 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>
78 </div>
79
80
81
82
83
84 <!-- Table of Contents -->
85 <div id="TOC" class="toc">
86
87 <h1>Table of Contents</h1>
88
89 <h3><a href="#summary">
90 Summary</a></h3>
91
92 <h3><a href="#1">
93 Procedure</a></h3>
94
95 <ol>
96 <li style="margin: 1% 0%;"><a href="#1">
97 Install Debian</a><br />
98 on your Primary Master disk -- hda. Or if you already have Debian installed, go to step 2.</li>
99 <li style="margin: 1% 0%;"><a href="#2">
100 Upgrade to RAID savvy Kernel</a><br />
101 and install 'mdadm'.</li>
102 <li style="margin: 1% 0%;"><a href="#3">
103 Setup RAID 1</a><br />
104 declaring disk-one 'missing' and disk-two hdc.</li>
105 <li style="margin: 1% 0%;"><a href="#4">
106 Copy your Debian system</a><br />
107 from hda to /dev/md0 ('missing' + 'hdc').</li>
108 <li style="margin: 1% 0%;"><a href="#5">
109 Reboot to RAID device.</a><br /></li>
110 <li style="margin: 1% 0%;"><a href="#6">
111 Reformat hda as 'fd' and declare it as disk-one of your RAID,</a><br />
112 and watch the booted RAID system automatically mirror itself onto the new drive. Done.</li>
113 </ol>
114
115 <h3><a href="#I">
116 Appendix</a></h3>
117
118 <ol style="list-style-type: upper-roman;">
119 <li><a href="#I">
120 RAID Introduction</a></li>
121 <li><a href="#II">
122 Drive designators (hda, hdb, hdc, hdd), jumpers and cables</a></li>
123 <li><a href="#III">
124 Setting up software RAID for multiple partitions</a></li>
125 <li><a href="#IV">
126 Lilo</a></li>
127 <li><a href="#V">
128 Copying Data</a></li>
129 <li><a href="#VI">
130 Rebooting</a></li>
131 <li><a href="#VII">
132 initrd</a></li>
133 <li><a href="#VIII">
134 Alternative way to copy files to RAID partition</a></li>
135 <li><a href="#IX">
136 Performance Optimizations</a></li>
137 <li><a href="#X">
138 Quick Reference</a></li>
139 </ol>
140
141
142 <h3><a href="#references">
143 References</a></h3>
144
145 </div>
146
147
148
149
150
151 <!-- Summary -->
152
153 <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">
154 ^</a></div>
155 <h1>
156 Summary</h1>
157 <p>
158 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>
159 <p>
160 If all goes well</p>
161 <ul>
162 <li>You do not need a rescue disk or to boot off anything except the hard drive.</li>
163 <li>You can do this operation completely remotely.</li>
164 <li>And you will not lose any data.</li>
165 </ul>
166 <p style:"font-weight: bold; font-style: italic;">
167 Use this HowTo at your own risk. We are not responsible for what happens!</p>
168 <p>
169 First things first</p>
170 <ul>
171 <li>Backup your data.</li>
172 <li>Create a boot floppy.</li>
173 </ul>
174 <p>
175 Whenever you change your partitions, you need to reboot.</p>
176 <p>
177 I assume you will mess up a step so wherever possible, we include verification.</p>
178 <p>
179 I us 'mdadm' because it is easier than 'raidtools' or 'raidtools2'.</p>
180 <p>
181 Directions are for Lilo, because I could not get Grub to work.</p>
182
183
184
185
186
187
188 <!-- Procedure -->
189
190
191 <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">
192 ^</a></div>
193 <h1 style="padding-bottom: 6%;">
194 Procedure</h1>
195
196
197 <h1>
198 1. Install Debian</h1>
199 <p>
200 Do a fresh install the normal way on your first drive, hda (the Primary Master drive in your computer). Or, if you already have a running Debian system that you want to use on hda, skip ahead to step 2. If you need Debian installation instructions, see:</p>
201 <p>
202 <a href="http://debian.org" target="_blank">
203 Debian Installation HowTo</a> &raquo; http://debian.org</p>
204
205
206
207 <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">
208 ^</a></div>
209 <h1>
210 2. Upgrade to a RAID savvy Kernel</h1>
211
212
213 <h2>
214 2.1 Compile and install a RAID savvy Kernel.</h2>
215 <p>
216 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 initiation ram disk or boot from a non-RAID boot drive, but I do not cover those methods here). You need RAID 1 but I usually include RAID 5, too. For step by step Kernel compile and install instructions, see:</p>
217 <p><a href="http://newbiedoc.sourceforge.net/system/kernel-pkg.html" target="_blank">
218 Creating custom Kernels with Debian's kernel-package system</a> &raquo; http://newbiedoc.sourceforge.net/system/kernel-pkg.html</p>
219
220
221 <h2>
222 2.2 Verify your RAID savvy Kernel.</h2>
223 <p class="code">
224 cat /proc/mdstat</p>
225 <p>
226 (You should see the RAID "personalities" your Kernel supports.)</p>
227 <p class="todo">
228 Roger is not sure about his assumption, below, that /etc/modules will not list RAID if Kernel has RAID compiled in instead of loaded as modules. This needs be checked out. This step is in Appendix IX: Quick Reference section, too.</p>
229 <p class="code">
230 cat /etc/modules</p>
231 <p>
232 (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>
233 <h2>
234
235
236 2.3 Install 'mdadm':</h2>
237 <p class="code">
238 apt-get install mdadm</p>
239
240
241
242 <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">
243 ^</a></div>
244 <h1>
245 3. Setup RAID 1</h1>
246 <p>
247 Setup RAID 1 and declare disk-one of your RAID to be 'missing' and disk-two of your RAID to be 'hdc'.</p>
248
249
250 <h2>
251 3.1 Create RAID (fd) partition on hdc</h2>
252 <p>
253 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>
254 <p>
255 Do A or B, either way will work:</p>
256 <p>
257 A. Create partitions on new disk.</p>
258 <p class="code">
259 cfdisk /dev/hdc</p>
260
261 <p>or</p>
262
263 <p>B. copy existing partitions to new disk with sfdisk.</p>
264 <p class="code">
265 cfdisk -d /dev/hda | sfdisk /dev/hdc</p>
266
267
268 <h2>
269 3.2 Create correct partition type signatures on new partition.</h2>
270 <p class="code">
271 cfdisk /dev/hdc</p>
272
273 <ul>
274 <li>Select Type, then hit enter, then type 'fd' (this means RAID type partition).</li>
275 <li>Select Write</li>
276 <li>Select Quit.</li>
277 </ul>
278
279 <p class="code">
280 <span class="reboot">reboot</span></p>
281 <p>
282 (to check that all is working okay.)
283
284
285 <h2>
286 3.3 Create RAID device</h2>
287 <p>
288 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>
289 <p>
290 RAID set after we boot into /dev/md0.</p>
291 <p class="code">
292 mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/hdc1</p>
293 <p>
294 If this gives errors then you need to zero the super block, see useful mdadm commands.</p>
295
296
297 <h2>
298 3.4 Format RAID device </h2>
299 <p>
300 You can use reiserfs or ext3 for this, both work, I use reiserfs for larger devices. Go with what you trust.</p>
301 <p class="code">
302 mkfs.ext3 /dev/md0</p>
303 <p>
304 or</p>
305 <p class="code">
306 mkfs -t reiserfs /dev/md0</p>
307
308
309 <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">
310 ^</a></div>
311 <h1>
312 4. Copy your Debian system</h1>
313 <p>
314 Copy your Debian system from hda to /dev/md0 ('missing' + 'hdc'). Then, check to make sure that the new RAID device is still setup right and can be mounted correctly. We do this with an entry in hda's /etc/fstab and a reboot. Note that by editing hda's /etc/fstab after the copy, instead of before, we leave the copy on md0 unaltered and only are editing hda's /etc/fstab. NB: THIS IS A BRANCH IN OUR SYSTEM CONFIGURATION, but it will overwritten later by the md0 version of /etc/fstab by the sync in step 6.</p>
315
316
317 <h2>
318 4.1 Create a mount point. </h2>
319 <p class="code">
320 mkdir /mnt/md0</p>
321
322
323 <h2>
324 4.2 Mount your RAID device. </h2>
325 <p class="code">
326 mount /dev/md0 /mnt/md0</p>
327
328
329 <h2>
330 4.3 Copy your Debian system to RAID device. </h2>
331 <p class="code">
332 cp -axu / /mnt/md0</p>
333 <p>
334 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>
335
336
337 <h2>
338 4.4 Edit /etc/fstab so that you mount your new RAID partition on boot up.</h2>
339 <p>
340 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>
341 <p class="code">
342 /dev/md0 /mnt/md0 ext3 defaults 0 0</p>
343 <p>
344 Then</p>
345 <p class="code">
346 <span class="reboot">reboot</span></p>
347 <p>
348 And see if the RAID partition comes up.</p>
349 <p class="code">
350 mount</p>
351 <p>
352 Should show /dev/md0 mounted on /mnt/md0.</p>
353
354
355 <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">
356 ^</a></div>
357 <h1>
358 5. Reboot to RAID device</h1>
359 <p>
360 For step 5 reboot, we will tell Lilo that
361 <ul>
362 <li>as before, /boot and MBR are still on hda,<br />
363 <li>and now we want root (/) to mount on md0.<br />
364 </ul></p>
365 <p>
366 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').
367
368
369 <h2>
370 5.1 Configure Lilo to boot to the RAID device </h2>
371 <p>
372 (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>
373 <p>
374 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>
375 <p class="code">
376 #the same boot drive as before.<br />
377 boot=/dev/hda<br />
378 image=/vmlinuz<br />
379 label=RAID<br />
380 read-only<br />
381 #our new root partition.<br />
382 root=/dev/md0</p>
383 <p>
384 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>
385 sample complete lilo.conf file:</p>
386 <p class="code">
387 #sample working lilo.conf for raid.<br />
388 #hda1,hdc1 are boot, hda2,hdc2 are swap<br />
389 #hda3,hdc3 are the partition used by array<br />
390 #root partition is /dev/md3 on / type reiserfs (rw)<br />
391 #I named the raid volumes the same as the partition numbers<br />
392 #this is the final lilo.conf file of a system completely finished,<br />
393 #and booted into raid.<br />
394 <br />
395 <br />
396 lba32<br />
397 boot=/dev/md1<br />
398 root=/dev/hda3<br />
399 install=/boot/boot-menu.b<br />
400 map=/boot/map<br />
401 prompt<br />
402 delay=50<br />
403 timeout=50<br />
404 vga=normal<br />
405 raid-extra-boot=/dev/hda,/dev/hdd<br />
406 default=RAID<br />
407 image=/boot/vmlinuz-RAID<br />
408 label=RAID<br />
409 read-only<br />
410 root=/dev/md3<br />
411 alias=1<br />
412
413 image=/vmlinuz<br />
414 label=Linux<br />
415 read-only<br />
416 alias=2<br />
417 <br />
418 image=/vmlinuz.old<br />
419 label=LinuxOLD<br />
420 read-only<br />
421 optional</p>
422
423
424 <h2>
425 5.2 Test our new lilo.conf </h2>
426 <p class="code">
427 lilo -t -v</p>
428 <p>
429 (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>
430
431
432 <h2>
433 5.3 Run Lilo </h2>
434 <p>
435 Configure a one time Lilo boot via the<span class="code"> -R </span>flag and with a reboot with Kernel panic</p>
436 <p>
437 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>
438 <p>
439 From 'man lilo':<br /><b>
440 -R command line</b><br />
441 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>
442 <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>
443 <p class="code">
444 lilo<br />
445 lilo -v -R RAID</p>
446
447
448 <h2>
449 5.4 Edit /mnt/md0/etc/fstab and reboot</h2>
450 <p>
451 to have /dev/md0 mount as root (/), when Lilo boots from our RAID device, /dev/md0.</p>
452 <p>
453 Previous root (/) in fstab was:</p>
454 <p class="code">
455 /dev/hda1 / reiserfs defaults 0 0</p>
456 <p>
457 Edit it to:</p>
458 <p class="code">
459 /dev/md0 / ext3 defaults 0 0</p>
460 <p>
461 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>
462 <p>
463 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>
464 <p class="code">
465 <span class="reboot">reboot</span></p>
466 <p>
467 Verify /dev/md0 is mounted as root (/)</p>
468 <p class="code">
469 mount</p>
470 <p>
471 should show:</p>
472
473 <p class="code">
474 /dev/md0 on / type reiserfs (rw)<br />
475 proc on /proc type proc (rw)<br />
476 devpts on /dev/pts type devpts (rw,gid=5,mode=620)</p>
477 <p>
478 'type reiserfs' is just my example; you will see whatever your file system type is.</p>
479 <p>
480 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>
481
482
483 <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">
484 ^</a></div>
485 <h1>
486 6. Reformat hda as 'fd' and declare it as disk-one of your RAID</h1>
487
488 <p>
489 For step 6 reboots, we tell Lilo that
490 <ul>
491 <li>as in step 5 above, our root (/) is now on md0.</li>
492 <li>and now, /boot is also on md0,</li>
493 <li>and MBR is on both hda and hdc.</li>
494 </ul></p>
495 <p>
496 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>
497
498
499 <h2>
500 6.1 Change the signature on /dev/hda to software RAID</h2>
501 <p class="code">
502 cfdisk /dev/hda</p>
503 <ul>
504 <li>Select "/dev/hda1" </li>
505 <li>Then select "[Type]" </li>
506 <li>Then hit "enter". </li>
507 <li>Then type "FD". </li>
508 <li>We are setting partition to "Software RAID" </li>
509 <li>Should already be set. </li>
510 <li>Then Select "Boot" if not set, so that you can boot
511 off the device. </li>
512 <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>
513 <li>Then select "Write" and enter 'yes'. </li>
514 <li>Then select "Quite". </li>
515 </ul>
516 <p>
517 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>
518
519
520 <h2>
521 6.2 Add the first-disk to our existing RAID device</h2>
522 <p>
523 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>
524 <p class="code">
525 mdadm --add /dev/md0 /dev/hda1</p>
526 <p>
527 Note: We are adding /dev/hda1 into our existing RAID device. See if it is syncing.</p>
528 <p class="code">
529 cat /proc/mdstat</p>
530 <p>
531 should show that it is syncing.</p>
532
533
534 <h2>
535 6.3 Write new /etc/lilo.conf settings</h2>
536 <p>
537 these are from when we are booted onto RAID.</p>
538 <p class="code">
539 boot=/dev/md0<br />
540 root=/dev/md0<br />
541 #this writes the boot signatures to either disk.<br />
542 raid-extra-boot=/dev/hda,/dev/hdc<br />
543 image=/vmlinuz<br />
544 label=RAID<br />
545 read-only</p>
546 <p>
547 YOU NEED THE raid-extra-boot to have it write the boot loader to all the disks.</p>
548 <p>
549 YOU ARE OVERWRITING THE BOOT LOADER ON BOTH /dev/hda and /dev/hdc.</p>
550 <p>
551 You can keep your old boot option to boot /dev/hda so you can boot RAID and /dev/hda.</p>
552 <p>
553 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>
554
555
556 <h2>
557 6.4 Run Lilo with -R option and reboot</h2>
558 <p>
559 (we are currently booted into RAID)</p>
560 <p class="code">
561 lilo -t -v</p>
562 <p class="code">
563 lilo -R RAID</p>
564 <p>
565 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>
566 <p>
567 <div class="note">
568 <b>Note 1:</b> Step 6.4 returned an error, "Fatal: Trying to map files from unnamed device 0x0000 (NFS/RAID mirror down ?)."</p>
569 <p>
570 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>
571
572 <b>Note 1a:</b> The synchronization however took two hours! I checked with 'hdparm' and it seems I do have <b>DMA</b> turned off. Perhaps the synchronization would go faster with DMA turned on.</p>
573 <p>
574 So I can now do Lilo with '-R <boot-parameter-here>' switch and reboot.</p>
575 <p>
576 <b>Note 2:</b> another error, "Fatal: No image "RAID" is defined."</p>
577 <p>
578 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>
579 <p>
580 <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>
581 <p>
582 </div>
583 Then</p>
584 <p class="code"><span class="reboot">
585 reboot</span></p>
586 <p>
587 and check</p>
588 <p class="code">
589 cat /proc/mdstat
590 <p>
591 and check</p>
592 <p class="code">
593 mount</p>
594 <p>
595 to be sure all is as expected.</p>
596
597
598 <h2>
599 6.5 Now run Lilo normally (without -R) and reboot</h2>
600 <p>
601 See what Lilo will do.</p>
602 <p class="code">
603 lilo -t -v</p>
604 <p>
605 If it looks okay, do it:</p>
606 <p class="code">
607 lilo</p>
608 <p class="code"><span class="reboot">
609 reboot</span></p>
610 <p>
611 and check</p>
612 <p class="code">
613 cat /proc/mdstat</p>
614 <p>
615 and check</p>
616 <p class="code">
617 mount</p>
618 <p>
619 as a final system check.</p>
620
621 <h2>
622 Done.</h2>
623
624
625
626
627
628
629 <!-- Appendix -->
630
631 <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">
632 ^</a></div>
633 <h1>
634 Appendix</h1>
635
636
637 <h2>
638 I. RAID 1 Introduction</h2>
639 <p>
640 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>
641 <p>
642 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>
643 <p>
644 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, unter 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>
645 <p>
646 RAID is not a substitute for regular data back ups. Many things can happen that destroy both your drives at the same time.</p>
647
648
649 <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">
650 ^</a></div>
651 <h2>
652 II. Drive designators (hda, hdb, hdc, hdd), jumpers and cables</h2>
653 <p>
654 <b>Drive designators.</b></p>
655 <p>
656 Drives on IDE 1 -- Primary Controller</p>
657 <ul>
658 <li>
659 hda, Primary Master drive</li>
660 <li>
661 hdb, Primary Slave drive</li>
662 </ul>
663 <p>
664 Drives on IDE 2 -- Secondary Controller</p>
665 <ul>
666 <li>
667 hdc, Secondary Master drive</li>
668 <li>
669 hdd, Secondary Slave drive</li>
670 </ul>
671 <p><b>
672 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.
673 <p><b>
674 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>
675
676
677 <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">
678 ^</a></div>
679 <h2>
680 III. Setting up software RAID for multiple partitions.</h2>
681 <p>
682 You can have a multi-partition RAID system if you prefer. You just need to create multiple RAID devices.</p>
683 <p>
684 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>
685 <p>
686 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>
687 <p class="code">
688 fdisk -d /dev/hda | sfdisk /dev/hdc;<br />
689 reboot<br />
690 mdadm --zero-superblock /dev/hda1<br />
691 mdadm --zero-superblock /dev/hda2<br />
692 mdadm --zero-superblock /dev/hda3<br />
693 mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/hdc1<br />
694 mdadm --create /dev/md2 --level=1 --raid-disks=2 missing /dev/hdc2<br />
695 mdadm --create /dev/md3 --level=1 --raid-disks=2 missing /dev/hdc3<br />
696 mkfs.reiserfs /dev/md1;mkfs.reiserfs /dev/md2; mkfs /dev/md3;<br />
697 mkdir /mnt/md1 /mnt/md2 /mnt/md3;<br />
698 cp -ax /boot /mnt/md1;cp -ax / /mnt/md2; cp -ax /var /mnt/md3;</p>
699 <p>
700 add entry in current fstab for all 3 and REBOOT.</p>
701 <p>
702 Sync data again, only copying changed stuff.
703 <p class="code">
704 cp -aux /boot /mnt/md1;cp -aux / /mnt/md2; cp -aux /var /mnt/md3;</p>
705 <p>
706 edit lilo.conf entry in this case:
707 <p class="code">
708 boot=/dev/md1<br />
709 root=/dev/md2</p>
710 <p>
711 Edit /mnt/md2/etc/fstab to have / set to /dev/md2.</p>
712 <p>
713 REBOOT into RAID.</p>
714 <p>
715 Add devices in:
716 <p class="code">
717 mdadm --add /dev/md1 /dev/hda1<br />
718 mdadm --add /dev/md2 /dev/hda2</p>
719 <p>
720 Wait for sync, write Lilo permanently, and REBOOT into your setup.</p>
721 <p>
722 It is not harder to include more devices in a software RAID device.</p>
723
724
725 <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">
726 ^</a></div>
727 <h2>
728 IV. Lilo</h2>
729 <p>
730 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 if I had the directions on how to do so. Just standard Lilo entries WILL NOT WORK FOR RAID.</p>
731 <p>
732 Entries in /etc/lilo.conf:
733 <p class="code">
734 raid-extra-boot=&lt;option&gt;</p>
735 <p>
736 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>
737 <p><span class="code">
738 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>
739
740
741 <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">
742 ^</a></div>
743 <h2>
744 V. Copying data</h2>
745 <p>
746 Use "cp -anu" 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 -anu /boot/* /mnt/md1" NOTE THE DIFFERENCE when copying mount points and not just /. If you just do cp -anu /boot /mnt/md1 it will just copy over boot as a subdirectory of /mnt/md1.</p>
747
748
749 <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">
750 ^</a></div>
751 <h2>
752 VI. Rebooting</h2>
753 <p>
754 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 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>
755
756
757 <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">
758 ^</a></div>
759 <h2>
760 VII. initrd</h2>
761 <p>
762 (Yazz D. Atlas)</p>
763 <p>
764 initrd: Use RAID as initrd modules. </p>
765 <p>
766 The Kernel that is installed when you first build a system does not use an initrd.img. However if you just uses apt-get to install a new Kernel from the Internet those Kernel packages from Debian do us an initrd.img.</p>
767 <p>
768 The new Kernel by default won't contain the right modules for creating a RAID savvy initrd, but they can be added.</p>
769 <p>
770 Before upgrading to a new Kernel you should modify the systems /etc/mkinitrd/modules to include the following:
771 <p class="code">
772 ~ RAID0<br />
773 ~ RAID1<br />
774 ~ RAID5<br />
775 ~ reiserfs<br />
776 ~ ext3<br />
777 ~ ext2</p>
778 <p>
779 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)
780 <p class="code">
781 apt-get install kernel-image-2.4.24-1-686-smp</p>
782 <p>
783 You will need to modify /etc/lilo.conf to include the right stuff. Otherwise the post install scripts for the package will likely fail.
784 <p class="code">
785 image=/vmlinuz<br />
786 label=Linux<br />
787 initrd=/initrd.img</p>
788 <p>
789 If you already have a new Debian Kernel installed that has an initrd.img already you can rebuild the initrd.img.
790 <p class="code">
791 mkinitrd -o /boot/initrd.img-2.4.24-1-686-smp /lib/modules/2.4.24-686-smp</p>
792 <p>
793 (The above is all one line)</p>
794 <p>
795 Run Lilo and REBOOT.</p>
796 <p>
797 You should now have the modules loaded. Check with:<span class="code"> cat /proc/mdstat </span></p>
798
799
800 <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">
801 ^</a></div>
802 <h2>
803 VIII. Alternative way to copy files to RAID partition</h2>
804 <p><p class="code">
805 cd /<br />
806 find . -xdev -print | cpio -dvpm /mnt/md0</p>
807
808 <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">
809 ^</a></div>
810 <h2>
811 IX. Performance Optimizations </h2>
812 <p><p class="code">
813 hdparm -d1 -c3 /dev/hda /dev/hdc <br />
814 (go read about hdparm,iozone and bonnie++) <br />
815 </p>
816
817 <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">
818 ^</a></div>
819 <h2>
820 X. Quick Reference</h2>
821 <p><b>
822 DON'T JUST LOOK AT THIS QUICK REFERENCE. Understand the rest of the document.</b></p>
823 <h3 style="font-style: italic; margin: 3% 1% 2% -2%;">
824 Quick Reference -- setting up bootable system on /dev/md0 using /dev/hda and /dev/hdc as RAID 1 component disks</h3>
825 <p>
826 Verify RAID savvy Kernel. (1) You should see the RAID "personalities" your Kernel supports:</p>
827 <p class="code">
828 cat /proc/mdstat</p>
829 <p class="todo">
830 Roger is not sure about his assumption, below, that /etc/modules will not list RAID if Kernel has RAID compiled in instead of loaded as modules. This needs be checked out. This step is in Procedure step 2, too.</p>
831 <p>
832 (2) You should NOT see any RAID modules in /etc/modules (If you do, review step 2 of Procedure):</p>
833 <p class="code">
834 cat /etc/modules</p>
835 <p>
836 Copy partitions hda to hdc:
837 <p class="code">
838 cfdisk -d /dev/hda | sfdisk /dev/hdc </p>
839 <p>
840 Create array:
841 <p class="code">
842 mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/hdc1 </p>
843 <p>
844 Copy data:
845 <p class="code">
846 cp -ax / /mnt/md0 </p>
847 <p>
848 Example /etc/lilo.conf entry for 1 disk RAID device:
849 <p class="code">
850 boot=/dev/hda<br />
851 image=/vmlinuz<br />
852 label=RAID<br />
853 read-only<br />
854 #our new root partition.<br />
855 root=/dev/md0</p>
856 <p>
857 Add second disk to array:
858 <p class="code">
859 mdadm --add /dev/md0 /dev/hdc1 </p>
860 <p>
861 Example final /etc/lilo.conf entry:
862 <p class="code">
863 boot=/dev/md0<br />
864 root=/dev/md0<br />
865 #this writes the boot signatures to either disk.<br />
866 raid-extra-boot=/dev/hda,/dev/hdc<br />
867 image=/vmlinuz<br />
868 label=RAID<br />
869 read-only</p>
870
871
872 <h3 style="font-style: italic; margin: 3% 1% 2% -2%;">
873 Useful 'mdadm' commands</h3>
874 <p>
875 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>
876 <p>
877 Erase the MD superblock from a device:
878 <p class="code">
879 mdadm --zero-superblock /dev/hdx</p>
880 <p>
881 Remove disk from array:</p>
882 <p class="code">
883 mdadm --set-faulty /dev/md1 /dev/hda1 <br />
884 mdadm --remove /dev/md1 /dev/hda1</p>
885 <p>
886 Replace failed disk or add disk to array:
887 <p class="code">
888 mdadm --add /dev/md1 /dev/hda1</p>
889 <p>
890 (that will format the disk and copy the data from the existing disk to the new disk.)</p>
891 <p>
892 Create mdadm config file:
893 <p class="code">
894 echo "DEVICES /dev/hda /dev/hdc" &gt; /etc/mdadm/mdadm.conf<br />
895 mdadm --brief --detail --verbose /dev/md0 &gt;&gt; /etc/mdadm/mdadm.conf<br />
896 mdadm --brief --detail --verbose /dev/md1 &gt;&gt; /etc/mdadm/mdadm.conf</p>
897 <p>
898 To stop the array completely:
899 <p class="code">
900 mdadm -S /dev/md0</p>
901
902
903
904
905
906
907 <!-- References -->
908
909 <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">
910 ^</a></div>
911 <h1>
912 References</h1>
913 <p>
914 RAID 1 Root HowTo PA-RISC<br /><a href="http://www.parisc-linux.org/faq/raidboot-howto.html" target="_blank">
915 http://www.pa-RISC-linux.org/faq/RAIDboot-howto.html</a></p>
916 <p>
917 Lilo RAID Configuration:<br /><a href="http://lists.debian.org/debian-user/2003/debian-user-200309/msg04821.html" target="_blank">
918 http://lists.debian.org/debian-user/2003/debian-user-200309/msg04821.html</a></p>
919 <p>
920 Grub RAID Howto<br /><a href="http://www.linuxsa.org.au/mailing-list/2003-07/1270.html" target="_blank">
921 http://www.linuxsa.org.au/mailing-list/2003-07/1270.html</a></p>
922 <p>
923 Building a Software RAID System in Slackware 8.0<br /><a href="http://slacksite.com/slackware/raid.html" target="_blank">
924 http://slacksite.com/slackware/RAID.html</a></p>
925 <p>
926 Root-on-LVM-on-RAID HowTo<br /><a href="http://www.midhgard.it/docs/lvm/html/install.disks.html" target="_blank">
927 http://www.midhgard.it/docs/lvm/html/install.disks.html</a></p>
928 <p>
929 Software RAID HowTo<br /><a href="http://unthought.net/Software-RAID.HOWTO/Software-RAID.HOWTO.txt" target="_blank">
930 http://unthought.net/Software-RAID.HOWTO/Software-RAID.HOWTO.txt</a></p>
931 <p>
932 HowTo - Install Debian Onto a Remote Linux System<br /><a href="http://trilldev.sourceforge.net/files/remotedeb.html" target="_blank">
933 http://trilldev.sourceforge.net/files/remotedeb.html</a></p>
934 <p>
935 Kernel Compilation Information and good getting started info for Debian<br /><a href="http://newbiedoc.sourceforge.net/" target="_blank">
936 http://newbiedoc.sourceforge.net</a></p>
937
938
939 <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">
940 ^</a></div>
941
942
943 </body>
944 </html>

  ViewVC Help
Powered by ViewVC 1.1.5