1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
<chapt id="initramfs">
<heading>Managing the initial ramfs (initramfs) archive</heading>
<p>
The booting in Debian is a two-stage process, involving
the initial RAM filesystem (initramfs for short, sometimes it
is also referred to as initrd, which stands for initial RAM
disk). First, the bootloader loads the kernel and initramfs
into memory, and passes the execution control to the
kernel. After basic initialization the kernel extracts the
initramfs archive and mounts it as a temporary root
filesystem. initramfs contains kernel modules and userspace
programs required to initialize the physical or logical
device(s) containing the real root filesystem. The
<tt>init</tt> script on the initramfs loads modules and
performs other neccessary initialization steps. At the end of
this stage <tt>run-init</tt> deletes the initramfs from
memory, mounts the real root filesystem and passes control to
the <tt>/sbin/init</tt> program on it.
</p>
<p>
Two major goals are achieved with such setup: the kernel size
is kept under control by allowing most of the drivers to be
compiled as modules (in a initramfs-less setup the drivers
neccessary for the boot-time initialization of the root device
must be compiled into it) and allow the setups which require
initialization which cannot be done in-kernel, but is performed
by userspace utilities.
</p>
<sect id="initramfs-gen-tools">
<heading>Initramfs generation tools</heading>
<p>
Since initramfs usually needs to be customized for the particular
hardware/device configuration and kernel version, they are not
included as a part of any package, but are generated on the
fly at kernel installation time. Currently there are two tools
in Debian capable of generating an initramfs:
<tt>update-initramfs</tt> provided by <tt>initramfs-tools</tt>
(default) and <tt>dracut-update-initramfs</tt> provided by the
<tt>dracut</tt> package (experimental).
</p>
</sect>
<sect id="initramfs-regen">
<heading>Regenerating the initramfs</heading>
<p>
If changes are desired after the corresponding
<tt>linux-image</tt> has been installed, the initramfs needs to
be regenerated. This is achieved by the command
<example>
# dpkg-reconfigure linux-image-3.2.0-2-686-pae
</example>
where <tt>linux-image-3.2.0-2-686-pae</tt> is the name of the
kernel package for which the initramfs regeneration is requested.
</sect>
<sect id="initramfs-exam">
<heading>Examining the initramfs contents</heading>
<p>
Occasionally it is useful to examine the contents of initramfs
to diagnose a problem or for educational purposes. They are
compressed <tt>cpio</tt> archives, which may be extracted
using the command
<example>
$ zcat /boot/initrd.img-3.2.0-2-686-pae | cpio -i
</example>
It will unpack the contents of the initramfs into the current directory.
</p>
<p>
It is also possible to list the contents of an initramfs
using the <tt>cpio -t</tt> option or the command
<example>
$ lsinitramfs /boot/initrd.img-3.2.0-2-686-pae
</example>
</p>
</sect>
</chapt>
|