]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/cdrom/yaird-0.0.5/README
33512cbd7b9cf361eb764b92ad18e129607cda17
[bacula/rescue] / rescue / linux / cdrom / yaird-0.0.5 / README
1
2 YAIRD -- Yet Another MkInitRd
3 =============================
4
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.
10
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.
15
16
17 Installation
18 ============
19
20 You'll need HTML::Template to run the application; a standard package
21 under Debian, in Fedora FC3 available via extras.
22
23 Unpack, then configure and install:
24
25         $ ./configure --prefix=$HOME/local --enable-template=Debian
26         $ make install
27
28 The --enable-template option is required; it picks one of the templates
29 from the template directory to install.
30
31 If you want to regenerate the html documentation, you need the xmlto
32 package.
33
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'.
37
38
39 Installing with klibc
40 =====================
41
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
47 in the same manner.
48
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.
55
56         $ cd klibc-0.207
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 \
62                 install
63         $
64
65 Once you have klibc, you can configure yaird to make use of it
66 as follows:
67
68         $ ./configure CFLAGS=-static CC=$HOME/local/bin/klcc \
69                 --prefix=$HOME/local --enable-template=Debian
70         ...
71         $ make install
72
73 The use of CFLAGS=-shared is optional.
74
75
76 Using the application
77 =====================
78
79 To make a new initrd image for the current kernel:
80
81         # yaird --format directory --output initrd.d
82
83 This creates a directory initrd.d to look at or to package
84 manually to a form suitable for booting.
85
86 To get an image suitable for use under debian:
87
88         # yaird --format cramfs --output /boot/initrd.img
89
90 For Fedora, a cpio file is needed:
91
92         # yaird --format cpio --output /boot/initrd.img
93
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.
98
99 To produce a boot image for another kernel:
100
101         # yaird --format directory --output initrd.d 2.6.10-1-686-smp
102
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.
106
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
110 type.
111
112         # yaird --format cramfs --output /boot/tst.img --root /dev/hdb7
113
114 Use '--help' for an overview of other command line options.
115
116
117 Using yaird as a replacement for mkinitrd
118 =========================================
119
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.
124
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:
129
130         #!/bin/sh
131         #
132         # mkinitrd - emulate mkinitrd with yaird for kernel-image installs.
133         #
134         # Copyright (C) 2001-2003 Herbert Xu <herbert@debian.org>
135         #
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.
140         #
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.
145         #
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
149         #
150         # $Id$
151
152         PROG=mkinitrd-shimmy
153         outfile=''
154
155         while getopts "d:km:o:r:" flag; do
156                 case $flag in
157                 d)
158                         echo "$PROG: -d unsupported"
159                         exit 1
160                         ;;
161                 k)
162                         echo "$PROG: -k unsupported"
163                         exit 1
164                         ;;
165                 m)
166                         # ignore 
167                         ;;
168                 o)
169                         outfile="$OPTARG"
170                         ;;
171                 r)
172                         echo "$PROG: -d unsupported"
173                         exit 1
174                         ;;
175                 *)
176                         echo "$PROG: unknown option $flag"
177                         exit 1
178                         ;;
179                 esac
180         done
181         shift $(($OPTIND - 1))
182
183         if [ "$outfile" = "" ]; then
184                 echo "$PROG: no output file specified"
185                 exit 1
186         fi
187         if [ $# -gt 1 ]; then
188                 echo "$PROG: extra arguments found"
189                 exit 1
190         fi
191
192         # Note that version may be a pathname;
193         # this is used by the installer for Debian kernel image packages.
194         VERSION=$1
195         [ $# -gt 0 ] || unset VERSION
196         case $VERSION in
197         /lib/modules/*/[!/]*)
198                 ;;
199         /lib/modules/[!/]*)
200                 VERSION=${VERSION#/lib/modules/}
201                 VERSION=${VERSION%%/*}
202                 ;;
203         esac
204
205         case $VERSION in
206         */*)
207                 echo $PROG: $VERSION is not a valid kernel version >&2
208                 exit 1
209                 ;;
210         esac
211
212         VERSION="${VERSION-$(uname -r)}"
213
214         exec $HOME/local/sbin/yaird \
215                 --verbose --format cpio --output "$outfile" "$VERSION"
216
217 For Fedora, you'll have to modify /sbin/new-kernel-package;
218 not tested yet.