Difference between revisions of "How to setup boot loaders"

From ThinkWiki
Jump to: navigation, search
(Installing LILO to a partitions boot sector)
m (LILO, GRUB and NT Boot Loader: repair table)
 
(23 intermediate revisions by 12 users not shown)
Line 7: Line 7:
 
|}
 
|}
 
==General information about boot processes==
 
==General information about boot processes==
From the moment you switch on your computer to the moment you can login into your installed operating system, a lot of things happen that can be devided into several major stages.
+
From the moment you turn on your computer to the moment you can login into your installed operating system, a lot of things happen that can be divided into several major stages.
  
 
===The BIOS stage===
 
===The BIOS stage===
When you switch on your computer, the first thing that's run is the BIOS, a program embedded into a chip within your computer that represents the lowest layer between all running software and the hardware. During startup the BIOS has several tasks to do, like i.e. analyzing and checking hardware as well as the current system state. The last of it's tasks is to find a bootable device and boot into that.
+
When you turn on your computer, the first thing to run is the BIOS, a program embedded into a chip within your computer that represents the lowest layer between all running software and the hardware. During startup the BIOS has several tasks to do, for example analyzing and checking hardware as well as the current system state. The last of its tasks is to find a bootable device and boot into that.
  
To do so, the BIOS program keeps a list of bootable drives as well as a boot order list which you can adjust via the BIOS settings menu - or on ThinkPads directly through hitting {{key|F12}} during bootup. In the order of that list it checks which of the drives it knows about actually contains bootable media. The first bootable media found will be booted. That means that the code at the very first sector of that media is loaded an run.
+
To do so, the BIOS program keeps a list of bootable drives as well as a boot order list which you can adjust via the BIOS settings menu - or on ThinkPads directly through hitting {{key|F12}} during bootup. It checks, in the order shown in that list, which of the drives it knows about actually contains bootable media. The first bootable media found will be booted. That means that the code at the very first sector of that media is loaded and run.
  
 
===The Boot Sectors===
 
===The Boot Sectors===
This first sector is called the boot sector. For different types of media different kinds of boot sectors are required, and since booting the harddrive is what we are concerned about here, we'll look into that specifically. Now, a harddrive is usually devided into partitions. Even if you only have one partition covering your whole drive, the internal structure is still the same. The first sector of your harddrive is the Master Boot Record (MBR), which includes the harddrives boot code as well as the hard drives partition table. The partition table contains information about the partition layout of your harddisk. The MBR typically is 512 KB in size, as is the size of every sector on an x86 machines harddisk. Now, every partitions first sector is called the boot sector of that partition, because it actually is reserved especially to serve that purpose. To summarize, a harddisk will always contain boot code in the MBR, and can contain further boot code in one or several boot sectors, belonging each to one partition.
+
This first sector is called the boot sector. For different types of media different kinds of boot sectors are required.  Since booting the harddrive is what we are concerned about here, we'll look into that specifically. Harddrives are usually divided into partitions. Even if you only have one partition covering your whole drive, the internal structure is still the same. The first sector of your harddrive is the Master Boot Record (MBR), which includes the harddrive's boot code as well as the hard drive's partition table. The partition table contains information about the partition layout of your harddisk. The MBR is typically 512 bytes in size, and so is the size of every sector on an x86 machine's harddisk.
 +
 
 +
A partition's first sector is usually called the boot sector of that partition, but one must be aware that depending on what is going to be stored in the partition, the first sector will be or will not be available for a boot loader.
 +
 
 +
{{WARN|Some filesystems will be corrupted if a boot loader (or anything else, really) overwrites their first sectors.  Installing a boot loader in the first sector of a partition is allowed for: ext2, ext3, FAT (all types), Linux LVM (metadata formats 1 and 2), Linux MD component partitions, Linux swap (format 1).  Installing a boot loader in the first sector of a partition is '''not allowed''' for: XFS.}}
 +
 
 +
To summarize, a harddisk will always contain boot code in the MBR, and can contain further boot code in one or several boot sectors, each belonging to one partition.
  
 
===The Boot Loader stage===
 
===The Boot Loader stage===
This stage starts with running the code inside the boot sector. As stated above, the first peace of code that's run on a harddisk is always the MBR. So, what happens next is already depending on what is written to the MBR and hence on which program wrote the boot code into the MBR. Typically, when you get your ThinkPad, the MBRs boot code will originate from Windows. In that case it picks the primary partition that is flagged with the bootable (or active) flag from the partition table and runs the boot sector of that partition, similar to how the BIOS launched the code in the MBR before. What happens next, depends on what code is in the partitions boot sector and at this point we should have a look to the most common boot loaders around.
+
This stage starts with running the code inside the boot sector. As stated above, the first piece of code to run on a harddisk is always the MBR. So what happens next depends upon what is written to the MBR. And what's written to the MBR depends upon which program wrote the boot code into the MBR. Typically, when you get your ThinkPad, the MBR's boot code will originate from Windows. In that case it picks the primary partition that is flagged with the bootable (or active) flag from the partition table and runs the boot sector of that partition, similar to how the BIOS launched the code in the MBR before. What happens next depends on what code is in the partition's boot sector and at this point we should have a look to the most common boot loaders around.
  
 
==LILO, GRUB and NT Boot Loader==
 
==LILO, GRUB and NT Boot Loader==
{| border="1" cellspacing="0" cellpadding="2"
+
{| {{prettytable}}
 
|+Comparison Table
 
|+Comparison Table
! !! LILO !! GRUB !! NT Boot Loader
+
|-
 +
| || LILO || GRUB || NT Boot Loader
 
|- style="vertical-align:top;"
 
|- style="vertical-align:top;"
| occupies || MBR '''or''' boot sector || MBR '''or''' boot sector || MBR '''and''' boot sector
+
| Occupies || MBR '''or''' boot sector || MBR '''or''' boot sector || MBR '''and''' boot sector
 
|-
 
|-
| boot selector ||
+
| Boot selector ||
 
*line input
 
*line input
 
*text menu
 
*text menu
Line 37: Line 44:
 
*text menu
 
*text menu
 
|- style="vertical-align:top;"
 
|- style="vertical-align:top;"
| OS support || GNU/Linux || FreeBSD, NetBSD, OpenBSD, GNU/Linux || can chainload other bootsectors
+
| OS support || GNU/Linux || FreeBSD, NetBSD, OpenBSD, GNU/Linux || Can chainload other bootsectors
 
|- style="vertical-align:top;"
 
|- style="vertical-align:top;"
| Windows Support || via chain-loading || via chain-loading || WinNT, Win2K, WinXP
+
| Windows Support || Via chain-loading || Via chain-loading || WinNT, Win2K, WinXP
 
|- style="vertical-align:top;"
 
|- style="vertical-align:top;"
| supported filesystems || block offset based || BSD FFS, FAT16, FAT32, Minix fs, ext2fs, ReiserFS, JFS, XFS, VSTa || FAT16, FAT32, NTFS
+
| Supported filesystems || Block-offset based || BSD FFS, FAT16, FAT32, Minix fs, ext2fs, ReiserFS, JFS, XFS, VSTa || FAT16, FAT32, NTFS
 
|- style="vertical-align:top;"
 
|- style="vertical-align:top;"
 
| Partition designation example<br />(second partion on first harddisk) || /dev/hda2 || (hd0,1) || multi(0)disk(0)rdisk(0)partition(2)
 
| Partition designation example<br />(second partion on first harddisk) || /dev/hda2 || (hd0,1) || multi(0)disk(0)rdisk(0)partition(2)
Line 47: Line 54:
  
 
==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.
+
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.
+
LILO's 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===
 
===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.
 
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}}.
+
*LILO is configured by editing {{path|/etc/lilo.conf}}.<br />The format is explained in {{cmduser|man lilo.conf}}.
 
:A simple example configuration could look like this:
 
:A simple example configuration could look like this:
 
  boot=/dev/hda
 
  boot=/dev/hda
Line 81: Line 81:
 
{{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.
 
{{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.
+
If you do not rerun <tt>lilo</tt> after such operations, you will render your system unbootable, which is one reason why you should create a LILO bootdisk.
 
}}
 
}}
 +
 +
===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 complicated 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.
 +
  
 
==GRUB==
 
==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 command line which can be the perfect tool for recovering boot problems.
+
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 command line 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 {{path|/usr/share}} to {{path|/usr/lib}}):
 
:{{cmdroot|1=dd if=/usr/share/grub/i386-pc/stage1 of=/dev/fd0 bs=512 count=1}}
 
:{{cmdroot|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 GRUB command line. Use {{cmdgrub|help}} there to get a list of available commands.
 
{{HINT|You can get partition and file listings at the GRUB command line through TAB completion.}}
 
  
 
===Installation of a GRUB boot loader===
 
===Installation of a GRUB boot loader===
Line 100: Line 99:
 
*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}}. The format of it is explained in GRUBs info page ({{cmd|info grub}}).
+
*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 ({{cmduser|info grub}}).
 +
*On some Thinkpads, the installation may fail, if there is no drive in the ultrabay.
 
*Once everything is setup in {{path|/boot/grub}}, launch the GRUB shell by running {{cmdroot|grub}}.
 
*Once everything is setup in {{path|/boot/grub}}, launch the GRUB shell by running {{cmdroot|grub}}.
*Within the GRUB shell select the partition on which your {{path|/boot/grub}} directory resides using the {{cmdgrub|root}} command, i.e. for the second partion on the first harddisk ({{path|/dev/hda2}}), enter
+
*Within the GRUB shell select the partition on which your {{path|/boot/grub}} directory resides using the {{cmd|root|}} command, i.e. for the second partion on the first harddisk ({{path|/dev/hda2}}), enter
 
:{{cmdgrub|root (hd0,1)}}
 
:{{cmdgrub|root (hd0,1)}}
 
{{NOTE|The numbering of disks and partitions starts from 0, not 1.}}
 
{{NOTE|The numbering of disks and partitions starts from 0, not 1.}}
Line 121: Line 121:
  
 
to install it into the 2nd partition (here the partitions are numbered from 1).
 
to install it into the 2nd partition (here the partitions are numbered from 1).
 +
 +
===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.
 +
====Creating a GRUB boot floppy====
 +
*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 {{path|/usr/share}} to {{path|/usr/lib}}):
 +
:{{cmdroot|1=dd if=/usr/share/grub/i386-pc/stage1 of=/dev/fd0 bs=512 count=1}}
 +
:{{cmdroot|1=dd if=/usr/share/grub/i386-pc/stage2 of=/dev/fd0 bs=512 seek=1}}
 +
====Creating a GRUB bootable CD-ROM====
 +
This allows to create a bootdisk for ThinkPads that do not come with a floppy drive. A GRUB bootable CD-ROM can be made to use the GRUB menu interface too.
 +
 +
See {{cmduser|info grub}} for detailed instructions (in node <tt>Making a GRUB bootable CD-ROM</tt>).
 +
 +
====Usage====
 +
The created disk will boot directly into the GRUB command line or the GRUB menu interface. Use {{cmd|help|}} at the GRUB command line to get a list of available commands.
 +
{{HINT|You can get partition and file listings at the GRUB command line through TAB completion.}}
  
 
==NT Boot Loader==
 
==NT Boot Loader==
Line 161: Line 177:
 
===Installing GRUB to a partitions boot sector===
 
===Installing GRUB to a partitions boot sector===
 
*Create or edit a minimal {{path|/boot/grub/menu.lst}} like this.
 
*Create or edit a minimal {{path|/boot/grub/menu.lst}} like this.
  boot=/dev/hda2
+
  # uncomment and edit accordingly if you have a boot partition that is different from your root partition
 +
# boot=/dev/hda2  
 
  default=0
 
  default=0
 
  title Linux
 
  title Linux
 
       root (hd0,1)
 
       root (hd0,1)
 
       kernel /boot/vmlinuz ro root=/dev/hda2
 
       kernel /boot/vmlinuz ro root=/dev/hda2
 +
      init  /boot/initrd
 +
* you may have to edit filenames vmlinuz and initrd if symlinks don't exist in your distribution.
 
*Launch the GRUB shell by running {{cmdroot|grub}}. Make sure that your stage files are properly setup (see above).
 
*Launch the GRUB shell by running {{cmdroot|grub}}. Make sure that your stage files are properly setup (see above).
 
*Within the GRUB shell 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 GRUB shell 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
Line 191: Line 210:
 
==Using LILO or GRUB to boot Windows==
 
==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.
 
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. It is often best to install the linux bootloader to the MBR (but this seems to break the [[Rescue and Recovery]] function available on some models).
+
*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. It is often best to install the Linux bootloader to the MBR.
 +
{{WARN|Installing a Linux bootlader to the MBR seems to break the [[Rescue and Recovery]] function available on some models}}
 
*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. {{cmdroot|fdisk /dev/hda}}) and leave it. However, there are cases requiring a more dynamic handling. GRUBs <tt>makeactive</tt> command can help you here.
 
*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. {{cmdroot|fdisk /dev/hda}}) and leave it. However, there are cases requiring a more dynamic handling. GRUBs <tt>makeactive</tt> command can help you here.
  
Line 207: Line 227:
 
  makeactive
 
  makeactive
 
  chainloader +1
 
  chainloader +1
 +
 +
==Using the Vista Boot Loader to boot Linux==
 +
The article from [http://port25.technet.com/archive/2006/10/13/Using-Vista_2700_s-Boot-Manager-to-Boot-Linux-and-Dual-Booting-with-BitLocker-Protection-with-TPM-Support.aspx] shows how to setup the Windows Vista boot loader to load GRUB and from there Linux.
  
 
==External Sources==
 
==External Sources==
Line 214: Line 237:
 
*[http://www.clug.org/cgi/wiki.cgi?InfamousLiThenStopProblem CLUGs Infamouse LI Then Stops Problem page]
 
*[http://www.clug.org/cgi/wiki.cgi?InfamousLiThenStopProblem CLUGs Infamouse LI Then Stops Problem page]
 
*[http://www.windowsitpro.com/Article/ArticleID/3952/3952.html?Ad=1 Windows IT article about the NT Boot Process]
 
*[http://www.windowsitpro.com/Article/ArticleID/3952/3952.html?Ad=1 Windows IT article about the NT Boot Process]
 +
*[http://ce.et.tudelft.nl/~zhijiangchang/resources/inst3.html How to use WINDOWS BOOT LOADER to make windows, linux and AcessIBM work all together]

Latest revision as of 20:26, 27 January 2008

This page (hopefully) will explain everything you should know about the major bootloaders so that you can configure them to your liking.

General information about boot processes

From the moment you turn on your computer to the moment you can login into your installed operating system, a lot of things happen that can be divided into several major stages.

The BIOS stage

When you turn on your computer, the first thing to run is the BIOS, a program embedded into a chip within your computer that represents the lowest layer between all running software and the hardware. During startup the BIOS has several tasks to do, for example analyzing and checking hardware as well as the current system state. The last of its tasks is to find a bootable device and boot into that.

To do so, the BIOS program keeps a list of bootable drives as well as a boot order list which you can adjust via the BIOS settings menu - or on ThinkPads directly through hitting F12 during bootup. It checks, in the order shown in that list, which of the drives it knows about actually contains bootable media. The first bootable media found will be booted. That means that the code at the very first sector of that media is loaded and run.

The Boot Sectors

This first sector is called the boot sector. For different types of media different kinds of boot sectors are required. Since booting the harddrive is what we are concerned about here, we'll look into that specifically. Harddrives are usually divided into partitions. Even if you only have one partition covering your whole drive, the internal structure is still the same. The first sector of your harddrive is the Master Boot Record (MBR), which includes the harddrive's boot code as well as the hard drive's partition table. The partition table contains information about the partition layout of your harddisk. The MBR is typically 512 bytes in size, and so is the size of every sector on an x86 machine's harddisk.

A partition's first sector is usually called the boot sector of that partition, but one must be aware that depending on what is going to be stored in the partition, the first sector will be or will not be available for a boot loader.

ATTENTION!
Some filesystems will be corrupted if a boot loader (or anything else, really) overwrites their first sectors. Installing a boot loader in the first sector of a partition is allowed for: ext2, ext3, FAT (all types), Linux LVM (metadata formats 1 and 2), Linux MD component partitions, Linux swap (format 1). Installing a boot loader in the first sector of a partition is not allowed for: XFS.

To summarize, a harddisk will always contain boot code in the MBR, and can contain further boot code in one or several boot sectors, each belonging to one partition.

The Boot Loader stage

This stage starts with running the code inside the boot sector. As stated above, the first piece of code to run on a harddisk is always the MBR. So what happens next depends upon what is written to the MBR. And what's written to the MBR depends upon which program wrote the boot code into the MBR. Typically, when you get your ThinkPad, the MBR's boot code will originate from Windows. In that case it picks the primary partition that is flagged with the bootable (or active) flag from the partition table and runs the boot sector of that partition, similar to how the BIOS launched the code in the MBR before. What happens next depends on what code is in the partition's boot sector and at this point we should have a look to the most common boot loaders around.

LILO, GRUB and NT Boot Loader

Comparison Table
LILO GRUB NT Boot Loader
Occupies MBR or boot sector MBR or boot sector MBR and boot sector
Boot selector
  • line input
  • text menu
  • graphical menu
  • line input
  • text menu
  • text menu
OS support GNU/Linux FreeBSD, NetBSD, OpenBSD, GNU/Linux Can chainload other bootsectors
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.

LILO's 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.

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 $ 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
lba32
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.
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 lilo 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 lilo after such operations, you will render your system unbootable, which is one reason why you should create a LILO bootdisk.

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 complicated 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.


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 command line which can be the perfect tool for recovering boot problems.

Installation of a GRUB boot loader

Manual

  • 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 ($ info grub).
  • On some Thinkpads, the installation may fail, if there is no drive in the ultrabay.
  • Once everything is setup in /boot/grub, launch the GRUB shell by running # grub.
  • Within the GRUB shell 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
grub> root (hd0,1)
NOTE!
The numbering of disks and partitions starts from 0, not 1.
  • After that is successfully done, install the bootloader to the MBR using
grub> setup (hd0)
  • Quit the GRUB shell
grub> quit
  • Reboot your machine to try if it works.

Automated

On most systems you can simply run

# grub-install /dev/hda

to install GRUB into the MBR, or

# grub-install /dev/hda2

to install it into the 2nd partition (here the partitions are numbered from 1).

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.

Creating a GRUB boot floppy

  • 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

Creating a GRUB bootable CD-ROM

This allows to create a bootdisk for ThinkPads that do not come with a floppy drive. A GRUB bootable CD-ROM can be made to use the GRUB menu interface too.

See $ info grub for detailed instructions (in node Making a GRUB bootable CD-ROM).

Usage

The created disk will boot directly into the GRUB command line or the GRUB menu interface. Use help at the GRUB command line to get a list of available commands.

Hint:
You can get partition and file listings at the GRUB command line through TAB completion.

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.
NOTE!
You can always boot older Windows NT like systems from the boot loader of newer ones, but trying the other way around will fail. Microsoft made changes to the boot loader and the NTFS file system throughout the releases of WinNT, Win2K and WinXP. An older NT Boot Loader will not know about these changes in a newer 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:

  1. Boot your Windows system.
  2. 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).
  3. 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

The NT boot loader is not able to boot anything else than NT type Windows systems. However, other systems boot sectors can be stored in a file on the same disk that the NTLDR files reside on and can be chainloaded from there.

Hence, the procedure to integrate Linux into your NT boot menu is outlines like this (we assume that the NT boot loader is properly installed already):

  • Install a Linux boot loader (LILO or GRUB) into the boot sector of your Linux partition.
  • Copy this boot sector into a file.
  • Copy that file to the root level of the Windows partition.
  • Add an entry to chainload that file to the NT boot menu.

Installing LILO to a partitions boot sector

  • Create a simple /etc/lilo.conf or edit your existing one like the following.
    The format is explained in $ man lilo.conf.
boot=/dev/hda2 ;It is important to specify your Linux boot partition here
map=/boot/map
install=/boot/boot.b
default=Linux
lba32
image=/boot/vmlinuz
       label=Linux
       root=/dev/hda2
       read-only
  • Run the # lilo command to write lilo to the boot sector of /dev/hda2.

Installing GRUB to a partitions boot sector

  • Create or edit a minimal /boot/grub/menu.lst like this.
# uncomment and edit accordingly if you have a boot partition that is different from your root partition
# boot=/dev/hda2    
default=0
title Linux
      root (hd0,1)
      kernel /boot/vmlinuz ro root=/dev/hda2
      init   /boot/initrd
  • you may have to edit filenames vmlinuz and initrd if symlinks don't exist in your distribution.
  • Launch the GRUB shell by running # grub. Make sure that your stage files are properly setup (see above).
  • Within the GRUB shell 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
grub> root (hd0,1)
  • After that is successfully done, install the GRUB bootloader to the boot sector of the second partition using
grub> setup (hd0,1)

Copying the boot sector

To make the boot sector accessable for NTLDR you must copy it to a file on a filesystem that is accessable by both Linux and Windows. This can be a floppy diskette, a USB drive, a CF card or simply a VFAT partition if you have one. There are also applications available for Windows which can read files from an ext2 partition. For whichever media you decide, it has to be mounted writable, we assume it's mounted under /media/floppy.

  • Copy the boot sector using the command
# dd if=/dev/hda2 of=/media/floppy/linbsect.bin bs=512 count=1
  • Reboot into Windows.
  • Copy the file linbsect.bin to the root level directory of your Windows partition, i.e. to C:\linbsect.bin.

Adjusting the NT boot menu

The final step is to add an entry for the Linux system to the boot.ini, which describes the NT boot menu. Your boot.ini might be hidden and set to read-only, so you might have to first adjust your folder options to show hidden and system files and remove the read-only flag within the properties dialog.

  • Open the file in an editor and add the following line at it's end:
C:\linbsect.bin="Linux"

This is it. On next reboot, you should be able to directly boot into your Linux system from the NT boot menu.

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. It is often best to install the Linux bootloader to the MBR.
ATTENTION!
Installing a Linux bootlader to the MBR seems to break the Rescue and Recovery function available on some models
  • 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

Using the Vista Boot Loader to boot Linux

The article from [1] shows how to setup the Windows Vista boot loader to load GRUB and from there Linux.

External Sources