next up previous contents
Next: Using the Boot Disks Up: Getting Linux into Small Previous: Building a Kernel   Contents

Subsections

Making a Bootable Diskette

We will describe three methods to boot Linux from a diskette.

Instead of LILO we could use another boot loader, such as SYSLINUX or GRUB. This is considered to be outside the scope of this text.

For the boot diskettes we have to format 1.44MB floppy disks or take formatted disks that may be erased. In Linux there are two programs to format a diskette. One program is fdformat. A diskette is formatted as follows:

fdformat /dev/fd0H1440
Some distributions have superformat instead. This is used as follows:
superformat --hd /dev/fd0
We assume 3.5'' HD diskettes and we only format them in the standard way (1440kB), so we do not try to get a few more sectors per track or a few more tracks.

All commands in this section should be done as root.

Booting Linux directly from a diskette

We do not have to use a complicated boot loader such a LILO in order to boot a Linux system. The Linux kernel has its own primitive boot loader. When the kernel is transferred directly to a diskette with the dd command, the kernel can boot itself. This way we cannot supply a command line and it works only with diskettes. We also cannot use the initrd feature, but there is a different way of loading a RAM disk, which we will not discuss (it is discussed in the Bootdisk HOWTO).

First we have to create a file system on the root diskette and transfer the files to it. Type the following commands:

mke2fs /dev/fd0
mkdir /home/lennartb/myboot/mnt
mount /dev/fd0 /home/lennartb/myboot/mnt
cp -a /home/lennartb/myboot/rootfs/* \
   /home/lennartb/myboot/mnt
umouunt /dev/fd0
The root file system will be mounted read-only. If this is not desired, add the following line to the file etc/init.d/rcS while the floppy is mounted:
mount -o remount /dev/fd0 /

Next we create the boot disk. With a different diskette in the drive type the following command:

dd if=/home/lennartb/myboot/linux/arch/boot/zImage \
   of=/dev/fd0
rdev /dev/fd0 /dev/fd0
The rdev command selects the device on which the root file system should be mounted by the kernel after booting. We could use the following command to make the diskette mount the root file system on the first hard disk partition.
rdev /dev/fd0 /dev/hda1

LILO bootable disk

First make the root diskette as described in the previous section. There are two ways to proceed:

The LILO diskette is either the root diskette to which we will add LILO or the separate diskette on which we will install LILO.

Mount the LILO diskette and add the kernel and boot loader to it:

mount /dev/fd0 /home/lennartb/myboot/mnt/
mkdir /home/lennartb/myboot/mnt/boot
cp /home/lennartb/myboot/linux/arch/i386/boot/zImage \
   /home/lennartb/myboot/mnt/boot
cp /boot/lilo/boot.b /home/lennartb/myboot/mnt/boot

Create the file /home/lennartb/myboot/lilo.conf as follows:

boot=/dev/fd0
install=/home/lennartb/myboot/mnt/boot/boot.b
map=/home/lennartb/myboot/mnt/boot/map
delay=100
compact
image=/home/lennartb/myboot/mnt/boot/zImage
  label=linux
  root=/dev/fd0
All relevant files mentioned in lilo.conf are on the mounted diskette. The delay option will wait 10 seconds, so we have the opportunity to type a command line in LILO. The compact option makes loading much faster. Try it without and compare.

Run LILO. This will add a map file to the /boot directory on the diskette and it will add a boot sector to the diskette. The boot sector will load the loader in boot.b, this will load the map file and the map file contains a list of sectors of the kernel, so this can be loaded.

lilo -C /home/lennartb/myboot/lilo.conf

Finally unmount the LILO diskette.

unount /dev/fd0

RAM disk

A RAM disk has the following advantages.

The RAM disk has the following disadvantages:

First we have to create an image file for the RAM disk. We limit its size to 1000K, so it still runs on a 4MB machine. Create a file system on the image file. The -N 200 option is necessary to create enough inodes on the file system, as there are a lot of symbolic links.

dd if=/dev/zero of=/home/lennartb/myboot/root.img \
   bs=1k count=1000
mke2fs -F -N 200 /home/lennartb/myboot/root.img

Next mount the image file using a loop device and copy all files of the root file system to it. The loop option to mount makes it possible to mount a regular file as if it were a block device.

mount -o loop /home/lennartb/myboot/root.img \
   /home/lennartb/myboot/mnt
cp -a /home/lennartb/myboot/rootfs/* \
   /home/lennartb/myboot/mnt
umount /home/lennartb/myboot/mnt

Compress the root file system image. This image file will be copied to a diskette.

gzip -9 /home/lennartb/myboot/root.img

Create a new LILO diskette, mount it and add the kernel, root file system image and boot loader to it:

mke2fs /dev/fd0
mount /dev/fd0 /home/lennartb/myboot/mnt/
mkdir /home/lennartb/myboot/mnt/boot
cp /home/lennartb/myboot/linux/arch/i386/boot/zImage \
   /home/lennartb/myboot/mnt/boot
cp /home/lennartb/myboot/root.img.gz \
   /home/lennartb/myboot/mnt/boot
cp /boot/lilo/boot.b /home/lennartb/myboot/mnt/boot

Create the file /home/lennartb/myboot/lilo-initrd.conf as follows:

boot=/dev/fd0
install=/home/lennartb/myboot/mnt/boot/boot.b
map=/home/lennartb/myboot/mnt/boot/map
delay=100
compact
image=/home/lennartb/myboot/mnt/boot/zImage
  label=linux
  root=/dev/ram
  initrd=/home/lennartb/myboot/mnt/boot/root.img.gz
image=/home/lennartb/myboot/mnt/boot/zImage
  label=noram
  root=/dev/fd0
The configuration file is almost the same, except for the initrd option. This causes the boot loader to load a RAM disk image into memory. The Linux kernel will decompress it to a RAM disk device and mount this as the root file system 3. Further we added a noram option, so it is also possible to use this LILO diskette without a RAM disk.

Run LILO:

lilo -C /home/lennartb/myboot/lilo-initrd.conf

Finally unmount the LILO diskette:

unount /dev/fd0


next up previous contents
Next: Using the Boot Disks Up: Getting Linux into Small Previous: Building a Kernel   Contents
Lennart Benschop 2003-05-29