Recipe 10.10. Creating an initrd Image
10.10.1 Problem
You are using SCSI drives, and
you like to load the drivers as modules, because there are so many
different SCSI drivers. You want the flexibility to change drives or
controllers without rebuilding the kernel every time, and you
don't want to fatten your kernel by compiling in
every possible driver. But how will the system boot without the SCSI
driver built into the base kernel?
10.10.2 Solution
Build an initrd (initialize RAM disk) image with
mkinitrd (make initial RAM disk) after you build
the kernel. Then add an entry to your bootloader that loads the
image.
On both 2.4 and 2.6 kernels, after running make
modules_install, run mkinitrd:
# mkinitrd -o /boot/initrd-2.4.25-new-kernel.img
This builds the image and installs it into the
/boot directory. Then create your bootloader
entries. In GRUB:
title Kernel 2.4.25, new kernel
root (hd0,0)
kernel /boot/bzImage-2.4.25-new-kernel root=/dev/hda1 ro
initrd /boot/initrd-2.4.25-new-kernel.img
LILO users do this:
image=/boot/bzImage-2.4.22-new-kernel
initrd=/boot/initrd-2.4.25-new-kernel.img
label=Kernel 2.4.22, new kernel
root=/dev/hda1
read-only
Remember to run /sbin/lilo to activate the
changes.
10.10.3 Discussion
Be sure to read the mkinitrd man page for your
system, as the options differ slightly between the different
distributions.
It's perfectly okay to build your SCSI driver into
the base kernel; using initrd
isn't required.
Most of the major Linux distributions use
initrd, so that their stock kernels will boot on
most systems without needing every driver in the world to be built
in.
10.10.4 See Also
|