The CD boot process is somewhat different. Again we need a boot loader, but we
don't necessarily know what device our CDROM is. It could be /dev/hdb,
/dev/hdc, /dev/hdd. Even if we told the boot loader where the kernel is, we
would still need to tell the kernel where its root filesystem is. ISOLINUX
helps us get around this, by working out where the CD is. This allows us to
boot the kernel, but it doesn't really help us to load the initial root
filesystem. Many boot disks use a thing called an initrd (Initial ram disk) to
get around this. initrd is an initial root filing system running in RAM. It
loads prior to when the kernel attempts to mount the 'real' root file
system. Yes this is odd. The idea is is that your initrd starts up, loads some
critical modules, then mounts your real root file system.
-
The CD is installed with ISOLINUX, so it boots first.
-
ISOLINUX loads the kernel from the /isolinux directory on the CD.
-
ISOLINUX now loads the initrd.gz compressed ext2 file system. Its
important to note that ISOLINUX loads this, and not the kernel. The
kernel will grab it later.
-
The kernel starts up and eventually decompresses the initrd.gz to ram
(in /dev/ram0 actually) and mounts it as root. You have to enable INITRD
and Ram disk support in the kernel to have this happen.
-
The kernel tries to execute the /linuxrc file in the new root filesystem
(because its an 'initrd').
-
The linuxrc program tries to mount the CDROM (It has to make a few
guesses to work out where it is), then copies a compressed 'real' root
filesystem from the CD into /dev/ram1. We mount the new filesystem just
so we can add a softlink in its /dev directory for the CD (so we don't
have to work out where the CD is again).
-
When the linuxrc script finishes, control returns to the kernel and it
attempts to mount its configured root filesystem. In this case, I've
rdev'd the kernel to make it use /dev/ram1 as the root filesystem. This
will mount our newly created ram based root file system. In this file
system I have an /sbin/init and the system starts up running entirely in
RAM.
So why does it have to be a two phase process? Linux doesn't really know how
to boot off a CD yet. The beauty of the initrd phase is that the initrd
filesystem is loaded by the bootloader (ie. not the kernel). It means that we
can effectively boot off any device, so long as the bootloader is able to read
from it.