62c57e769f024b77669b6313c58b95de6a8ab412
[rrq/maintain_lilo.git] / readme / README.raid1
1         Notes for use of LILO on RAID installations.
2
3 (LILO version 22.0 through 22.4.1 -- 17-Apr-2001)
4 (LILO version 22.5 and later -- 14-Mar-2003) see NEW CONSIDERATIONS
5
6
7 RESTRICTIONS
8 ============
9
10 Only RAID1 is supported.  LILO may be used to boot a system
11 containing other RAID level partitions, but it may not be installed
12 on any RAID partition other than RAID level 1.
13
14
15 GOAL
16 ====
17
18 The goal of a RAID1 installation of LILO is redundancy.  Redundancy to
19 the point that a failure of one disk in an array will not render the
20 system difficult to boot.
21
22 A secondary goal of LILO on a RAID installation is to maintain array
23 coherency when the LILO command line is written back to the map file. 
24 This writeback occurs when the '-R' switch command line is cleared,
25 when the user has specified the 'lock' option, or if a 'fallback'
26 command line is in use.
27
28
29 INSTALLATION ON A RAID SET
30 ==========================
31
32 A RAID installation of the LILO boot loader is initiated by
33 specifying that the boot record is to be placed in the boot area of
34 a RAID partition.  This is accomplished by the 'boot=' line in the
35 LILO configuration file, '/etc/lilo.conf'.  For instance, a system
36 running with '/dev/md1' mounted as root ('/'), would use the line:
37
38    boot = /dev/md1
39
40 to initiate a RAID installation.  As directed, the boot record is
41 written to the RAID partition.  Unfortunately, in the event of
42 failure of the RAID set disk from which booting occurs, the boot record
43 on the surviving disk(s) will only be usable if the disks are entirely
44 "parallel" to the disk that originally booted the system.
45
46 To continue, we first need some terminology for talking about RAID 1
47 partitions.
48
49
50 TERMINOLOGY
51 ===========
52
53 RAID 1 writes the same data to the corresponding disk blocks of the
54 partitions which make up the RAID set.  Two partitions are said to be
55 "parallel" if they start at exactly the same sector address on their
56 respective drives.  This means that files on the two disks have their
57 data written at exactly the same absolute sector addresses on both
58 drives.  
59
60 Two partitions are said to be "skewed" if they do not start at the
61 same sector address on their respective drives.  Data within each
62 partition will be at the same offset from the beginning of each
63 partition, but not at the same absolute sector address.
64
65
66 PARALLEL CASE
67 =============
68
69 "Parallel" RAID sets are the easiest for LILO to handle.  One boot
70 record, written to the boot area of the RAID partition, references the
71 same sectors, no matter which disk is operational at boot time.  For
72 "parallel" RAID installations, LILO has no need to write boot records
73 outside of the RAID partition, if primary.  This is in contrast to
74 previous versions of LILO based upon the "lilo.raid1" patch file to
75 vanilla version 21, which wrote the LILO boot record to the Master Boot
76 Records of all of the drives in the array, and not to the RAID
77 partition.
78
79 With the boot record written to the RAID partition on "parallel" RAID
80 sets, every drive has a boot record which will boot the system. 
81 There is now only one map file, and this file may be referenced by
82 any of the boot records, since it is at exactly the same sector
83 address on every drive.  To insure that it is possible to boot from
84 this simplest LILO installation to "parallel" RAID set partitions,
85 one must insure that they are primary partitions; i.e., partition
86 numbers 1-4 on their respective disks, and that each disk has written
87 to it a "master" boot loader which boots the partition marked "active".
88 And on each disk, mark the RAID set partition active.  Booting normally
89 occurs from the drive with the lowest BIOS device code (0x80).  In
90 the event this drive fails, another drive assumes the role of BIOS
91 device code 0x80, and in the case of a "parallel" RAID installation,
92 will be perfectly bootable.
93
94 The unusual event of RAID set partitions which are parallel, but not
95 primary partitions will be described later.
96
97
98 MORE TERMINOLOGY
99 ================
100
101 A boot record is "accessible", if it exists on a primary parition,
102 which may be marked "active"; or it is a Master Boot Record (MBR),
103 written to sector 0 of a drive.
104
105 Non-RAID LILO installations write accessible boot records when they
106 write to primary partitions, such as:
107
108    boot = /dev/hda1
109
110 or,
111
112    boot = /dev/sdb3
113
114 Boot records are written to the MBR by specifying the drive; viz.,
115
116    boot = /dev/hdb
117
118 writes to the MBR of the slave drive on the primary IDE controller.
119
120 Similarly, a boot record is "inaccessible" if it is written to a
121 logical (or secondary) partition; i.e., partition numbers 5 and
122 above.  These partitions are not booted by any of the usual MBR boot
123 loaders which search the partition table for a partition marked
124 "active".  They may be booted from a boot manager, such as the LILO
125 boot menu, and are booted as 'other=' entries in the configuration
126 file, '/etc/lilo.conf'.
127
128
129 SKEWED CASE
130 ===========
131
132 "Skewed" installations are not quite as simple.  Here the partitions
133 are not likely to be primary, and their distinguishing characteristic
134 is that files on the filesystem within the partition lie at different
135 absolute sector addresses:  kernel files, initrd files, and the LILO
136 map file, in particular.  Thus any boot record written to '/dev/mdX',
137 the RAID partition, will have sector addresses which cannot be
138 guaranteed accurate for all drives.  Worst case is that they are
139 accurate for only one drive.  Hence, this boot will work for one
140 drive, but it is not universal.  It will fail for some drive or
141 drives in the array.
142
143 In this case, LILO needs to place boot records in "accessible" places
144 so that all drives will be bootable in a recovery situation.
145
146 Here the need for the user to specify alternative actions becomes
147 necessary.  There is a new keyword now recoginzed in the
148 configuration file, and a new command line switch corresponding to
149 the keyword:  'raid-extra-boot=' and the '-x' switch.  The following
150 description will be for the configuration file option, but is equally
151 applicable to the command line switch.
152
153 For the simplest of "skewed" installations, it may be undesirable to
154 have LILO automatically write boot records outside of the RAID
155 partition.  In this case, 'raid-extra-boot=' should be specified,
156 literally, as "none"; viz.,
157
158    boot = /dev/md1
159    raid-extra-boot = none
160
161 With this specification, LILO will write the boot record to
162 '/dev/md1' only.  If the RAID disk on the lowest BIOS device code
163 fails, the array may not be bootable, except from a floppy disk.
164
165 Without the specification "none", the default LILO action in the case
166 of a skewed installation is:
167
168    boot = /dev/md1
169    raid-extra-boot = auto
170
171 This requests LILO to place recovery boot records on the MBRs of any
172 drives for which the the '/dev/md1' boot record is not valid, because
173 of partition skew.  Even with "auto" specified, or implied by having
174 no 'raid-extra-boot=' line, LILO will never write a boot record to
175 the MBR of BIOS device 0x80.  This MBR is considered so critical,
176 that it will never be written, unless you specifically request it.
177
178 It is strongly suggested that before any LILO installation on a RAID
179 set, that LILO be run with the 'test' flag:  '-t'.  LILO will go
180 through all the motions of mapping the kernel(s) to be booted, but it
181 will tell you where it wants to write any additional boot records.
182
183   lilo -t
184
185 Is strongly recommended, especially if you are not sure whether you
186 have a "skewed" (extra boot records needed) or "parallel" RAID
187 installation.
188
189 If boot records are desired on all MBRs of all disks with partitions
190 in the raid set, then the following specification is used:
191
192    boot = /dev/md1              # OR,   -b /dev/md1
193    raid-extra-boot = mbr        # OR,   -x mbr
194
195 If there are three disks with partitions that are part of the /dev/md1
196 raid set, then the Master Boot Records of all three will receive
197 additional boot records. With this specification, the MBR of BIOS
198 device 0x80 will be overwritten. 
199
200 The caution to run 'lilo -t' first, just to see where LILO will write
201 boot records, is reemphasized.
202
203 The keyword 'raid-extra-boot=' may also be used to specify exactly
204 where you want LILO to write the auxiliary boot records.  Consider
205 the following RAID installation:  disk 0:  /dev/hdc6; disk 1: 
206 /dev/sda1.  The installation is "skewed".  Disks /dev/hda and
207 /dev/hdb exist, and occupy BIOS device codes 0x80 and 0x81,
208 respectively.  /dev/hdc is BIOS device code 0x82, and /dev/sda is
209 BIOS device code 0x83.  If the configuration file looks something
210 like:
211
212    boot = /dev/md1
213    #  the following line is not needed, but may be used to
214    #  force the device code which the RAID set will boot as
215    #disk=/dev/md1 bios=0x82
216    #  disks hda and hdb are on the expected bios codes 80 & 81
217    #
218    disk=/dev/hdc bios=0x82
219    disk=/dev/sda bios=0x83
220    #
221    image = /boot/vmlinuz
222       label = linux
223       root = /dev/md1
224       read-only
225    other = /dev/hda
226       label = MBR
227
228 then LILO will write the boot record to boot from 0x82, the lowest
229 device code of any disk in the RAID set.  An additional boot record
230 will be written to the MBR of '/dev/hdc'.  Disk '/dev/sda' is
231 bootable should '/dev/hdc' fail under the following circumstance: 
232 '/dev/hdc' is removed, freeing BIOS device code 0x82.  '/dev/sda' now
233 installs on the lowest code, 0x82, and will boot as long as partition
234 1 is marked active.
235
236 The same effect could be achieved with the configuration file having
237 the extra line:
238
239   raid-extra-boot = /dev/hdc
240
241 Further, the use of extra boot records could be extended as follows:
242
243   raid-extra-boot = "/dev/hdc,/dev/sda"
244
245 Now both disks in the RAID set have usable boot records on the MBRs. 
246 There is no need to worry about "active" partitions in a recovery
247 situation.
248
249
250 BACKWARD COMPATIBLITY
251 =====================
252
253 Backward compatibility with earlier versions of LILO raid is provided
254 by (versions 21 through 21.7.5)
255
256    raid-extra-boot = mbr-only
257
258 Use of "mbr-only" defeats writing the boot record to the RAID
259 partition, '/dev/md1' in the examples above, defeats the protection
260 against writing to the MBR of BIOS device 0x80 (which is usually
261 '/dev/hda' or '/dev/sda'), and writes to all MBRs of the drives in
262 the RAID set.  Except for not writing to the boot record of the 
263 raid partition, this option is otherwise the same as the "raid-
264 extra-boot=mbr" specification discussed above.
265
266 On XFS filesystems, writing a boot record to the RAID partition itself
267 would be catastrophic.  Hence, on XFS filesystems, use of this option
268 is MANDATORY.
269
270
271 MASTER BOOT RECORDS and ACTIVE PRIMARY PARTITIONS
272 =================================================
273
274 The active partition, /dev/sda1 in the case above is booted by a
275 "Master Boot Record" written to /dev/sda.   LILO may be requested
276 to write such a Master record with the command:
277
278    lilo -M /dev/sda     # write master boot record
279
280 The Master Boot Record performs the same function as the DOS utility
281 'fdisk /mbr', except that the DOS code is only used for the C: drive. 
282 The LILO master boot record facility may be placed on sector 0 of
283 any drive.  It serves an additional function in RAID1 installations,
284 in that it will determine, and pass to the boot sector of the active
285 partition the correct BIOS device code of the drive, whether it is
286 0x80, 0x81, or higher.
287
288 The active partition may be set with the -A flag; viz.,
289
290    lilo -A /dev/sda 1   # note the space!!!
291
292 or checked; viz.,
293
294    lilo -A /dev/sda     # check active partition
295
296 (response:  /dev/sda1)
297
298
299 REMINDERS
300 =========
301
302 Unstated, but required by an installation of LILO to a RAID
303 partition, all of the files used in booting must reside on the RAID
304 set.  This means:  initrd, kernel, and message files; plus the LILO
305 internal files:  map, boot.b, and chain.b, if used.  Normally, the
306 internal files are kept in the '/boot' directory.  Many distributions
307 of Linux also place the kernel and initrd files in this same
308 directory.  Others place them in the root, '/', directory.  Either
309 location is acceptable, as long as they are within the same RAID
310 partition which you are making bootable.
311
312 LILO variations:  version 22.2 enforces the placement of the map file
313 on the RAID parition.  Version 22.3 eliminates the need for the
314 boot.b and chain.b files, and relaxes the restriction that the
315 message file be on the RAID partition by copying it into the map
316 file.  Likewise, any bitmap= file is copied into the map file, so it
317 too may reside anywhere.  It remains the user's responsibility to see
318 that the Kernel and Initrd files are on the bootable raid partition. 
319 The /boot directory, with the map file, is the recommended location for
320 these files.
321
322 If for some reason you want to write the MBR of BIOS device 0x80, you
323 will have to specify it explicitly.  Since LILO tells you where all
324 other auxiliary boot records have been written, if any, you will have
325 to mention these in addition to the MBR on drive 0x80.
326
327 (versions 22.0 through 22.4.1):
328 When making an installation of LILO to a RAID set, remember that LILO
329 will only make the disk with the lowest device code bootable.  For
330 very many RAID installations, this will be BIOS device code 0x80. 
331 The second and succeeding disks in the RAID set are not bootable in
332 the running RAID configuration; they only become bootable if the disk
333 on device code 0x80 is removed, so that one of them becomes BIOS
334 drive 0x80.
335
336
337 ERROR MESSAGES (versions 22.0 through 22.4.1):
338 ==============
339
340 If LILO is unable to write all of the auxiliary boot records it would
341 like, or your map file is not on the RAID partition, you will get the 
342 error message:
343
344   "Warning: FLAG_RAID_NOWRITE has been set"
345
346 This warning has two consequences.  First, the clearing the '-R'
347 stored command line will not take place; 'lock' will not work
348 properly; and 'fallback' will not work properly.  All of these LILO
349 options require LILO to re-write the stored boot command line before
350 the kernel is booted.  Because RAID set consistency cannot be
351 maintained, the boot loader will fall back to a read-only mode of
352 operation.  For many installations this is acceptable.  The command
353 line switch, '-R' will still work from a running system, since the
354 kernel RAID codes will maintain set coherency.
355
356 The second consequence of this message, is a warning that not all
357 boot records needed for booting in a disk failure scenario were
358 written.  The system may boot fine with the lowest BIOS code disk
359 running, but be prepared to use a boot floppy in the event this disk
360 fails.  This may or may not be acceptable.
361
362 This message will most often appear when 'raid-extra-boot=' was
363 specified as "none"; or, if specified as (or defaulted to), "auto",
364 the extra boot record it could not write was to the MBR of BIOS
365 device 0x80, usually '/dev/hda' or '/dev/sda'.  This could happen
366 with a skewed installation, where the RAID set partition on BIOS
367 device code 0x80 is not a primary partition.  If it were a primary
368 partition, then the RAID partition boot record written to '/dev/md?'
369 would be used, and there would be no necessity to write to the MBR of
370 BIOS disk 0x80.
371
372
373 NEW CONSIDERATIONS        (version 22.5 and later)
374 ==================
375
376 Booting is now based upon a 32-bit industry standard Volume ID,
377 rather than the 8-bit BIOS device code.  Device codes are still
378 generated, but are used primarily as an index into a volume id table. 
379 This means that the LILO-installed boot sector must contain the
380 volume id of the drive containing the map file, since this is where
381 the second stage loader is guaranteed to be located.  The record on
382 the first sector of a RAID1 partition is not unique, but is shared
383 among all the partitions in the raid set.  These partitions span two
384 or more drives.  
385
386 The worst case scenario is that the boot scheme falls back to actual
387 device codes, and is as reliable as the version 22.4.1 and earlier
388 codes.  A failed installation will still boot, as long a the failed
389 (first) drive is removed, and the backup (second) drive fills the
390 emptied BIOS device code slot formerly occupied by the failed drive.
391
392 Version 22.5 (and later) installations are more robust, as long as
393 the boot record on the RAID1 partition has access to the BIOS device
394 code under which it is booting; or, booting takes place from an
395 auxiliary boot record installed using the option "mbr"; or by
396 explicit declaration.  Auxiliary boot records are not shared across
397 drives, so they may have variations within them, such as their own
398 unique volume id's, for use in accessing the correct map file.  (They
399 also contain unique offset information, in the case of skewed
400 partitions.)
401
402 The most fault tolerant systems will be those installed using the
403 "mbr" (or "mbr-only") specification.
404
405
406 CONSERVATIVE INSTALLATION    (version 22.5.1 and later)
407 =========================
408
409 The most robust RAID1 installations, PARALLEL or SKEWED, are installed
410 with:
411
412    lilo -x mbr
413
414 This installation will boot any disk with a RAID partition on any
415 BIOS device code. It is not restricted to PARALLEL installations only
416 as is the next method.
417
418 Equally robust PARALLEL installations will use the new Master Boot
419 Record, activate the RAID1 partition on each drive, and install using
420 the specification that the MBR bios can be relied upon to pass the
421 correct BIOS device code in the DL register:
422
423    lilo -x auto
424      or
425    lilo -x none
426
427 will produce a warning message telling you that the following is needed:
428
429    lilo -M /dev/sda     # install new MBR
430    lilo -A /dev/sda 3   # activate the correct partition (# 3)
431    lilo -M /dev/sdb     # install new MBR
432    lilo -A /dev/sdb 2   # activate the correct partition (# 2)
433
434 If the partitions of the PARALLEL installation are not all primary, the
435 warning message will not be issued, and non-primary partitions will not
436 be bootable.  (The MBR from LILO version 22.5.1 or later MUST be used.
437 Once installed, it does not have to be re-installed each time you update
438 the boot record on the RAID partition.)
439
440 Since it is easier to achieve the most robust state of affairs with
441 the "-x mbr" or "raid-extra-boot=mbr" specification, it is the
442 suggested method of installation.
443
444
445 REMEMBER
446 ========
447
448 With a RAID installation, always run:
449
450    lilo -t
451
452 first -- just to let LILO tell you what it is about to do.  Use the
453 '-v' flag, too, for more verbose output.
454
455
456 REFERENCES
457 ==========
458
459 The 'man' pages for "lilo" and "lilo.conf" have been updated, and are
460 the main reference material for using the new switches and config
461 options.
462
463 The 'README' file in the LILO source directory, generated from the
464 doc materials, is still the best tutorial on booting, as well as a good
465 reference for many of the more obscure lilo options.  The 'man' pages
466 now contain most of this reference material, but in a condensed form.
467
468
469 CREDITS
470 =======
471
472 Thanks to Piete Brooks <lilo+pb@cl.cam.ac.uk> for prodding me
473 into attacking the RAID1 issues, for his incisive criticism of the
474 resulting work as it emerged, and for testing the early codes.
475
476 (end)
477 written 04/19/01 -- John Coffman <johninsd@san.rr.com>
478 updated 05/10/01 -- John Coffman
479 updated 08/08/01 -- John Coffman
480 updated 03/15/03 -- John Coffman (to version 22.5.1)
481 updated 09/07/04 -- John Coffman (spelling & punctuation)