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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download) (as text)
Sat Apr 16 09:42:50 2005 UTC (12 years, 10 months ago) by neysx
Branch: MAIN
Changes since 1.3: +4 -4 lines
File MIME type: application/xml
#89266 s/2.4/2.6/

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/1.0 -->
6
7 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/2005.0/hb-install-x86-bootloader.xml,v 1.3 2005/03/29 21:04:39 swift Exp $ -->
8
9 <sections>
10
11 <version>4.2</version>
12 <date>2005-04-16</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</ti>
128 <ti>
129 Setup MTRR registers
130 </ti>
131 </tr>
132 <tr>
133 <ti><c>mode</c></ti>
134 <ti>
135 (<c>vesafb-tng</c> only)<br/>
136 Set up the resolution, color depth and refresh rate. For instance,
137 <c>1024x768-32@85</c> for a resolution of 1024x768, 32 bit color depth and a
138 refresh rate of 85 Hz.
139 </ti>
140 </tr>
141 </table>
142
143 <p>
144 The result of those two statements could be something like <c>vga=0x318
145 video=vesafb:mtrr,ywrap</c> or <c>video=vesafb:mtrr,ywrap,1024x768-32@85</c>.
146 Remember (or write down) this setting; you will need it shortly.
147 </p>
148
149 <p>
150 Now continue by installing <uri link="#grub">GRUB</uri> <e>or</e> <uri
151 link="#lilo">LILO</uri>.
152 </p>
153
154 </body>
155 </subsection>
156 </section>
157 <section id="grub">
158 <title>Default: Using GRUB</title>
159 <subsection>
160 <title>Understanding GRUB's terminology</title>
161 <body>
162
163 <p>
164 The most critical part of understanding GRUB is getting comfortable with
165 how GRUB refers to hard drives and partitions. Your Linux partition
166 <path>/dev/hda1</path> will most likely be called <path>(hd0,0)</path> under
167 GRUB. Notice the parenthesis around the <path>hd0,0</path> - they are required.
168 </p>
169
170 <p>
171 Hard drives count from zero rather than "a" and partitions start at zero
172 rather than one. Be aware too that with the hd devices, only hard drives are
173 counted, not atapi-ide devices such as cdrom players and burners. Also, the
174 same construct is used with scsi drives. (Normally they get higher numbers
175 than ide drives except when the bios is configured to boot from scsi devices.)
176 When you ask the BIOS to boot from a different hard disk (for instance your
177 primary slave), <e>that</e> harddisk is seen as <path>hd0</path>.
178 </p>
179
180 <p>
181 Assuming you have a hard drive on <path>/dev/hda</path>, a cdrom player on
182 <path>/dev/hdb</path>, a burner on <path>/dev/hdc</path>, a second hard drive
183 on <path>/dev/hdd</path> and no SCSI hard drive, <path>/dev/hdd7</path> gets
184 translated to <path>(hd1,6)</path>. It might sound tricky and tricky it is
185 indeed, but as we will see, GRUB offers a tab completion mechanism
186 that comes handy for those of you having a lot of hard drives and
187 partitions and who are a little lost in the GRUB numbering scheme.
188 </p>
189
190 <p>
191 Having gotten the feel for that, it is time to install GRUB.
192 </p>
193
194 </body>
195 </subsection>
196 <subsection>
197 <title>Installing GRUB</title>
198 <body>
199
200 <p>
201 To install GRUB, let's first emerge it:
202 </p>
203
204 <pre caption = "Installing GRUB">
205 # <i>emerge grub</i>
206 </pre>
207
208 <p>
209 Although GRUB is now installed, we still need to write up a
210 configuration file for it and place GRUB in our MBR so that GRUB automatically
211 boots your newly created kernel. Create <path>/boot/grub/grub.conf</path> with
212 <c>nano</c> (or, if applicable, another editor):
213 </p>
214
215 <pre caption = "Creating /boot/grub/grub.conf">
216 # <i>nano -w /boot/grub/grub.conf</i>
217 </pre>
218
219 <p>
220 Now we are going to write up a <path>grub.conf</path>. Below you'll
221 find two possible <path>grub.conf</path> for the partitioning example we use
222 in this guide, with kernel image <path>kernel-2.6.11-gentoo-r3</path>. We've
223 only extensively commented the first <path>grub.conf</path>. Make sure you use
224 <e>your</e> kernel image filename and, if appropriate, <e>your</e> initrd image
225 filename.
226 </p>
227
228 <ul>
229 <li>
230 The first <path>grub.conf</path> is for people who have not used
231 <c>genkernel</c> to build their kernel
232 </li>
233 <li>
234 The second <path>grub.conf</path> is for people who have used
235 <c>genkernel</c> to build their kernel
236 </li>
237 </ul>
238
239 <note>
240 If your root filesystem is JFS, you <e>must</e> add " ro" to the <c>kernel</c>
241 line since JFS needs to replay its log before it allows read-write mounting.
242 </note>
243
244 <pre caption = "grub.conf for non-genkernel users">
245 <comment># Which listing to boot as default. 0 is the first, 1 the second etc.</comment>
246 default 0
247 <comment># How many seconds to wait before the default listing is booted.</comment>
248 timeout 30
249 <comment># Nice, fat splash-image to spice things up :)
250 # Comment out if you don't have a graphics card installed</comment>
251 splashimage=(hd0,0)/grub/splash.xpm.gz
252
253 title=Gentoo Linux 2.6.11-r3
254 <comment># Partition where the kernel image (or operating system) is located</comment>
255 root (hd0,0)
256 kernel /kernel-2.6.11-gentoo-r3 root=/dev/hda3
257
258 <comment># The next four lines are only if you dualboot with a Windows system.</comment>
259 <comment># In this case, Windows is hosted on /dev/hda6.</comment>
260 title=Windows XP
261 rootnoverify (hd0,5)
262 makeactive
263 chainloader +1
264 </pre>
265
266
267 <pre caption = "grub.conf for genkernel users">
268 default 0
269 timeout 30
270 splashimage=(hd0,0)/grub/splash.xpm.gz
271
272 title=Gentoo Linux 2.6.11-r3
273 root (hd0,0)
274 kernel /kernel-2.6.11-gentoo-r3 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hda3
275 initrd /initrd-2.6.11-gentoo-r3
276
277 <comment># Only in case you want to dual-boot</comment>
278 title=Windows XP
279 root (hd0,5)
280 makeactive
281 chainloader +1
282 </pre>
283
284
285 <note>
286 If you use a different partitioning scheme and/or kernel image, adjust
287 accordingly. However, make sure that anything that follows a GRUB-device
288 (such as <path>(hd0,0)</path>) is relative to the mountpoint, not the root. In
289 other words, <path>(hd0,0)/grub/splash.xpm.gz</path> is in reality
290 <path>/boot/grub/splash.xpm.gz</path> since <path>(hd0,0)</path> is
291 <path>/boot</path>.
292 </note>
293
294 <p>
295 If you need to pass any additional options to the kernel, simply add
296 them to the end of the kernel command. We're already passing one option
297 (<c>root=/dev/hda3</c> or <c>real_root=/dev/hda3</c>), but you can pass others
298 as well, such as the <c>video</c> and/or <c>vga</c> statements for framebuffer
299 as we discussed previously.
300 </p>
301
302 <p>
303 If you're using a 2.6.7 or higher kernel and you jumpered your harddrive
304 because the BIOS can't handle large harddrives you'll need to append
305 <c>hdx=stroke</c>.
306 </p>
307
308 <p>
309 <c>genkernel</c> users should know that their kernels use the same boot options
310 as is used for the Installation CD. For instance, if you have SCSI devices, you
311 should add <c>doscsi</c> as kernel option.
312 </p>
313
314 <p>
315 Now save the <path>grub.conf</path> file and exit. You still need to install
316 GRUB in the MBR (Master Boot Record) so that GRUB is automatically executed when
317 you boot your system.
318 </p>
319
320 <p>
321 The GRUB developers recommend the use of <c>grub-install</c>. However, if for
322 some reason <c>grub-install</c> fails to work correctly you still have the
323 option to manually install GRUB.
324 </p>
325
326 <p>
327 Continue with <uri link="#grub-install-auto">Default: Setting up GRUB using
328 grub-install</uri> or <uri link="#grub-install-manual">Alternative: Setting up
329 GRUB using manual instructions</uri>.
330 </p>
331
332 </body>
333 </subsection>
334 <subsection id="grub-install-auto">
335 <title>Default: Setting up GRUB using grub-install</title>
336 <body>
337
338 <p>
339 To install GRUB you will need to issue the <c>grub-install</c> command. However,
340 <c>grub-install</c> won't work off-the-shelf since we are inside a chrooted
341 environment. We need to update <path>/etc/mtab</path> (the file with information
342 about all mounted filesystems) first: luckily there is an easy way to accomplish
343 this - just copy over <path>/proc/mounts</path> to <path>/etc/mtab</path>:
344 </p>
345
346 <pre caption="Updating /etc/mtab">
347 # <i>cp /proc/mounts /etc/mtab</i>
348 </pre>
349
350 <p>
351 Now we can install GRUB using <c>grub-install</c>:
352 </p>
353
354 <pre caption="Running grub-install">
355 # <i>grub-install --root-directory=/boot /dev/hda</i>
356 </pre>
357
358 <p>
359 If you have more questions regarding GRUB, please consult the <uri
360 link="http://www.gnu.org/software/grub/grub-faq.html">GRUB FAQ</uri> or the <uri
361 link="http://www.gnu.org/software/grub/manual/">GRUB Manual</uri>.
362 </p>
363
364 <p>
365 Continue with <uri link="#reboot">Rebooting the System</uri>.
366 </p>
367
368 </body>
369 </subsection>
370 <subsection id="grub-install-manual">
371 <title>Alternative: Setting up GRUB using manual instructions</title>
372 <body>
373
374 <p>
375 To start configuring GRUB, you type in <c>grub</c>. You'll be presented
376 with the <path>grub&gt;</path> grub command-line prompt. Now, you need to type
377 in the right commands to install the GRUB boot record onto your hard drive.
378 </p>
379
380 <pre caption =" Starting the GRUB shell">
381 # <i>grub</i>
382 </pre>
383
384 <note>
385 If your system does not have any floppy drives, add the <c>--no-floppy</c>
386 option to the above command to prevent grub from probing the (non-existing)
387 floppy drives.
388 </note>
389
390 <p>
391 In the example configuration we want to install GRUB so that it reads its
392 information from the boot-partition <path>/dev/hda1</path>, and installs the
393 GRUB boot record on the hard drive's MBR (master boot record) so that the first
394 thing we see when we turn on the computer is the GRUB prompt. Of course, if you
395 haven't followed the example configuration during the installation,
396 change the commands accordingly.
397 </p>
398
399 <p>
400 The tab completion mechanism of GRUB can be used from within GRUB.
401 For instance, if you type in "<c>root (</c>" followed by a TAB, you will
402 be presented with a list of devices (such as <path>hd0</path>). If you
403 type in "<c>root (hd0,</c>" followed by a TAB, you will receive a list
404 of available partitions to choose from (such as <path>hd0,0</path>).
405 </p>
406
407 <p>
408 By using the tab completion, setting up GRUB should be not that hard.
409 Now go on, configure GRUB, shall we? :-)
410 </p>
411
412 <pre caption =" Installing GRUB in the MBR">
413 grub&gt; <i>root (hd0,0)</i> <comment>(Specify where your /boot partition resides)</comment>
414 grub&gt; <i>setup (hd0)</i> <comment>(Install GRUB in the MBR)</comment>
415 grub&gt; <i>quit</i> <comment>(Exit the GRUB shell)</comment>
416 </pre>
417
418 <note>
419 If you want to install GRUB in a certain partition instead of the MBR,
420 you have to alter the <c>setup</c> command so it points to the right
421 partition. For instance, if you want GRUB installed in
422 <path>/dev/hda3</path>, then the command becomes <c>setup (hd0,2)</c>.
423 Few users however want to do this.
424 </note>
425
426 <p>
427 If you have more questions regarding GRUB, please consult the <uri
428 link="http://www.gnu.org/software/grub/grub-faq.html">GRUB FAQ</uri> or the <uri
429 link="http://www.gnu.org/software/grub/manual/">GRUB Manual</uri>.
430 </p>
431
432 <note>
433 When you reinstall a kernel, you do not need to copy over the files anymore.
434 Just run <c>make install</c> after compiling the kernel; it will automatically
435 copy the necessary files and adjust the GRUB configuration.
436 </note>
437
438 <p>
439 Continue with <uri link="#reboot">Rebooting the System</uri>.
440 </p>
441
442 </body>
443 </subsection>
444 </section>
445 <section id="lilo">
446 <title>Alternative: Using LILO</title>
447 <subsection>
448 <title>Installing LILO</title>
449 <body>
450
451 <p>
452 LILO, the LInuxLOader, is the tried and true workhorse of Linux
453 bootloaders. However, it lacks some features that GRUB has (which is
454 also the reason why GRUB is currently gaining popularity). The reason
455 why LILO is still used is that, on some systems, GRUB doesn't work and
456 LILO does. Of course, it is also used because some people know LILO and
457 want to stick with it. Either way, Gentoo supports both, and apparently
458 you have chosen to use LILO.
459 </p>
460
461 <p>
462 Installing LILO is a breeze; just use <c>emerge</c>.
463 </p>
464
465 <pre caption = "Installing LILO">
466 # <i>emerge --usepkg lilo</i>
467 </pre>
468
469 </body>
470 </subsection>
471 <subsection>
472 <title>Configuring LILO</title>
473 <body>
474
475 <p>
476 To configure LILO, you must create <path>/etc/lilo.conf</path>. Fire up
477 your favorite editor (in this handbook we use <c>nano</c> for
478 consistency) and create the file.
479 </p>
480
481 <pre caption = "Creating /etc/lilo.conf">
482 # <i>nano -w /etc/lilo.conf</i>
483 </pre>
484
485 <p>
486 Some sections ago we have asked you to remember the kernel-image name
487 you have created. In the next example <path>lilo.conf</path> we assume
488 the imagename is <path>kernel-2.6.11-gentoo-r3</path>. We also use the
489 example partitioning scheme in this example. There are two separate parts:
490 </p>
491
492 <ul>
493 <li>
494 One for those who have not used <c>genkernel</c> to build their kernel
495 </li>
496 <li>
497 One for those who have used <c>genkernel</c> to build their kernel
498 </li>
499 </ul>
500
501 <p>
502 Make sure you use <e>your</e> kernel image filename and, if appropriate,
503 <e>your</e> initrd image filename.
504 </p>
505
506 <note>
507 If your root filesystem is JFS, you <e>must</e> add an <c>append="ro"</c> line
508 to each boot image since JFS needs to replay its log before it allows
509 read-write mounting.
510 </note>
511
512 <pre caption = "Example /etc/lilo.conf">
513 boot=/dev/hda <comment># Install LILO in the MBR</comment>
514 prompt <comment># Give the user the chance to select another section</comment>
515 timeout=50 <comment># Wait 5 (five) seconds before booting the default section</comment>
516 default=gentoo <comment># When the timeout has passed, boot the "gentoo" section</comment>
517
518 <comment># For non-genkernel users</comment>
519 image=/boot/kernel-2.6.11-gentoo-r3
520 label=gentoo <comment># Name we give to this section</comment>
521 read-only <comment># Start with a read-only root. Do not alter!</comment>
522 root=/dev/hda3 <comment># Location of the root filesystem</comment>
523
524 <comment># For genkernel users</comment>
525 image=/boot/kernel-2.6.11-gentoo-r3
526 label=gentoo
527 read-only
528 root=/dev/ram0
529 append="init=/linuxrc ramdisk=8192 real_root=/dev/hda3"
530 initrd=/boot/initrd-2.6.11-gentoo-r3
531
532 <comment># The next two lines are only if you dualboot with a Windows system.</comment>
533 <comment># In this case, Windows is hosted on /dev/hda6.</comment>
534 other=/dev/hda6
535 label=windows
536 </pre>
537
538 <note>
539 If you use a different partitioning scheme and/or kernel image, adjust
540 accordingly.
541 </note>
542
543 <p>
544 If you need to pass any additional options to the kernel, add an
545 <c>append</c> statement to the section. As an example, we add the
546 <c>video</c> statement to enable framebuffer:
547 </p>
548
549 <pre caption = "Using append to add kernel options">
550 image=/boot/kernel-2.6.11-gentoo-r3
551 label=gentoo
552 read-only
553 root=/dev/hda3
554 <i>append="video=vesafb:mtrr,ywrap,1024x768-32@85"</i>
555 </pre>
556
557 <p>
558 If you're using a 2.6.7 or higher kernel and you jumpered your harddrive
559 because the BIOS can't handle large harddrives you'll need to append
560 <c>hdx=stroke</c>.
561 </p>
562
563 <p>
564 <c>genkernel</c> users should know that their kernels use the same boot options
565 as is used for the Installation CD. For instance, if you have SCSI devices, you
566 should add <c>doscsi</c> as kernel option.
567 </p>
568
569
570 <p>
571 Now save the file and exit. To finish up, you have to run <c>/sbin/lilo</c> so
572 LILO can apply the <path>/etc/lilo.conf</path> to your system (i.e. install
573 itself on the disk). Keep in mind that you'll also have to rerun
574 <c>/sbin/lilo</c> every time you install a new kernel or make any changes to
575 the menu.
576 </p>
577
578 <pre caption = "Finishing the LILO installation">
579 # <i>/sbin/lilo</i>
580 </pre>
581
582 <note>
583 When you reinstall a kernel, you do not need to copy over the files anymore.
584 Just run <c>make install</c> after compiling the kernel; it will automatically
585 copy the necessary files and adjust the LILO configuration.
586 </note>
587
588 <p>
589 You can now continue with <uri link="#reboot">Rebooting the System</uri>.
590 </p>
591
592 </body>
593 </subsection>
594 </section>
595 <section id="reboot">
596 <title>Rebooting the System</title>
597 <subsection>
598 <body>
599
600 <p>
601 Exit the chrooted environment and unmount all mounted partitions. Then type in
602 that one magical command you have been waiting for: <c>reboot</c>.
603 </p>
604
605 <pre caption="Unmounting all partitions and rebooting">
606 # <i>exit</i>
607 cdimage ~# <i>cd</i>
608 cdimage ~# <i>umount /mnt/gentoo/boot /mnt/gentoo/proc /mnt/gentoo</i>
609 cdimage ~# <i>reboot</i>
610 </pre>
611
612 <p>
613 Of course, don't forget to remove the bootable CD, otherwise the CD will be
614 booted again instead of your new Gentoo system.
615 </p>
616
617 <p>
618 Once rebooted in your Gentoo installation, finish up with <uri
619 link="?part=1&amp;chap=11">Finalizing your Gentoo Installation</uri>.
620 </p>
621
622 </body>
623 </subsection>
624 </section>
625 </sections>

  ViewVC Help
Powered by ViewVC 1.1.20