/[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.1 - (show annotations) (download) (as text)
Mon Mar 28 08:13:48 2005 UTC (13 years, 6 months ago) by swift
Branch: MAIN
File MIME type: application/xml
2004.3 docs in 2005.0

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/2004.3/hb-install-x86-bootloader.xml,v 1.2 2005/02/14 15:28:42 swift Exp $ -->
8
9 <sections>
10
11 <version>1.22</version>
12 <date>2005-02-14</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.4.26-gentoo-r9</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 <pre caption = "grub.conf for non-genkernel users">
240 <comment># Which listing to boot as default. 0 is the first, 1 the second etc.</comment>
241 default 0
242 <comment># How many seconds to wait before the default listing is booted.</comment>
243 timeout 30
244 <comment># Nice, fat splash-image to spice things up :)
245 # Comment out if you don't have a graphics card installed</comment>
246 splashimage=(hd0,0)/grub/splash.xpm.gz
247
248 title=Gentoo Linux 2.4.26-r9
249 <comment># Partition where the kernel image (or operating system) is located</comment>
250 root (hd0,0)
251 kernel /kernel-2.4.26-gentoo-r9 root=/dev/hda3
252
253 <comment># The next four lines are only if you dualboot with a Windows system.</comment>
254 <comment># In this case, Windows is hosted on /dev/hda6.</comment>
255 title=Windows XP
256 rootnoverify (hd0,5)
257 makeactive
258 chainloader +1
259 </pre>
260
261
262 <pre caption = "grub.conf for genkernel users">
263 default 0
264 timeout 30
265 splashimage=(hd0,0)/grub/splash.xpm.gz
266
267 title=Gentoo Linux 2.4.26-r9
268 root (hd0,0)
269 kernel /kernel-2.4.26-gentoo-r9 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hda3
270 initrd /initrd-2.4.26-gentoo-r9
271
272 <comment># Only in case you want to dual-boot</comment>
273 title=Windows XP
274 root (hd0,5)
275 makeactive
276 chainloader +1
277 </pre>
278
279
280 <note>
281 If you use a different partitioning scheme and/or kernel image, adjust
282 accordingly. However, make sure that anything that follows a GRUB-device
283 (such as <path>(hd0,0)</path>) is relative to the mountpoint, not the root. In
284 other words, <path>(hd0,0)/grub/splash.xpm.gz</path> is in reality
285 <path>/boot/grub/splash.xpm.gz</path> since <path>(hd0,0)</path> is
286 <path>/boot</path>.
287 </note>
288
289 <p>
290 If you need to pass any additional options to the kernel, simply add
291 them to the end of the kernel command. We're already passing one option
292 (<c>root=/dev/hda3</c> or <c>real_root=/dev/hda3</c>), but you can pass others
293 as well, such as the <c>video</c> and/or <c>vga</c> statements for framebuffer
294 as we discussed previously.
295 </p>
296
297 <p>
298 If you're using a 2.6.7 or higher kernel and you jumpered your harddrive
299 because the BIOS can't handle large harddrives you'll need to append
300 <c>hdx=stroke</c>.
301 </p>
302
303 <p>
304 <c>genkernel</c> users should know that their kernels use the same boot options
305 as is used for the LiveCD. For instance, if you have SCSI devices, you should
306 add <c>doscsi</c> as kernel option.
307 </p>
308
309 <p>
310 Now save the <path>grub.conf</path> file and exit. You still need to install
311 GRUB in the MBR (Master Boot Record) so that GRUB is automatically executed when
312 you boot your system.
313 </p>
314
315 <p>
316 The GRUB developers recommend the use of <c>grub-install</c>. However, if for
317 some reason <c>grub-install</c> fails to work correctly you still have the
318 option to manually install GRUB.
319 </p>
320
321 <p>
322 Continue with <uri link="#grub-install-auto">Default: Setting up GRUB using
323 grub-install</uri> or <uri link="#grub-install-manual">Alternative: Setting up
324 GRUB using manual instructions</uri>.
325 </p>
326
327 </body>
328 </subsection>
329 <subsection id="grub-install-auto">
330 <title>Default: Setting up GRUB using grub-install</title>
331 <body>
332
333 <p>
334 To install GRUB you will need to issue the <c>grub-install</c> command. However,
335 <c>grub-install</c> won't work off-the-shelf since we are inside a chrooted
336 environment. We need to update <path>/etc/mtab</path> (the file with information
337 about all mounted filesystems) first: luckily there is an easy way to accomplish
338 this - just copy over <path>/proc/mounts</path> to <path>/etc/mtab</path>:
339 </p>
340
341 <pre caption="Updating /etc/mtab">
342 # <i>cp /proc/mounts /etc/mtab</i>
343 </pre>
344
345 <p>
346 Now we can install GRUB using <c>grub-install</c>:
347 </p>
348
349 <pre caption="Running grub-install">
350 # <i>grub-install --root-directory=/boot /dev/hda</i>
351 </pre>
352
353 <p>
354 If you have more questions regarding GRUB, please consult the <uri
355 link="http://www.gnu.org/software/grub/grub-faq.html">GRUB FAQ</uri> or the <uri
356 link="http://www.gnu.org/software/grub/manual/">GRUB Manual</uri>.
357 </p>
358
359 <p>
360 Continue with <uri link="#reboot">Rebooting the System</uri>.
361 </p>
362
363 </body>
364 </subsection>
365 <subsection id="grub-install-manual">
366 <title>Alternative: Setting up GRUB using manual instructions</title>
367 <body>
368
369 <p>
370 To start configuring GRUB, you type in <c>grub</c>. You'll be presented
371 with the <path>grub&gt;</path> grub command-line prompt. Now, you need to type
372 in the right commands to install the GRUB boot record onto your hard drive.
373 </p>
374
375 <pre caption =" Starting the GRUB shell">
376 # <i>grub</i>
377 </pre>
378
379 <note>
380 If your system does not have any floppy drives, add the <c>--no-floppy</c>
381 option to the above command to prevent grub from probing the (non-existing)
382 floppy drives.
383 </note>
384
385 <p>
386 In the example configuration we want to install GRUB so that it reads its
387 information from the boot-partition <path>/dev/hda1</path>, and installs the
388 GRUB boot record on the hard drive's MBR (master boot record) so that the first
389 thing we see when we turn on the computer is the GRUB prompt. Of course, if you
390 haven't followed the example configuration during the installation,
391 change the commands accordingly.
392 </p>
393
394 <p>
395 The tab completion mechanism of GRUB can be used from within GRUB.
396 For instance, if you type in "<c>root (</c>" followed by a TAB, you will
397 be presented with a list of devices (such as <path>hd0</path>). If you
398 type in "<c>root (hd0,</c>" followed by a TAB, you will receive a list
399 of available partitions to choose from (such as <path>hd0,0</path>).
400 </p>
401
402 <p>
403 By using the tab completion, setting up GRUB should be not that hard.
404 Now go on, configure GRUB, shall we? :-)
405 </p>
406
407 <pre caption =" Installing GRUB in the MBR">
408 grub&gt; <i>root (hd0,0)</i> <comment>(Specify where your /boot partition resides)</comment>
409 grub&gt; <i>setup (hd0)</i> <comment>(Install GRUB in the MBR)</comment>
410 grub&gt; <i>quit</i> <comment>(Exit the GRUB shell)</comment>
411 </pre>
412
413 <note>
414 If you want to install GRUB in a certain partition instead of the MBR,
415 you have to alter the <c>setup</c> command so it points to the right
416 partition. For instance, if you want GRUB installed in
417 <path>/dev/hda3</path>, then the command becomes <c>setup (hd0,2)</c>.
418 Few users however want to do this.
419 </note>
420
421 <p>
422 If you have more questions regarding GRUB, please consult the <uri
423 link="http://www.gnu.org/software/grub/grub-faq.html">GRUB FAQ</uri> or the <uri
424 link="http://www.gnu.org/software/grub/manual/">GRUB Manual</uri>.
425 </p>
426
427 <note>
428 When you reinstall a kernel, you do not need to copy over the files anymore.
429 Just run <c>make install</c> after compiling the kernel; it will automatically
430 copy the necessary files and adjust the GRUB configuration.
431 </note>
432
433 <p>
434 Continue with <uri link="#reboot">Rebooting the System</uri>.
435 </p>
436
437 </body>
438 </subsection>
439 </section>
440 <section id="lilo">
441 <title>Alternative: Using LILO</title>
442 <subsection>
443 <title>Installing LILO</title>
444 <body>
445
446 <p>
447 LILO, the LInuxLOader, is the tried and true workhorse of Linux
448 bootloaders. However, it lacks some features that GRUB has (which is
449 also the reason why GRUB is currently gaining popularity). The reason
450 why LILO is still used is that, on some systems, GRUB doesn't work and
451 LILO does. Of course, it is also used because some people know LILO and
452 want to stick with it. Either way, Gentoo supports both, and apparently
453 you have chosen to use LILO.
454 </p>
455
456 <p>
457 Installing LILO is a breeze; just use <c>emerge</c>.
458 </p>
459
460 <pre caption = "Installing LILO">
461 # <i>emerge --usepkg lilo</i>
462 </pre>
463
464 </body>
465 </subsection>
466 <subsection>
467 <title>Configuring LILO</title>
468 <body>
469
470 <p>
471 To configure LILO, you must create <path>/etc/lilo.conf</path>. Fire up
472 your favorite editor (in this handbook we use <c>nano</c> for
473 consistency) and create the file.
474 </p>
475
476 <pre caption = "Creating /etc/lilo.conf">
477 # <i>nano -w /etc/lilo.conf</i>
478 </pre>
479
480 <p>
481 Some sections ago we have asked you to remember the kernel-image name
482 you have created. In the next example <path>lilo.conf</path> we assume
483 the imagename is <path>kernel-2.4.26-gentoo-r9</path>. We also use the
484 example partitioning scheme in this example. There are two separate parts:
485 </p>
486
487 <ul>
488 <li>
489 One for those who have not used <c>genkernel</c> to build their kernel
490 </li>
491 <li>
492 One for those who have used <c>genkernel</c> to build their kernel
493 </li>
494 </ul>
495
496 <p>
497 Make sure you use <e>your</e> kernel image filename and, if appropriate,
498 <e>your</e> initrd image filename.
499 </p>
500
501 <pre caption = "Example /etc/lilo.conf">
502 boot=/dev/hda <comment># Install LILO in the MBR</comment>
503 prompt <comment># Give the user the chance to select another section</comment>
504 timeout=50 <comment># Wait 5 (five) seconds before booting the default section</comment>
505 default=gentoo <comment># When the timeout has passed, boot the "gentoo" section</comment>
506
507 <comment># For non-genkernel users</comment>
508 image=/boot/kernel-2.4.26-gentoo-r9
509 label=gentoo <comment># Name we give to this section</comment>
510 read-only <comment># Start with a read-only root. Do not alter!</comment>
511 root=/dev/hda3 <comment># Location of the root filesystem</comment>
512
513 <comment># For genkernel users</comment>
514 image=/boot/kernel-2.4.26-gentoo-r9
515 label=gentoo
516 read-only
517 root=/dev/ram0
518 append="init=/linuxrc ramdisk=8192 real_root=/dev/hda3"
519 initrd=/boot/initrd-2.4.26-gentoo-r9
520
521 <comment># The next two lines are only if you dualboot with a Windows system.</comment>
522 <comment># In this case, Windows is hosted on /dev/hda6.</comment>
523 other=/dev/hda6
524 label=windows
525 </pre>
526
527 <note>
528 If you use a different partitioning scheme and/or kernel image, adjust
529 accordingly.
530 </note>
531
532 <p>
533 If you need to pass any additional options to the kernel, add an
534 <c>append</c> statement to the section. As an example, we add the
535 <c>video</c> statement to enable framebuffer:
536 </p>
537
538 <pre caption = "Using append to add kernel options">
539 image=/boot/kernel-2.4.26-gentoo-r9
540 label=gentoo
541 read-only
542 root=/dev/hda3
543 <i>append="video=vesafb:mtrr,ywrap,1024x768-32@85"</i>
544 </pre>
545
546 <p>
547 If you're using a 2.6.7 or higher kernel and you jumpered your harddrive
548 because the BIOS can't handle large harddrives you'll need to append
549 <c>hdx=stroke</c>.
550 </p>
551
552 <p>
553 <c>genkernel</c> users should know that their kernels use the same boot options
554 as is used for the LiveCD. For instance, if you have SCSI devices, you should
555 add <c>doscsi</c> as kernel option.
556 </p>
557
558
559 <p>
560 Now save the file and exit. To finish up, you have to run <c>/sbin/lilo</c> so
561 LILO can apply the <path>/etc/lilo.conf</path> to your system (i.e. install
562 itself on the disk). Keep in mind that you'll also have to rerun
563 <c>/sbin/lilo</c> every time you install a new kernel or make any changes to
564 the menu.
565 </p>
566
567 <pre caption = "Finishing the LILO installation">
568 # <i>/sbin/lilo</i>
569 </pre>
570
571 <note>
572 When you reinstall a kernel, you do not need to copy over the files anymore.
573 Just run <c>make install</c> after compiling the kernel; it will automatically
574 copy the necessary files and adjust the LILO configuration.
575 </note>
576
577 <p>
578 You can now continue with <uri link="#reboot">Rebooting the System</uri>.
579 </p>
580
581 </body>
582 </subsection>
583 </section>
584 <section id="reboot">
585 <title>Rebooting the System</title>
586 <subsection>
587 <body>
588
589 <p>
590 Exit the chrooted environment and unmount all mounted partitions. Then type in
591 that one magical command you have been waiting for: <c>reboot</c>.
592 </p>
593
594 <pre caption="Unmounting all partitions and rebooting">
595 # <i>exit</i>
596 cdimage ~# <i>cd</i>
597 cdimage ~# <i>umount /mnt/gentoo/boot /mnt/gentoo/proc /mnt/gentoo</i>
598 cdimage ~# <i>reboot</i>
599 </pre>
600
601 <p>
602 Of course, don't forget to remove the bootable CD, otherwise the CD will be
603 booted again instead of your new Gentoo system.
604 </p>
605
606 <p>
607 Once rebooted in your Gentoo installation, finish up with <uri
608 link="?part=1&amp;chap=11">Finalizing your Gentoo Installation</uri>.
609 </p>
610
611 </body>
612 </subsection>
613 </section>
614 </sections>

  ViewVC Help
Powered by ViewVC 1.1.20