5. LILO's Boot Partition below 1024

Because of the 1024 cylinder BIOS limitation, you should create a 10 MB partition to boot with.

10 MB is enough for a few kernels, an initrd image and the necessary boot files. Create one on EVERY disk! You only need it on one of the first two, but it's nice to be free to move disks around later.

Then you have to copy in the necessary files, and customise /etc/lilo.conf and /sbin/installkernel so that it just runs itself. Here's why and how ...

NOTE: there is a second section about lilo itself, this first section is about moving the files to the boot partition.

5.1 BIOS Limitations
5.2 /hda4 and /dev/hda4
5.3 /etc/lilo.conf
5.4 /boot -> /hda4/boot
5.5 /boot/kernel/vmlinuz
5.6 /sbin/installkernel


BIOS Limitations

When the kernel is running you can access "anything, anywhere", but before the kernel runs, LILO must use BIOS to load it. When LILO is booting, the BIOS can only access the first 1024 cylinders on the first two disks.

That means that your vmlinuz kernel has to be within that area. This may happen by chance, or you can make it happen.

The answer is to create the 10 MB boot partition. There are different tricks to avoid this limitation, such as doubling the number of sectors per track and halving the number of tracks (or not ...), or accessing the sectors linearly, but I'd recommend against that.

In addition, DOS uses BIOS until you install a special config.sys driver that reaches above, so it's easiest to allocate the rest of the space (504 MB - 10 MB) to DOS, then split what's left into 650 MB CDROM size chunks.


/hda4 and /dev/hda4

On my system, that 10 MB partition is the primary partition /dev/hda4 I put it at the very start of the disk, for flexibility later.

You can mount that partition as any directory. I use /hda4 because it makes sense to me. Don't get confused by them both having similar names: distinguish the difference between the directory and the device. Run the usual to create it, ie fdisk, mke2fs, vi /etc/fstab and mount.

You run fdisk(8) to create the partition. fdisk allows you to allocate the 1 2 3 4 numbers as you choose. Remember to set the partition tag to indicate that the partition is intended to be used as a Linux file partition. Read the menu's and think. Don't blindly copy this example at it erases part of the disk (no not that part ...)

fdisk /dev/hda
fdisk -l | less

Then run mke2fs(8) to make an ext2 filesystem on the partition. Also create the directory where it will be mounted.

mke2fs /dev/hda4
mkdir /hda4
vi /etc/fstab

Now edit /etc/fstab, using "vi /etc/fstab", your favourite editor, or the editor builtin to mc(1) the Midnight Commander. Create a line like the following:

/dev/hda4  /hda4  ext2  defaults  1  1

Now mount the partition and see that it is there. Because it is in /etc/fstab, it will be auto-mounted at boot time. It doesn't have to be! But when you create a new kernel, you will be writing it into the /hda4/boot/kernel/ directory, and running lilo. Then it must be mounted!

mount /hda4

That's created the partition, below 1024, ready for us to put files into it, and for us to point LILO to use those files.

What follows is really very simple, but I've written it out step by step just to worry you ;-) Refer to the finished lilo.conf file that explains it to the system first.



This is the top part of my lilo.conf, so that you can see what changes I made to it, to make the layout work, and how you can have the choice of several names (press CTRL during boot up).

# the main settings #

	boot = /dev/hda		
	delay = 50		
	vga = normal    	

# choice of kernel images       #
# choice of machine identities  #
# ie root parition = raven      #

	image = /boot/kernel/vmlinuz
	root  = /dev/hda1
	label = raven

	image = /boot/kernel/vmlinuz-2.1.42
	root  = /dev/hda2
	label = raven-2.1.42

	image = /boot/kernel/vmlinuz-2.0.29
	root  = /dev/hdc7
	label = raven-2.0.29

	image = /boot/kernel/vmlinuz.old
	root  = /dev/hdc7
	label = raven.old
# ...
# see the LILO section for more details
# my file has more options

From that you can see that only three files are named: kernel/vmlinuz, sector/map and sector/boot.b and of course the root partition that can be on any disk. Coincidentally, these are the only 3 files that must be below 1024 (except messages and of course the sector or MBR that it installs into), so you could simplify it even further (I use boot.b, you might use one of the other files).

So you don't even need the /boot symb-link! But the backup copies of the MBR have to go somewhere!


/boot -> /hda4/boot

LILO traditionally uses /boot for its file as well as /etc/lilo.conf It doesn't have to.

We are going to comply with LILO, but also take advantage of this opportunity to make a more logical layout. All the boot-sector files get a directory of their own, all the kernels get their own directory, and a few stray files appear loose. Create these directories:

mkdir /hda4/boot/
mkdir /hda4/boot/initrd/
mkdir /hda4/boot/kernel/
mkdir /hda4/boot/sector/


When we've finished, you will hardly use the "hda4" name, just as you never say "cua2" but always "modem", again this is done with a symb-link, the only thing to watch out for, is that you will be dismantling a directory called /boot and assembling a symblink also called /boot. It's easier to do than to explain!

cd /
mv boot boot.old
ln -s /hda4/boot /boot


Now copy over the necessary LILO boot sector files. Note that some people will actually be copying from /boot.old/ on the third disk, installing onto the first disk, so they'd have to do something, and this is a good layout.

cp -p /boot.old/* /boot/sector/


You don't have to, but I like to keep /etc/lilo.conf near the actual boot files, "all in one place". This will make more sense when you have three independently bootable systems, but want them all to share the same lilo.conf. Again you create a symb-link and a backup copy.

cd /etc
cp -p lilo.conf /boot/
mv lilo.conf lilo.conf.old
ln -s /boot/lilo.conf .


You now need to copy over your kernel(s) into the /hda4 partition. This will vary as you will have different version number from me, depending on you lilo.conf file.

cp -p /vmlinuz /boot/kernel/vmlinuz

For general file management, I really recommend mc It makes life so much easier, it preserves the times and permissions of files, and ESC-ENTER makes it easy to put the highlighted filename into the command line. CTRL-X CTRL-P and CTRL-X P for the dirs.

You can copy/move files between two panels easily, and the few hassles / bugs that it has, are quickly learned.


The real pathnames are actually like /hda4/boot/sector/map, so that the root directory of /hda4 contains very little (it's tidier and has space for other experimental layouts). So now you should have a tree of file like:

/hda4/boot/		# tidy spartan top 

/boot/			# symb-link
/boot/sector/		# boot.b here
/boot/kernel/		# vmlinuz here
/boot/initrd/		# later

/boot/lilo.conf		# the central config file 

/boot/boot.0200		# LILO creates this 
/boot/boot.0300		# backup of the MBR

/boot/sector/any_b.b	# copied from /boot.old
/boot/sector/map	# created by lilo



/boot/kernel/vmlinuz-rd	# goes with initrd.img It has lo rd ...

To see exactly which files you needed, run lilo with lots of -v options (or strace it).



When you build a kernel using make install and the customised /sbin/installkernel you will overwrite the following 2 files:

That means that you have to do very little work, just make sure that lilo.conf contains an entry for a kernel other than the newly built one, that you may wish to revert to, eg vmlinuz-2.0.29

If you later compile 2.1.50, the 2.1.42 file will still be around. If you updated lilo.conf then you can boot it!

If the disk gets full, you cannot boot with the default, you must name one.

make zlilo

To build kernels direct into /boot/kernel/vmlinuz, but not either of the other two, use the command:

make INSTALL_PATH=/boot/kernel/. zlilo



If you want make install to do something special, such as install itself into /boot/kernel/, create a script called /sbin/installkernel, and it will get called by /usr/src/linux/arch/i386/boot/Makefile with the following parameters:

# Arguments:
#   $1 - 2.0.7	 			- kernel version
#   $2 - /usr/src/linux/arch/i386/boot/zImage - kernel image file
#   $3 - /usr/src/linux/System.map 	- kernel map file
#   $4 - /hda4/kernels			- kernel install path (blank)

The script is very simple, here it is:

# /sbin/installkernel


  [ -f $DIR1/vmlinuz    ] && mv $DIR1/vmlinuz    $DIR1/vmlinuz.old
  [ -f $DIR1/System.map ] && mv $DIR1/System.map $DIR1/System.old

  cat $2 > $DIR1/vmlinuz	|| exit $?
  cat $2 > $DIR1/vmlinuz-$1	|| exit $?
  cp  $3   $DIR1/System.map
  cp  $3   $DIR1/System.map-$1


The exit commands will be run if the disk becomes full half way through creating one of the files (or another error). In that case, the file will probably be corrupted, and not bootable. lilo will not have been run, but the previous run would attempt to use the old file's block, which are probably be partially overwritten.

If that happens procede carefully< do not delete an old kernel that you might then want to boot from! That might make lilo fail, requiring an edit, increasing the time that you are "at risk". Delete the System.map files because you don't really need them.