[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#627665: option to remove kernel+initrd from compressed filesystem

Package: live-build
Version: 3.0~a17-1
Severity: wishlist
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch oneiric

On the Ubuntu live CDs, we have a hack to save some space: rather than
shipping the kernel and initrd both in the ISO9660 filesystem (for
booting) and in the squashfs (for installing), we remove the duplicate
copies from the squashfs, and our installer is smart enough to copy
those files from the ISO9660 filesystem if it needs to.  This saves us
17MiB or so of CD space at the cost of a small amount of code

We'll be able to get rid of this hack once we switch to GRUB as our CD
boot loader, since it can read files out of the squashfs directly; but
even so it seems like something other folks might find useful,
particularly if they're creating a live CD that isn't intended to be

The attached patch adds 'lb config --binary-remove-linux true'.  Feel
free to rename the option if some other name would fit better, though.


Colin Watson                                       [cjwatson@ubuntu.com]
>From dfaac39fe91755c5cfc7e34b85d52633df5bfd0c Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@canonical.com>
Date: Mon, 23 May 2011 13:12:01 +0100
Subject: [PATCH] Add an option to remove the kernel and initrd from the compressed filesystem.

 functions/defaults.sh               |    2 ++
 manpages/en/lb_config.1             |    4 ++++
 scripts/build/lb_binary_linux-image |    6 ++++++
 scripts/build/lb_config             |   12 +++++++++++-
 4 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/functions/defaults.sh b/functions/defaults.sh
index 8526335..a1e5c83 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -826,6 +826,8 @@ Set_defaults ()
 	# Setting apt indices
 	case "${LB_MODE}" in
diff --git a/manpages/en/lb_config.1 b/manpages/en/lb_config.1
index 88fcc9b..5e247b4 100644
--- a/manpages/en/lb_config.1
+++ b/manpages/en/lb_config.1
@@ -33,6 +33,8 @@
 	[\fB\-\-binary\-filesystem\fR fat16|fat32|ext2]
+	[\fB\-\-binary\-remove\-linux\fR true|false]
 	[\fB\-\-bootappend\-install\fR \fIPARAMETER\fR|\fI"PARAMETERS"\fR]
 	[\fB\-\-bootappend\-live\fR \fIPARAMETER\fR|\fI"PARAMETERS"\fR]
@@ -281,6 +283,8 @@ defines the architecture of the to be build image. By default, this is set to th
 defines the image type to build. By default, for images using syslinux this is set to iso\-hybrid to build CD/DVD images that may also be used like usb\-hdd images, for non\-syslinux images, it defaults to iso.
 .IP "\fB\-\-binary\-filesystem\fR fat16|fat32|ext2" 4
 defines the filesystem to be used in the image type. This only has an effect if the selected binary image type does allow to choose a filesystem. For example, when selection iso the resulting CD/DVD has always the filesystem ISO9660. When building usb\-hdd images for usb sticks, this is active. Note that it defaults to fat16 on all architectures except sparc where it defaults to ext2. Also note that if you choose fat16 and your resulting binary image gets bigger than 2GB, the binary filesystem automatically gets switched to fat32.
+.IP "\fB\-\-binary\-remove\-linux\fR true|false" 4
+defines if the Linux kernel and initrd should be removed from the filesystem (they will still be published in the binary output directory). This is useful to reduce image size if the image is not meant to be installable, or if the installer is intelligent enough to copy the kernel and initrd from the top-level image rather than from the compressed filesystem. Default is false.
 .IP "\fB\-\-bootappend\-install\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4
 sets boot parameters specific to debian\-installer, if included.
 .IP "\fB\-\-bootappend\-live\fR \fIPARAMETER\fR|""\fIPARAMETERS\fR""" 4
diff --git a/scripts/build/lb_binary_linux-image b/scripts/build/lb_binary_linux-image
index cac19d8..c5a8cc6 100755
--- a/scripts/build/lb_binary_linux-image
+++ b/scripts/build/lb_binary_linux-image
@@ -76,6 +76,12 @@ mkdir -p "${DESTDIR}"
 cp chroot/boot/"${LINUX}"-* "${DESTDIR}"
 cp chroot/boot/initrd.img-* "${DESTDIR}"
+if [ "${LB_BINARY_REMOVE_LINUX}" = true ]
+	rm -f chroot/boot/"${LINUX}"-*
+	rm -f chroot/boot/initrd.img-*
 case "${LB_INITRAMFS}" in
 		if [ -e chroot/usr/share/doc/live-boot/parameters.txt ]
diff --git a/scripts/build/lb_config b/scripts/build/lb_config
index 0e36240..a2f90eb 100755
--- a/scripts/build/lb_config
+++ b/scripts/build/lb_config
@@ -41,6 +41,7 @@ USAGE="${PROGRAM}   [--apt apt|aptitude]\n\
 \t    [-a|--architectures ARCHITECTURE]\n\
 \t    [-b|--binary-images iso|iso-hybrid|net|tar|usb-hdd]\n\
 \t    [--binary-filesystem fat16|fat32|ext2]\n\
+\t    [--binary-remove-linux true|false]\n\
 \t    [--bootappend-install PARAMETER|\"PARAMETERS\"]\n\
 \t    [--bootappend-live PARAMETER|\"PARAMETERS\"]\n\
 \t    [--bootloader grub|syslinux|yaboot]\n\
@@ -159,7 +160,7 @@ Local_arguments ()
-		packages:,package-lists:,tasks:,security:,volatile:,backports:,binary-filesystem:,binary-images:,
+		packages:,package-lists:,tasks:,security:,volatile:,backports:,binary-filesystem:,binary-images:,binary-remove-linux:,
@@ -603,6 +604,11 @@ Local_arguments ()
 				shift 2
+			--binary-remove-linux)
+				shift 2
+				;;
 				shift 2
 # (Default: ${LB_BINARY_IMAGES})
+# \$LB_BINARY_REMOVE_LINUX: set whether to remove kernel from filesystem
 # \$LB_APT_INDICES: set apt/aptitude generic indices
 # (Default: ${LB_APT_INDICES})

Reply to: