2 YAIRD -- Yet Another MkInitRd
3 =============================
5 This is a proof of concept rewrite of mkinitrd, intended to test the
6 idea that we can get a more accurate picture of the modules needed
7 to boot a linux system by fully utilizing the information in sysfs.
8 It comes with templates that make it possible to generate different
9 initrd images for different distributions.
11 Proof of concept means this software is barely tested: it may
12 produce a working initrd image, or it may eat your disk. This
13 is a good moment to re-read the "NO WARRANTY" part of the licence,
14 and decide whether you want to test this software.
20 You'll need HTML::Template to run the application; a standard package
21 under Debian, in Fedora FC3 available via extras.
23 Unpack, then configure and install:
25 $ ./configure --prefix=$HOME/local --enable-template=Debian
28 The --enable-template option is required; it picks one of the templates
29 from the template directory to install.
31 If you want to regenerate the html documentation, you need the xmlto
34 If you're installing from version control rather than a tarball,
35 you'll also need to have autmake and autoconf available, and
36 need to run bootstrap.sh before doing 'configure; make'.
42 Yaird comes with a small C program to manage the transfer from the initial
43 root file system to the real root. To avoid the overhead of the GNU
44 C library, you may want to compile this with klibc. Note however that
45 this is only effective if every other program that is copied to the
46 initial root filesystem (such as mount, mknod and a shell) is compiled
49 Recent versions of klibc provide klcc, a wrapper around gcc that makes
50 it easier to port programs to klibc. Installation is faily simple;
51 the most important point is to make a symlink to a configured linux
52 source tree. The SHLIBDIR determines where the shared library version
53 ends up. If you want to use klibc for programs used early in the
54 boot process it makes sense to put it on the root file system.
57 $ ln -s /usr/src/linux... linux
58 $ make bindir=$HOME/local/bin \
59 mandir=$HOME/local/man \
60 INSTALLDIR=$HOME/local \
61 SHLIBDIR=$HOME/local/shlib \
65 Once you have klibc, you can configure yaird to make use of it
68 $ ./configure CFLAGS=-static CC=$HOME/local/bin/klcc \
69 --prefix=$HOME/local --enable-template=Debian
73 The use of CFLAGS=-shared is optional.
79 To make a new initrd image for the current kernel:
81 # yaird --format directory --output initrd.d
83 This creates a directory initrd.d to look at or to package
84 manually to a form suitable for booting.
86 To get an image suitable for use under debian:
88 # yaird --format cramfs --output /boot/initrd.img
90 For Fedora, a cpio file is needed:
92 # yaird --format cpio --output /boot/initrd.img
94 Note that there is no strong relation between distribution
95 and image format: nothing stops you from building a template
96 that uses initramfs and cpio under Debian. However, the template
97 and the image format do have to match.
99 To produce a boot image for another kernel:
101 # yaird --format directory --output initrd.d 2.6.10-1-686-smp
103 There is also a '--test' option that will produce an overview
104 of block special files, devices, modules etc that may be helpful
105 in debugging boot problems.
107 If you want the generated image to boot into something other than
108 the current root, use the --root option. The block device specified
109 must occur in /etc/fstab to allow yaird to find the required file system
112 # yaird --format cramfs --output /boot/tst.img --root /dev/hdb7
114 Use '--help' for an overview of other command line options.
117 Using yaird as a replacement for mkinitrd
118 =========================================
120 If you install a new kernel from your distribution, that means
121 making a new initial boot image. The postinstall script that
122 comes with the kernel will normally do this using mkinitrd;
123 if you want yaird to be used instead, some tweaking is necessary.
125 In Debian, there are a lot of configuration options for the kernel
126 installation, but replacing mkinitrd is not among them, so you'll
127 have to replace /usr/sbin/mkinitrd with a wrapper around yaird.
128 The following worked with debian 2.6.10-1-686:
132 # mkinitrd - emulate mkinitrd with yaird for kernel-image installs.
134 # Copyright (C) 2001-2003 Herbert Xu <herbert@debian.org>
136 # This program is free software; you can redistribute it and/or modify
137 # it under the terms of the GNU General Public License as published by
138 # the Free Software Foundation; either version 2 of the License, or
139 # (at your option) any later version.
141 # This program is distributed in the hope that it will be useful,
142 # but WITHOUT ANY WARRANTY; without even the implied warranty of
143 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144 # GNU General Public License for more details.
146 # You should have received a copy of the GNU General Public License
147 # along with this program; if not, write to the Free Software
148 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
155 while getopts "d:km:o:r:" flag; do
158 echo "$PROG: -d unsupported"
162 echo "$PROG: -k unsupported"
172 echo "$PROG: -d unsupported"
176 echo "$PROG: unknown option $flag"
181 shift $(($OPTIND - 1))
183 if [ "$outfile" = "" ]; then
184 echo "$PROG: no output file specified"
187 if [ $# -gt 1 ]; then
188 echo "$PROG: extra arguments found"
192 # Note that version may be a pathname;
193 # this is used by the installer for Debian kernel image packages.
195 [ $# -gt 0 ] || unset VERSION
197 /lib/modules/*/[!/]*)
200 VERSION=${VERSION#/lib/modules/}
201 VERSION=${VERSION%%/*}
207 echo $PROG: $VERSION is not a valid kernel version >&2
212 VERSION="${VERSION-$(uname -r)}"
214 exec $HOME/local/sbin/yaird \
215 --verbose --format cpio --output "$outfile" "$VERSION"
217 For Fedora, you'll have to modify /sbin/new-kernel-package;