Monday, May 18, 2009

Installing Your Kernel

Once you have rebuilt your kernel, you must install it to be able to boot it. Because it is the simplest to use and available on all current distributions, I am only going to talk about the Linux Loaded (LILO) as a method to install your kernel.

LILO is actually a general-purpose boot manager that can boot almost every OS that you installed on your system. LILO normally is run from the hard disk, but you can configure it to run from a floppy as well. LILO can act as a primary boot loader (that is, it is started from the master boot block) or a secondary loader (started by the primary loader).

There are some problems when you run OS/2 or NT because they have their own boot managers. Therefore you will probably have to use their manager as the primary boot loader and have LILO on the Linux partition to boot Linux.

LILOs configuration is in /etc/lilo.conf, which is a text file that can be edited with any text editor (vi, emacs, etc.). On many systems, there is a configuration program liloconfig, which will prompt you for some basic configuration parameters that are then written to /etc/lilo.conf.

To get a better idea of what this is all about, lets look at the lilo.conf file from one of my systems with a Linux and DOS file system. (Most of this was the default.)

# Modified by YaST2. Last modification on Fri Nov  9 16:27:26 2001

boot = /dev/hda
vga = 791
menu-scheme = Wg:kw:Wg:Wg
timeout = 80
message = /boot/message

image = /vmlinuz
label = linux_vm
root = /dev/hda4
initrd = /boot/initrd
append = "enableapic vga=0x0317"

image = /boot/vmlinuz
label = linux2
root = /dev/hda4
initrd = /boot/initrd
append = "enableapic vga=0x0317"

image = /vmlinuz
label = linux3
root = /dev/hdb7
initrd = /boot/initrd
append = "enableapic vga=0x0317"

image = /boot/vmlinuz.suse
label = failsafe
root = /dev/hda4
initrd = /boot/initrd.suse
append = "disableapic ide=nodma apm=off"

image = /boot/memtest.bin
label = memtest86

other = /dev/hda1
label = windows

The first part of the file are the basic configuration parameters. The boot line defines the device that LILO should install itself onto, in this case, device /dev/hda, which is the master boot block. If you wanted to install lilo on a different partition, maybe to use a commercial boot manager, you might specific /dev/hda2, which is the second partition of the first drive. Note that this is what it is on an IDE drive; on an SCSI drive, the device would be /dev/sda2.

The delay line specifies the number of tenths of seconds LILO should wait before booting the first image. Here we have 80, so this means 8 seconds. The VGA line specifies the text mode the system should use when booting. Normal means to select 80x25 text mode. The ramdisk line specifies the size of the RAM disk to create; in this case, it won't be created because the size is 0.

Next is the section that defines a particular OS to boot. The image line specifies the image to load. In the first case, this is the file vmlinuz in the root file system. Next we define the root file system; here it is the device /dev/hda4, which is the fourth partition on the first disk.

The label is the name you use to specify which OS you want to boot. In the first example, it is called linux_vm (which tells me that this kernel is configured to run VMWare. Also, when the LILO prompt comes, press TAB to display this label, in this case, Linux. The next line says the root file system should be mounted read-only. This seems to contradict logic and experience because the root file system ought to be writable. Actually, this is only used for checking when the system first boots; later, other routines will remount the file system as read-write.

In the last section is the description for the DOS/Windows partition, which is on the first partition on the first drive, /dev/hda1.

When the lilo.conf file is set up as you want, you need to run /sbin/lilo to install it. If you are using Windows NT, which likes to take control and prescribe everything, you will need to configure LILO as a "secondary" boot loader. You can also do this if you don't want LILO to be your boot manager.

If LILO is installed as your master boot record, you can "remove" it by overwriting the MBR. From DOS, you can remove it with

fdisk /mbr

The original boot block is stored in the /boot directory as either boot.3?? for IDE drives or boot.8?? for SCSI devices, where ?? is the device where the master boot block was. You can then use the dd command to copy it back to the hard disk. The syntax of dd follows:

For example:

Although the size of the file in /boot is 512 bytes, only the first 446 contain information. You need to be very careful here. If you make a mistake, for example, count=10, you can overwrite important information on the first partition.

No comments:

Post a Comment