/[gentoo]/xml/htdocs/doc/en/handbook/hb-install-x86+amd64-bootloader.xml
Gentoo

Contents of /xml/htdocs/doc/en/handbook/hb-install-x86+amd64-bootloader.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Wed Aug 2 21:15:02 2006 UTC (7 years, 11 months ago) by neysx
Branch: MAIN
File MIME type: application/xml
Copy of latest x86 files

1 <?xml version='1.0' encoding='UTF-8'?>
2 <!DOCTYPE sections SYSTEM "/dtd/book.dtd">
3
4 <!-- The content of this document is licensed under the CC-BY-SA license -->
5 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
6
7 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-install-x86-bootloader.xml,v 1.45 2006/05/28 14:39:58 nightmorph Exp $ -->
8
9 <sections>
10
11 <version>2.13</version>
12 <date>2006-05-28</date>
13
14 <section>
15 <title>Making your Choice</title>
16 <subsection>
17 <title>Introduction</title>
18 <body>
19
20 <p>
21 Now that your kernel is configured and compiled and the necessary system
22 configuration files are filled in correctly, it is time to install a
23 program that will fire up your kernel when you start the system. Such a
24 program is called a <e>bootloader</e>. For x86, Gentoo Linux provides <uri
25 link="#grub">GRUB</uri> and <uri link="#lilo">LILO</uri>. But before we
26 install one of these two bootloaders, we inform you how to configure framebuffer
27 (assuming you want it of course). With framebuffer you can run the Linux command
28 line with (limited) graphical features (such as using the nice bootsplash
29 image Gentoo provides).
30 </p>
31
32 </body>
33 </subsection>
34 <subsection>
35 <title>Optional: Framebuffer</title>
36 <body>
37
38 <p>
39 <e>If</e> you have configured your kernel with framebuffer support (or you used
40 <c>genkernel</c>'s default kernel configuration), you can activate it by adding
41 a <c>vga</c> and/or a <c>video</c> statement to your bootloader configuration
42 file.
43 </p>
44
45 <p>
46 First of all you need to know what type of framebuffer device you're using. If
47 you use a Gentoo patched kernel tree (such as <c>gentoo-sources</c>) you will
48 have had the possibility of selecting <c>vesafb-tng</c> as the <e>VESA driver
49 type</e> (which is default for these kernel sources). If this is the case, you
50 are using <c>vesafb-tng</c> and do not need to set a <c>vga</c> statement.
51 Otherwise you are using the <c>vesafb</c> driver and need to set the <c>vga</c>
52 statement.
53 </p>
54
55 <p>
56 The <c>vga</c> statement controls the resolution and color depth of your
57 framebuffer screen for <c>vesafb</c>. As stated in
58 <path>/usr/src/linux/Documentation/fb/vesafb.txt</path> (which gets installed
59 when you install a kernel source package), you need to pass the VESA number
60 corresponding to the requested resolution and color depth to it.
61 </p>
62
63 <p>
64 The following table lists the available resolutions and colordepths and matches
65 those against the value that you need to pass on to the <c>vga</c> statement.
66 </p>
67
68 <table>
69 <tr>
70 <ti></ti>
71 <th>640x480</th>
72 <th>800x600</th>
73 <th>1024x768</th>
74 <th>1280x1024</th>
75 </tr>
76 <tr>
77 <th>256</th>
78 <ti>0x301</ti>
79 <ti>0x303</ti>
80 <ti>0x305</ti>
81 <ti>0x307</ti>
82 </tr>
83 <tr>
84 <th>32k</th>
85 <ti>0x310</ti>
86 <ti>0x313</ti>
87 <ti>0x316</ti>
88 <ti>0x319</ti>
89 </tr>
90 <tr>
91 <th>64k</th>
92 <ti>0x311</ti>
93 <ti>0x314</ti>
94 <ti>0x317</ti>
95 <ti>0x31A</ti>
96 </tr>
97 <tr>
98 <th>16M</th>
99 <ti>0x312</ti>
100 <ti>0x315</ti>
101 <ti>0x318</ti>
102 <ti>0x31B</ti>
103 </tr>
104 </table>
105
106 <p>
107 The <c>video</c> statement controls framebuffer display options. It needs to be
108 given the framebuffer driver (<c>vesafb</c> for 2.6 kernels, or <c>vesa</c> for
109 2.4 kernels) followed by the control statements you wish to enable. All
110 variables are listed in <path>/usr/src/linux/Documentation/fb/vesafb.txt</path>,
111 but we'll inform you about three most-used options:
112 </p>
113
114 <table>
115 <tr>
116 <th>Control</th>
117 <th>Description</th>
118 </tr>
119 <tr>
120 <ti>ywrap</ti>
121 <ti>
122 Assume that the graphical card can wrap around its memory (i.e. continue at
123 the beginning when it has approached the end)
124 </ti>
125 </tr>
126 <tr>
127 <ti>mtrr:n</ti>
128 <ti>
129 Setup MTRR registers. <c>n</c> can be:
130 0 - disabled
131 1 - uncachable
132 2 - write-back
133 3 - write-combining
134 4 - write-through
135 </ti>
136 </tr>
137 <tr>
138 <ti><c>mode</c></ti>
139 <ti>
140 (<c>vesafb-tng</c> only)<br/>
141 Set up the resolution, color depth and refresh rate. For instance,
142 <c>1024x768-32@85</c> for a resolution of 1024x768, 32 bit color depth and a
143 refresh rate of 85 Hz.
144 </ti>
145 </tr>
146 </table>
147
148 <p>
149 The result of those two statements could be something like <c>vga=0x318
150 video=vesafb:mtrr:3,ywrap</c> or
151 <c>video=vesafb:mtrr:3,ywrap,1024x768-32@85</c>. Remember (or write down) this
152 setting; you will need it shortly.
153 </p>
154
155 <p>
156 Now continue by installing <uri link="#grub">GRUB</uri> <e>or</e> <uri
157 link="#lilo">LILO</uri>.
158 </p>
159
160 </body>
161 </subsection>
162 </section>
163 <section id="grub">
164 <title>Default: Using GRUB</title>
165 <subsection>
166 <title>Understanding GRUB's terminology</title>
167 <body>
168
169 <p>
170 The most critical part of understanding GRUB is getting comfortable with how
171 GRUB refers to hard drives and partitions. Your Linux partition
172 <path>/dev/hda1</path> (for IDE drives) or <path>/dev/sda1</path> (for
173 SATA/SCSI drives) will most likely be called <path>(hd0,0)</path> under GRUB.
174 Notice the parenthesis around the <path>hd0,0</path> - they are required.
175 </p>
176
177 <p>
178 Hard drives count from zero rather than "a" and partitions start at zero
179 rather than one. Be aware too that with the hd devices, only hard drives are
180 counted, not atapi-ide devices such as cdrom players and burners. Also, the
181 same construct is used with SCSI drives. (Normally they get higher numbers
182 than IDE drives except when the BIOS is configured to boot from SCSI devices.)
183 When you ask the BIOS to boot from a different hard disk (for instance your
184 primary slave), <e>that</e> harddisk is seen as <path>hd0</path>.
185 </p>
186
187 <p>
188 Assuming you have a hard drive on <path>/dev/hda</path>, a cdrom player on
189 <path>/dev/hdb</path>, a burner on <path>/dev/hdc</path>, a second hard drive
190 on <path>/dev/hdd</path> and no SCSI hard drive, <path>/dev/hdd7</path> gets
191 translated to <path>(hd1,6)</path>. It might sound tricky and tricky it is
192 indeed, but as we will see, GRUB offers a tab completion mechanism
193 that comes handy for those of you having a lot of hard drives and
194 partitions and who are a little lost in the GRUB numbering scheme.
195 </p>
196
197 <p>
198 Having gotten the feel for that, it is time to install GRUB.
199 </p>
200
201 </body>
202 </subsection>
203 <subsection>
204 <title>Installing GRUB</title>
205 <body>
206
207 <p>
208 To install GRUB, let's first emerge it:
209 </p>
210
211 <pre caption="Installing GRUB">
212 # <i>emerge grub</i>
213 </pre>
214
215 <p>
216 Although GRUB is now installed, we still need to write up a
217 configuration file for it and place GRUB in our MBR so that GRUB automatically
218 boots your newly created kernel. Create <path>/boot/grub/grub.conf</path> with
219 <c>nano</c> (or, if applicable, another editor):
220 </p>
221
222 <pre caption="Creating /boot/grub/grub.conf">
223 # <i>nano -w /boot/grub/grub.conf</i>
224 </pre>
225
226 <p>
227 Now we are going to write up a <path>grub.conf</path>. Below you'll
228 find two possible <path>grub.conf</path> for the partitioning example we use
229 in this guide. We've
230 only extensively commented the first <path>grub.conf</path>. Make sure you use
231 <e>your</e> kernel image filename and, if appropriate, <e>your</e> initrd image
232 filename.
233 </p>
234
235 <ul>
236 <li>
237 The first <path>grub.conf</path> is for people who have not used
238 <c>genkernel</c> to build their kernel
239 </li>
240 <li>
241 The second <path>grub.conf</path> is for people who have used
242 <c>genkernel</c> to build their kernel
243 </li>
244 </ul>
245
246 <note>
247 If your root filesystem is JFS, you <e>must</e> add " ro" to the <c>kernel</c>
248 line since JFS needs to replay its log before it allows read-write mounting.
249 </note>
250
251 <pre caption="grub.conf for non-genkernel users">
252 <comment># Which listing to boot as default. 0 is the first, 1 the second etc.</comment>
253 default 0
254 <comment># How many seconds to wait before the default listing is booted.</comment>
255 timeout 30
256 <comment># Nice, fat splash-image to spice things up :)
257 # Comment out if you don't have a graphics card installed</comment>
258 splashimage=(hd0,0)/boot/grub/splash.xpm.gz
259
260 title=Gentoo Linux 2.6.12-r10
261 <comment># Partition where the kernel image (or operating system) is located</comment>
262 root (hd0,0)
263 kernel /boot/kernel-2.6.12-gentoo-r10 root=/dev/hda3
264
265 <comment># The next four lines are only if you dualboot with a Windows system.</comment>
266 <comment># In this case, Windows is hosted on /dev/hda6.</comment>
267 title=Windows XP
268 rootnoverify (hd0,5)
269 makeactive
270 chainloader +1
271 </pre>
272
273 <pre caption="grub.conf for genkernel users">
274 default 0
275 timeout 30
276 splashimage=(hd0,0)/boot/grub/splash.xpm.gz
277
278 title=Gentoo Linux 2.6.12-r10
279 root (hd0,0)
280 kernel /boot/kernel-genkernel-x86-2.6.12-gentoo-r10 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hda3 udev
281 initrd /boot/initramfs-genkernel-x86-2.6.12-gentoo-r10
282
283 <comment># Only in case you want to dual-boot</comment>
284 title=Windows XP
285 rootnoverify (hd0,5)
286 makeactive
287 chainloader +1
288 </pre>
289
290 <note>
291 The <c>udev</c> mentioned at the end of the kernel line is needed to work around
292 a bug in some genkernel versions <e>if</e> you use udev in the first place
293 (which is the default behaviour).
294 </note>
295
296 <p>
297 If you used a different partitioning scheme and/or kernel image, adjust
298 accordingly. However, make sure that anything that follows a GRUB-device (such
299 as <path>(hd0,0)</path>) is relative to the mountpoint, not the root. In other
300 words, <path>(hd0,0)/grub/splash.xpm.gz</path> is in reality
301 <path>/boot/grub/splash.xpm.gz</path> since <path>(hd0,0)</path> is
302 <path>/boot</path>.
303 </p>
304
305 <p>
306 Besides, if you chose to use a different partitioning scheme and did not put
307 <path>/boot</path> in a separate partition, the <path>/boot</path> prefix used
308 in the above code samples is really <e>required</e>. If you followed our
309 suggested partitioning plan, the <path>/boot</path> prefix it not required, but
310 a <path>boot</path> symlink makes it work. In short, the above examples should
311 work whether you defined a separate <path>/boot</path> partition or not.
312 </p>
313
314 <p>
315 If you need to pass any additional options to the kernel, simply add
316 them to the end of the kernel command. We're already passing one option
317 (<c>root=/dev/hda3</c> or <c>real_root=/dev/hda3</c>), but you can pass others
318 as well, such as the <c>video</c> and/or <c>vga</c> statements for framebuffer
319 as we discussed previously.
320 </p>
321
322 <p>
323 If you're using a 2.6.7 or higher kernel and you jumpered your harddrive
324 because the BIOS can't handle large harddrives you'll need to append
325 <c>hdx=stroke</c>.
326 </p>
327
328 <p>
329 <c>genkernel</c> users should know that their kernels use the same boot options
330 as is used for the Installation CD. For instance, if you have SCSI devices, you
331 should add <c>doscsi</c> as kernel option.
332 </p>
333
334 <p>
335 Now save the <path>grub.conf</path> file and exit. You still need to install
336 GRUB in the MBR (Master Boot Record) so that GRUB is automatically executed when
337 you boot your system.
338 </p>
339
340 <p>
341 The GRUB developers recommend the use of <c>grub-install</c>. However, if for
342 some reason <c>grub-install</c> fails to work correctly you still have the
343 option to manually install GRUB.
344 </p>
345
346 <p>
347 Continue with <uri link="#grub-install-auto">Default: Setting up GRUB using
348 grub-install</uri> or <uri link="#grub-install-manual">Alternative: Setting up
349 GRUB using manual instructions</uri>.
350 </p>
351
352 </body>
353 </subsection>
354 <subsection id="grub-install-auto">
355 <title>Default: Setting up GRUB using grub-install</title>
356 <body>
357
358 <p>
359 To install GRUB you will need to issue the <c>grub-install</c> command.
360 However, <c>grub-install</c> won't work off-the-shelf since we are inside a
361 chrooted environment. We need to create <path>/etc/mtab</path> which lists all
362 mounted filesystems. Fortunately, there is an easy way to accomplish this -
363 just copy over <path>/proc/mounts</path> to <path>/etc/mtab</path>, excluding
364 the <c>rootfs</c> line if you haven't created a separate boot partition. The
365 following command will work in both cases:
366 </p>
367
368 <pre caption="Creating /etc/mtab">
369 # <i>grep -v rootfs /proc/mounts &gt; /etc/mtab</i>
370 </pre>
371
372 <p>
373 Now we can install GRUB using <c>grub-install</c>:
374 </p>
375
376 <pre caption="Running grub-install">
377 # <i>grub-install /dev/hda</i>
378 </pre>
379
380 <p>
381 If you have more questions regarding GRUB, please consult the <uri
382 link="http://www.gnu.org/software/grub/grub-faq.html">GRUB FAQ</uri> or the <uri
383 link="http://www.gnu.org/software/grub/manual/">GRUB Manual</uri>.
384 </p>
385
386 <p>
387 Continue with <uri link="#reboot">Rebooting the System</uri>.
388 </p>
389
390 </body>
391 </subsection>
392 <subsection id="grub-install-manual">
393 <title>Alternative: Setting up GRUB using manual instructions</title>
394 <body>
395
396 <p>
397 To start configuring GRUB, you type in <c>grub</c>. You'll be presented
398 with the <path>grub&gt;</path> grub command-line prompt. Now, you need to type
399 in the right commands to install the GRUB boot record onto your hard drive.
400 </p>
401
402 <pre caption="Starting the GRUB shell">
403 # <i>grub</i>
404 </pre>
405
406 <note>
407 If your system does not have any floppy drives, add the <c>--no-floppy</c>
408 option to the above command to prevent grub from probing the (non-existing)
409 floppy drives.
410 </note>
411
412 <p>
413 In the example configuration we want to install GRUB so that it reads its
414 information from the boot-partition <path>/dev/hda1</path>, and installs the
415 GRUB boot record on the hard drive's MBR (master boot record) so that the first
416 thing we see when we turn on the computer is the GRUB prompt. Of course, if you
417 haven't followed the example configuration during the installation,
418 change the commands accordingly.
419 </p>
420
421 <p>
422 The tab completion mechanism of GRUB can be used from within GRUB.
423 For instance, if you type in "<c>root (</c>" followed by a TAB, you will
424 be presented with a list of devices (such as <path>hd0</path>). If you
425 type in "<c>root (hd0,</c>" followed by a TAB, you will receive a list
426 of available partitions to choose from (such as <path>hd0,0</path>).
427 </p>
428
429 <p>
430 By using the tab completion, setting up GRUB should be not that hard.
431 Now go on, configure GRUB, shall we? :-)
432 </p>
433
434 <pre caption="Installing GRUB in the MBR">
435 grub&gt; <i>root (hd0,0)</i> <comment>(Specify where your /boot partition resides)</comment>
436 grub&gt; <i>setup (hd0)</i> <comment>(Install GRUB in the MBR)</comment>
437 grub&gt; <i>quit</i> <comment>(Exit the GRUB shell)</comment>
438 </pre>
439
440 <note>
441 If you want to install GRUB in a certain partition instead of the MBR,
442 you have to alter the <c>setup</c> command so it points to the right
443 partition. For instance, if you want GRUB installed in
444 <path>/dev/hda3</path>, then the command becomes <c>setup (hd0,2)</c>.
445 Few users however want to do this.
446 </note>
447
448 <p>
449 If you have more questions regarding GRUB, please consult the <uri
450 link="http://www.gnu.org/software/grub/grub-faq.html">GRUB FAQ</uri> or the <uri
451 link="http://www.gnu.org/software/grub/manual/">GRUB Manual</uri>.
452 </p>
453
454 <note>
455 When you reinstall a kernel, you do not need to copy over the files anymore.
456 Just run <c>make install</c> after compiling the kernel; it will automatically
457 copy the necessary files and adjust the GRUB configuration.
458 </note>
459
460 <p>
461 Continue with <uri link="#reboot">Rebooting the System</uri>.
462 </p>
463
464 </body>
465 </subsection>
466 </section>
467 <section id="lilo">
468 <title>Alternative: Using LILO</title>
469 <subsection>
470 <title>Installing LILO</title>
471 <body>
472
473 <p>
474 LILO, the LInuxLOader, is the tried and true workhorse of Linux
475 bootloaders. However, it lacks some features that GRUB has (which is
476 also the reason why GRUB is currently gaining popularity). The reason
477 why LILO is still used is that, on some systems, GRUB doesn't work and
478 LILO does. Of course, it is also used because some people know LILO and
479 want to stick with it. Either way, Gentoo supports both, and apparently
480 you have chosen to use LILO.
481 </p>
482
483 <p>
484 Installing LILO is a breeze; just use <c>emerge</c>.
485 </p>
486
487 <pre caption = "Installing LILO">
488 # <i>emerge lilo</i>
489 </pre>
490
491 </body>
492 </subsection>
493 <subsection>
494 <title>Configuring LILO</title>
495 <body>
496
497 <p>
498 To configure LILO, you must create <path>/etc/lilo.conf</path>. Fire up
499 your favorite editor (in this handbook we use <c>nano</c> for
500 consistency) and create the file.
501 </p>
502
503 <pre caption = "Creating /etc/lilo.conf">
504 # <i>nano -w /etc/lilo.conf</i>
505 </pre>
506
507 <p>
508 Some sections ago we have asked you to remember the kernel-image name
509 you have created. In the next example <path>lilo.conf</path> we use the
510 example partitioning scheme. There are two separate parts:
511 </p>
512
513 <ul>
514 <li>
515 One for those who have not used <c>genkernel</c> to build their kernel
516 </li>
517 <li>
518 One for those who have used <c>genkernel</c> to build their kernel
519 </li>
520 </ul>
521
522 <p>
523 Make sure you use <e>your</e> kernel image filename and, if appropriate,
524 <e>your</e> initrd image filename.
525 </p>
526
527 <note>
528 If your root filesystem is JFS, you <e>must</e> add a <c>append="ro"</c>
529 line after each boot item since JFS needs to replay its log before it allows
530 read-write mounting.
531 </note>
532
533 <pre caption = "Example /etc/lilo.conf">
534 boot=/dev/hda <comment># Install LILO in the MBR</comment>
535 prompt <comment># Give the user the chance to select another section</comment>
536 timeout=50 <comment># Wait 5 (five) seconds before booting the default section</comment>
537 default=gentoo <comment># When the timeout has passed, boot the "gentoo" section</comment>
538
539 <comment># For non-genkernel users</comment>
540 image=/boot/kernel-2.6.12-gentoo-r10
541 label=gentoo <comment># Name we give to this section</comment>
542 read-only <comment># Start with a read-only root. Do not alter!</comment>
543 root=/dev/hda3 <comment># Location of the root filesystem</comment>
544
545 <comment># For genkernel users</comment>
546 image=/boot/kernel-genkernel-x86-2.6.12-gentoo-r10
547 label=gentoo
548 read-only
549 root=/dev/ram0
550 append="init=/linuxrc ramdisk=8192 real_root=/dev/hda3 udev"
551 initrd=/boot/initramfs-genkernel-2.6.12-gentoo-r10
552
553 <comment># The next two lines are only if you dualboot with a Windows system.</comment>
554 <comment># In this case, Windows is hosted on /dev/hda6.</comment>
555 other=/dev/hda6
556 label=windows
557 </pre>
558
559 <note>
560 The <c>udev</c> mentioned at the end of the append line is needed to work around
561 a bug in some genkernel versions <e>if</e> you use udev in the first place
562 (which is the default behaviour).
563 </note>
564
565 <note>
566 If you use a different partitioning scheme and/or kernel image, adjust
567 accordingly.
568 </note>
569
570 <p>
571 If you need to pass any additional options to the kernel, add an
572 <c>append</c> statement to the section. As an example, we add the
573 <c>video</c> statement to enable framebuffer:
574 </p>
575
576 <pre caption = "Using append to add kernel options">
577 image=/boot/kernel-2.6.12-gentoo-r10
578 label=gentoo
579 read-only
580 root=/dev/hda3
581 <i>append="video=vesafb:mtrr,ywrap,1024x768-32@85"</i>
582 </pre>
583
584 <p>
585 If you're using a 2.6.7 or higher kernel and you jumpered your harddrive
586 because the BIOS can't handle large harddrives you'll need to append
587 <c>hdx=stroke</c>.
588 </p>
589
590 <p>
591 <c>genkernel</c> users should know that their kernels use the same boot options
592 as is used for the Installation CD. For instance, if you have SCSI devices, you
593 should add <c>doscsi</c> as kernel option.
594 </p>
595
596
597 <p>
598 Now save the file and exit. To finish up, you have to run <c>/sbin/lilo</c> so
599 LILO can apply the <path>/etc/lilo.conf</path> to your system (i.e. install
600 itself on the disk). Keep in mind that you'll also have to rerun
601 <c>/sbin/lilo</c> every time you install a new kernel or make any changes to
602 the menu.
603 </p>
604
605 <pre caption = "Finishing the LILO installation">
606 # <i>/sbin/lilo</i>
607 </pre>
608
609 <note>
610 When you reinstall a kernel, you do not need to copy over the files anymore.
611 Just run <c>make install</c> after compiling the kernel; it will automatically
612 copy the necessary files and adjust the LILO configuration.
613 </note>
614
615 <p>
616 You can now continue with <uri link="#reboot">Rebooting the System</uri>.
617 </p>
618
619 </body>
620 </subsection>
621 </section>
622 <section id="reboot">
623 <title>Rebooting the System</title>
624 <subsection>
625 <body>
626
627 <p>
628 Exit the chrooted environment and unmount all mounted partitions. Then type in
629 that one magical command you have been waiting for: <c>reboot</c>.
630 </p>
631
632 <pre caption="Unmounting all partitions and rebooting">
633 # <i>exit</i>
634 cdimage ~# <i>cd</i>
635 cdimage ~# <i>umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo</i>
636 cdimage ~# <i>reboot</i>
637 </pre>
638
639 <p>
640 Of course, don't forget to remove the bootable CD, otherwise the CD will be
641 booted again instead of your new Gentoo system.
642 </p>
643
644 <p>
645 Once rebooted in your Gentoo installation, finish up with <uri
646 link="?part=1&amp;chap=11">Finalizing your Gentoo Installation</uri>.
647 </p>
648
649 </body>
650 </subsection>
651 </section>
652 </sections>

  ViewVC Help
Powered by ViewVC 1.1.20