/[rootraiddoc]/rootraiddoc.html
ViewVC logotype

Contents of /rootraiddoc.html

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.5