Prepare for 2.5.
[febootstrap.git] / febootstrap-to-supermin.pod
1 =head1 NAME
2
3 febootstrap-to-supermin - Convert febootstrap root to supermin appliance.
4
5 =head1 SYNOPSIS
6
7  febootstrap-to-supermin DIR supermin.img hostfiles.txt
8
9 =head1 DESCRIPTION
10
11 I<febootstrap-to-supermin> converts the filesystem created by
12 L<febootstrap(8)> into a supermin appliance.  The term "supermin
13 appliance" is described in the documentation below.  First you should
14 be familiar with L<febootstrap(8)> and L<febootstrap-to-initramfs(8)>.
15
16 =head1 PARAMETERS
17
18 C<DIR> is the directory created by febootstrap (ie. the output of
19 febootstrap and the input to this program).
20
21 C<supermin.img> is the name of the supermin appliance that this
22 program creates, and C<hostfiles.txt> is the name of the list of
23 hostfiles that this program creates.  (ie. the outputs of this
24 program).
25
26 =head1 SUPERMIN APPLIANCE
27
28 A supermin appliance is a very specialized, highly minimized
29 appliance which can be reconstructed on-the-fly at runtime into
30 an ordinary (initramfs) appliance.
31
32 The normal appliance is a self-contained Linux operating system, based
33 on the Fedora/RHEL/CentOS Linux distro.  So it contains a complete
34 copy of all the libraries and programs needed, like kernel, libc,
35 bash, coreutils etc etc.
36
37 The supermin appliance removes the kernel and all the executable
38 libraries and programs from the appliance.  That just leaves a
39 skeleton of directories, config files and some data files, which is
40 obviously massively smaller than the normal appliance.  At runtime we
41 rebuild the appliance on-the-fly from the libraries and programs on
42 the host (eg. pulling in the real /lib/libc.so, the real /bin/bash
43 etc.)
44
45 Although this process of rebuilding the appliance each time sounds
46 slow, it turns out to be faster than using a prebuilt appliance.
47 (Most of the saving comes from not compressing the appliance - it
48 transpires that decompressing the appliance is the slowest part of the
49 whole boot sequence).  On my machine, a new appliance can be built in
50 under a fifth of a second, and the boot time is several seconds
51 shorter.
52
53 The big advantage of the supermin appliance for distributions like
54 Fedora is that it gets security fixes automatically from the host, so
55 there is no need to rebuild the whole appliance for a security update
56 in some underlying library.
57
58 There are several I<disadvantages>:
59
60 It won't work at all except in very narrow, controlled cases like the
61 Fedora packaging case.  We control the dependencies of the appliance
62 RPM tightly to ensure that the required binaries are actually present
63 on the host.
64
65 Furthermore there are certain unlikely changes in the packages on the
66 host which could break a supermin appliance, eg. an updated library
67 which depends on an additional data file.
68
69 Also supermin appliances are subjected to changes in the host kernel
70 which might break compatibility with qemu -- these are, of course,
71 real bugs in any case.
72
73 Lastly, supermin appliances really can't be moved between branches of
74 distributions (eg. built on Fedora 12 and moved to Fedora 10) because
75 they are not self-contained and they rely on certain libraries being
76 around.  You shouldn't do this anyway.
77
78 Use supermin appliances with caution.
79
80 =head2 ANATOMY OF A SUPERMIN APPLIANCE
81
82 A supermin appliance consists of two files:
83
84 =over 4
85
86 =item supermin.img
87
88 The image file (conventionally called C<supermin.img>, but you can
89 call it anything you want) is the skeleton initramfs.  This is like an
90 initramfs built by L<febootstrap-to-initramfs(8)>, but all libraries
91 and binaries are removed.
92
93 =item hostfiles.txt
94
95 This plain text file contains a list of files that we need to add back
96 from the host at runtime.  ie. It's the list of libraries and binaries
97 that we removed when we constructed C<supermin.img>.
98
99 This file usually contains wildcards.  This is because we don't
100 want the file to break on minor updates to libraries, so for example
101 instead of listing
102
103  lib64/libreadline.so.6.1.2
104
105 the file contains
106
107  lib64/libreadline.so.6.*
108
109 =back
110
111 =head2 RECONSTRUCTING AN INITRAMFS FROM A SUPERMIN APPLIANCE
112
113 The program L<febootstrap-supermin-helper(8)> can be used to
114 reconstruct a full initramfs from C<supermin.img> and C<hostfiles.txt>
115 (plus, naturally, the required programs and libraries in the host
116 filesystem).
117
118 See that man page for details.
119
120 =head2 RESTRICTION: UNREADABLE BINARIES ON THE HOST
121
122 Some binaries on the host are not publically readable.  For example:
123
124  $ ll /usr/libexec/pt_chown 
125  -rws--x--x 1 root root 28418 2009-09-28 13:42 /usr/libexec/pt_chown
126  $ ll /usr/bin/chsh 
127  -rws--x--x 1 root root 18072 2009-10-05 16:28 /usr/bin/chsh
128
129 These binaries cause a problem when reconstructing the supermin
130 appliance, because we'd like to copy them into the final appliance,
131 and usually that process is done as non-root.  Currently the only
132 solution is that you should remove these problematic binaries from the
133 appliance.
134
135 =head1 EXAMPLE
136
137 Create a basic Fedora directory and turn it into a supermin image.
138
139 I<NB> You must only build "Rawhide on Rawhide".  If using another
140 Fedora branch, you must change C<rawhide> below as appropriate, eg to
141 C<fedora-12>.
142
143  $ febootstrap rawhide /tmp/fedora
144  $ febootstrap-to-supermin /tmp/fedora supermin.img hostfiles.txt
145
146 Examine the resulting files:
147
148  $ cpio -itv < supermin.img | less
149  $ less hostfiles.txt
150
151 Reconstruct the final kernel and initramfs.
152
153 I<NB> The first time you run this, it will be slow because the
154 required host files are not in cache.  With a "hot cache" it should be
155 lightning fast.  Run it several times to get representative timings.
156
157  $ febootstrap-supermin-helper supermin.img hostfiles.txt \
158      /tmp/kernel /tmp/initrd
159
160 You would boot the final image like this, although in this example it
161 probably won't work unless you add a C</init> file to the appliance
162 (see the discussion in L<febootstrap-to-initramfs(8)>).
163
164  $ qemu -m 1024 -kernel /tmp/kernel -initrd /tmp/initrd [etc...]
165
166 =head1 SEE ALSO
167
168 L<febootstrap(8)>,
169 L<febootstrap-to-initramfs(8)>,
170 L<febootstrap-supermin-helper(8)>.
171
172 =head1 AUTHORS
173
174 Richard W.M. Jones <rjones @ redhat . com>
175
176 =head1 COPYRIGHT
177
178 (C) Copyright 2009 Red Hat Inc.,
179 L<http://et.redhat.com/~rjones/febootstrap>.
180
181 This program is free software; you can redistribute it and/or modify
182 it under the terms of the GNU General Public License as published by
183 the Free Software Foundation; either version 2 of the License, or
184 (at your option) any later version.
185
186 This program is distributed in the hope that it will be useful,
187 but WITHOUT ANY WARRANTY; without even the implied warranty of
188 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
189 GNU General Public License for more details.
190
191 You should have received a copy of the GNU General Public License
192 along with this program; if not, write to the Free Software
193 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.