Difference between revisions of "How to setup boot loaders"
(→Installation of a GRUB boot loader) |
(→LILO) |
||
Line 31: | Line 31: | ||
===LILO=== | ===LILO=== | ||
+ | LILO (LInux LOader) is one of the oldest linux and multiboot boot loaders. It is feature rich, dependable and widely used. Since LILO is configured through a human readable, easy to understand configuration file it is easy to setup. | ||
+ | |||
+ | LILOs classical way of behaving is to offer a single input line on boot, enabling you to type the label of the system to be booted and provide additional boot parameters. It can also print a message, or - in newer versions - it can be configured to show a menu (even a graphical one) so that you can pick your system more comfortably. | ||
+ | |||
+ | ====Creating a LILO bootdisk==== | ||
+ | As a fallback it is always good to create a simple LILO bootdisk. We are creating a simple LILO bootdisk here, not a Linux bootdisk, which is a different thing and would require more comprehensive steps. | ||
+ | * You need to configure LILO beforehand, so edit {{path|lilo.conf}} to fit your configuration. | ||
+ | * Insert a formatted floppy disk to your floppy drive, but do not mount it. | ||
+ | * Now do a {{cmdroot|lilo -v -b /dev/fd0}}. This overrides the <tt>boot=...</tt> line in the config file and writes the configured boot sector to the floppy. | ||
+ | That's it. You can use this floppy as long as your system layout is the same (as long as you don't need to modify {{path|/etc/lilo.conf}}). Whenever you modify LILOs configuration, you should recreate the bootdisk using the command above. | ||
+ | |||
+ | ====Installation of a LILO boot loader==== | ||
+ | The {{cmdroot|lilo}} command is used to install the LILO boot loader. It reads the configuration file, calculates the block offset of the configured kernel images and writes the necessary data to the boot sector. | ||
+ | |||
+ | *LILO is configured by editing {{path|/etc/lilo.conf}}.<br />The format is explained in {{cmd|man lilo.conf}}. | ||
+ | :A simple example configuration could look like this: | ||
+ | boot=/dev/hda | ||
+ | map=/boot/map | ||
+ | install=/boot/boot.b | ||
+ | prompt | ||
+ | timeout=100 | ||
+ | compact | ||
+ | default=Linux | ||
+ | image=/boot/vmlinuz | ||
+ | label=Linux | ||
+ | root=/dev/hda2 | ||
+ | read-only | ||
+ | other=/dev/hda1 | ||
+ | label=Windows | ||
+ | *Run the {{cmdroot|lilo}} command to write lilo to the MBR. | ||
+ | *Reboot your machine. | ||
+ | {{NOTE|Since LILO doesn't know about file systems and saves the kernel images positions based on a block count, you will have to rerun the <tt>lilo</tt> command everytime you did modifications to your kernel image. This includes recompiling or reinstalling the kernel as well as moving it to somewhere else or defragmenting the file system. | ||
+ | |||
+ | If you do not rerun <tt>lilo</tt> after such operations, you will render your system unbootable. | ||
+ | }} | ||
===GRUB=== | ===GRUB=== | ||
Line 47: | Line 82: | ||
*Usually the files needed for GRUB should reside in {{path|/boot/grub}}. | *Usually the files needed for GRUB should reside in {{path|/boot/grub}}. | ||
*Copy over the necessary stage files from {{path|/usr/share/grub/i386-pc/}} or {{path|/usr/lib/grub/i386-pc}}. You will need {{path|stage1}}, {{path|stage2}} and usually one or more stage 1.5 files matching your filesystem. Usually these are {{path|e2fs_stage1_5}}, {{path|reiserfs_stage1_5}} or {{path|iso9660_stage1_5}}. Look into the directory for support of other filesystems. | *Copy over the necessary stage files from {{path|/usr/share/grub/i386-pc/}} or {{path|/usr/lib/grub/i386-pc}}. You will need {{path|stage1}}, {{path|stage2}} and usually one or more stage 1.5 files matching your filesystem. Usually these are {{path|e2fs_stage1_5}}, {{path|reiserfs_stage1_5}} or {{path|iso9660_stage1_5}}. Look into the directory for support of other filesystems. | ||
− | *To get the comfortable GRUB boot menu you will have to create the file {{path|/boot/grub/menu.lst}}. | + | *To get the comfortable GRUB boot menu you will have to create the file {{path|/boot/grub/menu.lst}}. The format of it is explained in GRUBs info page ({{cmd|info grub}}). |
*Once everything is setup in {{path|/boot/grub}}, launch the GRUB console by running {{cmdroot|grub}}. | *Once everything is setup in {{path|/boot/grub}}, launch the GRUB console by running {{cmdroot|grub}}. | ||
*Within the console select the partition on which your {{path|/boot/grub}} directory resides using the <tt>root</tt> command, i.e. for the second partion on the first harddisk ({{path|/dev/hda2}}), enter | *Within the console select the partition on which your {{path|/boot/grub}} directory resides using the <tt>root</tt> command, i.e. for the second partion on the first harddisk ({{path|/dev/hda2}}), enter |
Revision as of 17:51, 3 September 2005
This page (hopefully) will explain everything you should know about the major bootloaders so that you can configure them to your liking. |
LILO, GRUB and NT Boot Loader
LILO | GRUB | NT Boot Loader | |
---|---|---|---|
boot selector |
|
|
|
OS support | GNU/Linux | FreeBSD, NetBSD, OpenBSD, GNU/Linux | none |
Windows Support | via chain-loading | via chain-loading | WinNT, Win2K, WinXP |
supported filesystems | block offset based | BSD FFS, FAT16, FAT32, Minix fs, ext2fs, ReiserFS, JFS, XFS, VSTa | FAT16, FAT32, NTFS |
Partition designation example (second partion on first harddisk) |
/dev/hda2 | (hd0,1) | multi(0)disk(0)rdisk(0)partition(2) |
LILO
LILO (LInux LOader) is one of the oldest linux and multiboot boot loaders. It is feature rich, dependable and widely used. Since LILO is configured through a human readable, easy to understand configuration file it is easy to setup.
LILOs classical way of behaving is to offer a single input line on boot, enabling you to type the label of the system to be booted and provide additional boot parameters. It can also print a message, or - in newer versions - it can be configured to show a menu (even a graphical one) so that you can pick your system more comfortably.
Creating a LILO bootdisk
As a fallback it is always good to create a simple LILO bootdisk. We are creating a simple LILO bootdisk here, not a Linux bootdisk, which is a different thing and would require more comprehensive steps.
- You need to configure LILO beforehand, so edit lilo.conf to fit your configuration.
- Insert a formatted floppy disk to your floppy drive, but do not mount it.
- Now do a
# lilo -v -b /dev/fd0
. This overrides the boot=... line in the config file and writes the configured boot sector to the floppy.
That's it. You can use this floppy as long as your system layout is the same (as long as you don't need to modify /etc/lilo.conf). Whenever you modify LILOs configuration, you should recreate the bootdisk using the command above.
Installation of a LILO boot loader
The # lilo
command is used to install the LILO boot loader. It reads the configuration file, calculates the block offset of the configured kernel images and writes the necessary data to the boot sector.
- LILO is configured by editing /etc/lilo.conf.
The format is explained in{{{2}}} man lilo.conf
.
- A simple example configuration could look like this:
boot=/dev/hda map=/boot/map install=/boot/boot.b prompt timeout=100 compact default=Linux image=/boot/vmlinuz label=Linux root=/dev/hda2 read-only other=/dev/hda1 label=Windows
- Run the
# lilo
command to write lilo to the MBR. - Reboot your machine.
If you do not rerun lilo after such operations, you will render your system unbootable.
GRUB
GNU GRUB (GRand Unified Bootloader) is surely the most powerful of the bootloaders listed here. Besides featuring a nice and comfortable boot menu and a human readable easy to understand configuration file, it offers an interactive console which can be the perfect tool for recovering boot problems.
Creating a GRUB bootdisk
As a fallback it is always good to create a GRUB bootdisk, especially because for GRUB this is very quick and simple.
- Insert a formatted floppy disk to your floppy drive, but do not mount it.
- Execute the following commands to create the boot disk (you may need to change /usr/share to /usr/lib):
# dd if=/usr/share/grub/i386-pc/stage1 of=/dev/fd0 bs=512 count=1
# dd if=/usr/share/grub/i386-pc/stage2 of=/dev/fd0 bs=512 seek=1
That's it. The created disk will boot directly into the interactive GRUB console. Use help there to get a list of available commands.
Installation of a GRUB boot loader
- Usually the files needed for GRUB should reside in /boot/grub.
- Copy over the necessary stage files from /usr/share/grub/i386-pc/ or /usr/lib/grub/i386-pc. You will need stage1, stage2 and usually one or more stage 1.5 files matching your filesystem. Usually these are e2fs_stage1_5, reiserfs_stage1_5 or iso9660_stage1_5. Look into the directory for support of other filesystems.
- To get the comfortable GRUB boot menu you will have to create the file /boot/grub/menu.lst. The format of it is explained in GRUBs info page (
{{{2}}} info grub
). - Once everything is setup in /boot/grub, launch the GRUB console by running
# grub
. - Within the console select the partition on which your /boot/grub directory resides using the root command, i.e. for the second partion on the first harddisk (/dev/hda2), enter
- root (hd0,1)
- After that is successfully done, install the bootloader to the MBR using
- setup (hd0)
- Reboot your machine to try if it works.
NT Boot Loader
The Windows 2000/XP boot loader is a bit hard to tweak if you want something else than use it to choose between your Windows installations.
The NT Boot Loader generally works like this:
- The booted partitions (i.e. the active one) boot sector looks for ntldr.exe on the active partitions filesystem. NTLDR is the actual boot loader and control is given to it if it's found. Else the boot process will fail.
- NTLDR looks for the boot.ini file on the active partition to read it's configuration. If more than one operating systems are configured in the file and the delay parameter is not 0, then the NT boot menu is displayed.
- When the user chooses a system, the delay time runs out or there is only one given system, NTLDR will start that system.
Installation of the NT Boot Loader
The NT Boot Loader gets installed by the Windows installation routines. However, there are cases when you manually want to install the NT Boot Loader to a partition. The easiest way to do so is as follows:
- Boot your Windows system.
- Use the Disk Management Administration Console or a partitioning tool to set the partition that the boot sector should be installed to as active (bootable).
- Right-click on 'My Computer', select properties and go to the Startup Settings in the Advanced tab. Make some sensible changes, lowering or raising the delay time would be enough. Confirm with OK. This should write the boot sector to the active partition.
Using the NT Boot Loader to boot Linux
ToDo...
Using LILO or GRUB to boot Windows
When you want to configure a linux boot manager to boot Windows, there are some aspects to care about.
- First of all, do not install LILO or GRUB to the Windows partitions boot sector. This would overwrite the Windows boot loader and Windows would not be bootable anymore. In fact it is always a good idea to install the linux bootloader to the MBR.
- Take care that at least at the time of booting, your Windows partition is the active one. As long as the LILO/GRUB is installed to the MBR, the Linux boot process doesn't depend on the active partition flag. So in most cases you can just set it on the Windows partition (using i.e.
# fdisk /dev/hda
) and leave it. However, there are cases requiring a more dynamic handling. GRUBs makeactive command can help you here.
LILO configuration
Given that /dev/hda2 would be your Windows partition, a typical /etc/lilo.conf section for booting it with LILO would be:
other=/dev/hda2 label=win
GRUB configuration
Given that /dev/hda2 would be your Windows partition, a typical /boot/grub/menu.lst section for booting it with GRUB would be:
title Windows rootnoverify (hd0,1) makeactive chainloader +1