[Libguestfs] [PATCH supermin v2 3/4] docs: Document how to link the init binary with an alternate libc.

Richard W.M. Jones rjones at redhat.com
Wed Feb 17 14:22:33 UTC 2016


Because of the previous commits, it is now possible to link the init
binary using alternate libc's.  This updates the documentation to
describe how to link it using dietlibc.

Using dietlibc reduces the overall size of the initrd substantially.
For libguestfs, 2.6M -> 1.8M.  Though this is still slightly larger
than the initrd using compressed modules (1.4M).
---
 README           | 24 ++++++++++++++++++++++++
 init/Makefile.am |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/README b/README
index 56a28f6..ee2ec0e 100644
--- a/README
+++ b/README
@@ -40,6 +40,8 @@ Requirements
     - This is just used to generate the manpage.
 
   static libc
+    - Can be replaced with dietlibc (and maybe other alternate libc).
+      See section ``Alternate libc'' below.
 
   bash
 
@@ -144,3 +146,25 @@ Feedback and bugs
 Send feedback to libguestfs at redhat.com.  You can file bugs in
 https://bugzilla.redhat.com/ (under "Fedora", "supermin")
 
+Alternate libc
+--------------
+
+Supermin uses a small, statically linked "init" binary.  Normally this
+is linked to static glibc, but static glibc produces enormous binaries
+(800KB+).  You can use an alternate libc if you prefer.  For example,
+using dietlibc, I can build a 22K init, about 1/40th of the size.
+
+  $ ls -l init/init
+  -rwxrwxr-x. 1 rjones rjones 21736 Feb 17 14:03 init/init
+
+- Dietlibc
+
+For dietlibc, build supermin like this:
+
+  ./configure
+  make clean
+  make -C init init CC="diet gcc"
+  make
+
+which builds the init using dietlibc, and then builds the rest of
+supermin with the dietlibc-using init binary.
diff --git a/init/Makefile.am b/init/Makefile.am
index 075cf46..5e02870 100644
--- a/init/Makefile.am
+++ b/init/Makefile.am
@@ -19,6 +19,9 @@
 
 CLEANFILES = *~
 
+# You can build this using an alternate libc if you want.  See
+# README ``Alternate libc''.
+
 noinst_PROGRAMS = init
 init_SOURCES = init.c
 init_CFLAGS = -static
-- 
2.5.0




More information about the Libguestfs mailing list