Add configuration variables to build a stripped down initrd
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Thu, 4 Jan 2018 14:05:37 +0000 (15:05 +0100)
committerRaphaël Hertzog <hertzog@debian.org>
Fri, 23 Feb 2018 17:48:45 +0000 (18:48 +0100)
Add several environment variables to strip down the initrd size (for
minimal systems that do not need all features). This allows me to reduce
the initrd size from 8.5 MiB to 8.0 MiB when also using busybox's
mount (see Debian bug #868559) and wget (see Debian bug #885455).

Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
Closes: #886337

backend/initramfs-tools/live.hook
manpages/en/live-boot.7

index 761849e..8be2335 100755 (executable)
@@ -53,12 +53,15 @@ do
 done
 
 # udev dependencies
-for FILE in /lib/udev/*_id
-do
-       copy_exec "${FILE}"
-done
+if [ "${MINIMAL:-}" != "y" ]
+then
+       for FILE in /lib/udev/*_id
+       do
+               copy_exec "${FILE}"
+       done
+fi
 
-if [ -e /lib/udev/rules.d/60-cdrom_id.rules ]
+if [ -e /lib/udev/rules.d/60-cdrom_id.rules ] && [ "${DISABLE_CDROM:-}" != "y" ]
 then
        mkdir -p "${DESTDIR}/lib/udev/rules.d"
        cp -p /lib/udev/rules.d/60-cdrom_id.rules "${DESTDIR}/lib/udev/rules.d"
@@ -103,7 +106,7 @@ manual_add_modules hfsplus
 # Filesystem: jffs2
 manual_add_modules jffs2
 
-if [ -x /usr/bin/rsync ]
+if [ -x /usr/bin/rsync ] && [ "${MINIMAL:-}" != "y" ]
 then
        copy_exec /usr/bin/rsync /bin
 fi
@@ -120,25 +123,37 @@ manual_add_modules aufs
 manual_add_modules overlay
 
 # Filesystem: vfat
-manual_add_modules nls_cp437
-manual_add_modules nls_iso8859-1
-manual_add_modules nls_utf8
-manual_add_modules nls_ascii
-manual_add_modules vfat
+if [ "${DISABLE_FAT:-}" != "y" ]
+then
+       manual_add_modules nls_cp437
+       manual_add_modules nls_iso8859-1
+       manual_add_modules nls_utf8
+       manual_add_modules nls_ascii
+       manual_add_modules vfat
+fi
 
 # Filesystem: ntfs
-manual_add_modules ntfs
+if [ "${DISABLE_NTFS:-}" != "y" ]
+then
+       manual_add_modules ntfs
+fi
 
 [ "${QUIET}" ] || echo -n " devices"
 # Hardware: cdrom
-manual_add_modules ide-cd
-manual_add_modules ide-generic
-manual_add_modules ohci1394
-manual_add_modules sbp2
-manual_add_modules sr_mod
+if [ "${DISABLE_CDROM:-}" != "y" ]
+then
+       manual_add_modules ide-cd
+       manual_add_modules ide-generic
+       manual_add_modules ohci1394
+       manual_add_modules sbp2
+       manual_add_modules sr_mod
+fi
 
 # Hardware: usb
-manual_add_modules sd_mod
+if [ "${DISABLE_USB:-}" != "y" ]
+then
+       manual_add_modules sd_mod
+fi
 
 # Hardware: network
 auto_add_modules net
@@ -187,24 +202,27 @@ then
 fi
 
 # FUSE kernel module
-manual_add_modules fuse
-
-# FUSE filesystem: httpfs2
-if [ -x /usr/bin/httpfs2_ssl ]
-then
-       [ "${QUIET}" ] || echo -n " httpfs:ssl"
-       copy_exec /usr/bin/httpfs2_ssl /bin/httpfs
-elif [ -x /usr/bin/httpfs2 ]
+if [ "${DISABLE_FUSE:-n}" != "y" ]
 then
-       [ "${QUIET}" ] || echo -n " httpfs"
-       copy_exec /usr/bin/httpfs2 /bin/httpfs
-fi
+       manual_add_modules fuse
 
-# FUSE filesystem: curlftpfs
-if [ -x /usr/bin/curlftpfs ]
-then
-       [ "${QUIET}" ] || echo -n " ftpfs"
-       copy_exec /usr/bin/curlftpfs /bin
+       # FUSE filesystem: httpfs2
+       if [ -x /usr/bin/httpfs2_ssl ]
+       then
+               [ "${QUIET}" ] || echo -n " httpfs:ssl"
+               copy_exec /usr/bin/httpfs2_ssl /bin/httpfs
+       elif [ -x /usr/bin/httpfs2 ]
+       then
+               [ "${QUIET}" ] || echo -n " httpfs"
+               copy_exec /usr/bin/httpfs2 /bin/httpfs
+       fi
+
+       # FUSE filesystem: curlftpfs
+       if [ -x /usr/bin/curlftpfs ]
+       then
+               [ "${QUIET}" ] || echo -n " ftpfs"
+               copy_exec /usr/bin/curlftpfs /bin
+       fi
 fi
 
 # iSCSI
index db36641..e6bc73f 100644 (file)
@@ -24,6 +24,31 @@ In addition, there are some more boot parameters to influence the behaviour, see
 
 .SS Configuration Files
 \fBlive\-boot\fR can be configured (but not activated) through configuration files. Those files can be placed either in the root filesystem itself (/etc/live/boot.conf, /etc/live/boot/*), or on the live media (live/boot.conf, live/boot/*).
+These environment variables can only be set in the configuration files:
+
+.TP
+\fBDISABLE_CDROM\fR=[\fIy\fR|\fIn\fR]
+Disable support for booting from CD-ROMs.  If set to '\fIy\fR' mkinitramfs will build an initramfs without the kernel modules for reading CD-ROMs.
+
+.TP
+\fBDISABLE_FAT\fR=[\fIy\fR|\fIn\fR]
+Disable support for booting from FAT file systems.  If set to '\fIy\fR' mkinitramfs will build an initramfs without the kernel module vfat and some nls_* modules.
+
+.TP
+\fBDISABLE_FUSE\fR=[\fIy\fR|\fIn\fR]
+Disable support for booting from FUSE-based file systems.  If set to '\fIy\fR' mkinitramfs will build an initramfs without the kernel module fuse and file systems that depend on it (like curlftpfs and httpfs2).
+
+.TP
+\fBDISABLE_NTFS\fR=[\fIy\fR|\fIn\fR]
+Disable support for booting from NTFS file systems.  If set to '\fIy\fR' mkinitramfs will build an initramfs without the kernel module ntfs.
+
+.TP
+\fBDISABLE_USB\fR=[\fIy\fR|\fIn\fR]
+Disable support for booting from USB devices.  If set to '\fIy\fR' mkinitramfs will build an initramfs without the kernel module sd_mod.
+
+.TP
+\fBMINIMAL\fR=[\fIy\fR|\fIn\fR]
+Build a minimal initramfs.  If set to '\fIy\fR' mkinitramfs will build an initramfs without some udev scripts and without rsync.
 
 .SH OPTIONS
 \fBlive\-boot\fR currently features the following parameters.