2 <title>Goals, features, to do</title>
4 The purpose in life of a tool like <application>Yaird</application>
5 is to produce an initial boot image that loads the required modules
6 to allow a booting kernel to access the root file system and from
7 there use the startup scripts to get to the default run level.
8 This means that hardly any drivers need to be compiled into the kernel
9 itself, so a distribution can produce a kernel with a large amount of
10 modules that will run unchanged on practically any hardware, without
11 introducing a large number of unused drivers that would waste RAM.
12 In a sense, the initial boot image customises the kernel to the hardware
13 it happens to be running on.
17 That purpose still leaves a lot of room to optimise for different
18 goals: as an example, you could attempt to make the generated
19 image as small as possible, or you could attempt to make the
20 generated image so flexible that it will boot on any hardware.
21 This chapter discusses the goals that determined the design, the
22 resulting features, and what's still left to do.
28 Well, not really. I started this thingy to show off a small
29 algorithm to find required modules based on sysfs information.
30 To make that a credible demonstration, the small algorithm
31 turned out to need a lot of scaffolding to turn it into a
35 of <application>Yaird</application> are as follows:
46 Be maintainable. Small functions with documented arguments
47 and result are better than a shell script full of constructs
48 like <code>eval "awk | bash | tac 3>&7"</code>.
54 Be secure and reliable. The application should stop with an error
55 message at the slightest provocation, rather than run the
56 risk of producing a non-booting initrd image.
57 The application should not open loopholes that allow the 'bad
58 guys' to modify the image, gain access to raw devices or
59 overwrite system files.
65 Be distribution agnostic. Fedora and Debian run similar
66 kernels and similar startup scripts, so there's little
67 reason why the glue between the two levels should be
74 Have limited footprint. The tools needed to build and run
75 the application should be few and widely available, with a
76 preference for tools that are installed anyway.
82 Be future proof. Future kernels may use different modules
83 and may change device numbers; the application should need
84 no changes to cope with such migrations.
90 Promote code reuse. Make functions side-effect free and
91 independent of context, so that it's easy to package the
92 core as a library that can be reused in other applications.
98 Generate small images. The application should accurately
99 detect what modules are needed to get the root file system
100 running and include only those modules on the generated
103 An alternative and equally interesting exercise would be
104 an attempt to generate a universal initrd that could be
105 distributed together with the kernel. Such an image
106 would most likely be based on udev/hotplug.
121 Linux 2.6.8 or later, both when running
122 <application>yaird</application> and when running the generated
123 image. By limiting the goal to support only recent kernels,
124 we can drastically reduce the number of special cases and
125 knowledge about modules in the application.
131 Sysfs and procfs, both on the old and on the
138 Perl and the HTML-Template module.
146 To achieve these goals, the following features are implemented:
151 Templating system to tune the generated image to a
152 given distribution; templates for Debian and Fedora FC3
159 Interprets <filename>/etc/fstab</filename>, including
160 details such as octal escapes, <code>ignore</code> and
161 <code>noauto</code> keywords, and — for ext3 and reiser
162 file systems — label and uuid detection.
163 Where applicable, options in <filename>/etc/fstab</filename>
164 are used in the generated image.
170 Supports volume management via LVM2; activates only the volume
171 group required for the root file system.
177 Supports software RAID via mdadm; activates only required
184 Understands SATA, IDE devices.
190 Generated image does not use hard coded device
193 Except where the distribution depends on it;
194 there are some issues with mdadm in Debian.
202 Image generation understands how included executables may
203 depend on symbolic links and shared libraries. Shared libraries
204 work for both glibc and klibc.
210 Support input devices such as USB keyboard, if the input
211 device supports sysfs.
212 Input devices are needed in the initial image to supply
213 a password for encrypted root disk and to do debugging.
219 Basic support for kernel command line as passed by the boot
220 loader. Interprets init=, ro, rw.
226 Interprets the blacklist information from hotplug.
232 Interprets the kernel configuration file that defines whether a
233 component is built in, available as a module or unavailable.
234 By maintaining a mapping between module name and config
235 parameter for selected modules, we avoid error messages if
236 for instance a required file system is built into the kernel.
242 Supports initramfs, both in Debian and Fedora versions.
243 An example template using the older initrd model
244 is included for Debian.
250 Does not require devfs in either the old or the new kernel.
258 Obviously, this tool is far from complete. Here's a list of
259 features that still need to be implemented:
264 Understands USB and SCSI storage, no special provisions
265 are needed for code generation, but it's not tested yet.
271 EVMS, an alternative user level interface to LVM2 and MD,
272 is not supported yet.
278 Swsusp is not supported yet.
284 Module aliases and options as specified in
285 <filename>/etc/modprobe.d</filename> are not supported yet.
291 Firewire and DASD are not supported.
297 NFS, loopback and encrypted file systems are not supported.
303 Configuration info is hard coded in a module; it should be
304 possible to read this from a file.