Lilo comes with a neat script called QuickInst
. Unpack the lilo
source into the target source directory, run this script with the command
ROOT=/mnt/target ./QuickInst
. It will ask you questions about
how you want lilo installed.
Remember, since we have set ROOT
,
to the target partition, you tell it file names relative to that. So
when it asks what kernel you want to boot by default, answer
/boot/bzImage
not /mnt/target/boot/bzImage
.
I found a little bug in the script, so it said
./QuickInst: /boot/bzImage: no such file
But if you just ignore it, it's ok.
Where should we get QuickInst
to put the boot sector?
When we reboot we want to have the choice of booting into the source system
or the target system, or any other systems that are on this box.
And we want the instance of lilo that we are building now to load
the kernel of our new system. How are we going achieve both of these
things? Let's digress a little and look at how lilo boots DOS on a
dual boot Linux system. The lilo.conf
file on such a system
probably looks something like this:
prompt timeout = 50 default = linux image = /boot/bzImage label = linux root = /dev/hda1 read-only other = /dev/hda2 label = dos
If the machine is set up this way, then the master boot record gets read and
loaded by the bios, and it loads the lilo bootloader, which gives a prompt.
If you type in dos
at the prompt, lilo loads the boot sector from
hda2, and it loads DOS.
What we are going to do is just the same, except that the boot sector in
hda2 is going to be another lilo boot sector - the one that QuickInst
is going to install. So the lilo from the Linux distribution will load the
lilo that we have built, and that will load the kernel that we have built.
You will see two lilo prompts when you reboot.
To cut a long story short, when QuickInst
asks you where to put the
boot sector, tell it the device where your target filesystem is,
eg. /dev/hda2
.
Now modify the lilo.conf
on your source system, so it has
a line like
other = /dev/hda2 label = target
run lilo, and we should be able to do our first boot into the target system.