Implement --[no-]compress-initramfs option to complement --[no-]integrated-initramfs
authorRichard Yao <ryao@cs.stonybrook.edu>
Sat, 28 Jan 2012 01:08:58 +0000 (20:08 -0500)
committerRobin H. Johnson <robbat2@gentoo.org>
Sat, 28 Jan 2012 20:17:00 +0000 (20:17 +0000)
When using an integrated initramfs (including in kernel during build),
it's better NOT to compress the initramfs, as the kernel build process
will then be re-compressing it. This can provide space savings on disk
as well as potential time & memory savings (one less decompress pass is
needed before the kernel can use the initramfs).

This functionality was previously available in the undocumented
COMPRESS_INITRD variable.

Code-by: Richard Yao <ryao@cs.stonybrook.edu>
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
(commit message rewritten).

18 files changed:
arch/alpha/config.sh
arch/arm/config.sh
arch/ia64/config.sh
arch/mips/config.sh
arch/parisc/config.sh
arch/parisc64/config.sh
arch/ppc/config.sh
arch/ppc64/config.sh
arch/sparc/config.sh
arch/sparc64/config.sh
arch/um/config.sh
arch/x86/config.sh
arch/x86_64/config.sh
doc/genkernel.8.txt
gen_cmdline.sh
gen_determineargs.sh
gen_initramfs.sh
genkernel.conf

index 44494f1f493cea76c0bf19ba069c96eefdaaa1ad..2692f23afc8e7fd9a4cb1523b87d2ea1e0a47db1 100755 (executable)
@@ -6,12 +6,12 @@ KERNEL_MAKE_DIRECTIVE="boot"
 KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="arch/alpha/boot/vmlinux.gz"
 
-COMPRESS_INITRD=yes
-
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index 52ec777538ac49334a1bbb511442536a11d77430..7ce427efbcc0c086f542453e695b7125cacb1a78 100755 (executable)
@@ -6,12 +6,12 @@ KERNEL_MAKE_DIRECTIVE=""
 KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="arch/arm/boot/zImage"
 
-COMPRESS_INITRD=yes
-
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index 38f1bc100c8fa6111003f5a561f552b9e1a3c3b9..9b61bce5858c88126ef32523133a45ca74ed31b9 100755 (executable)
@@ -6,12 +6,12 @@ KERNEL_MAKE_DIRECTIVE=""
 KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="vmlinux.gz"
 
-COMPRESS_INITRD=yes
-
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index 9d49c09bc534f7fd11ee7264b1c482f40485e042..939fb96ae684888090fe25e5e051a86c2e12a5f6 100755 (executable)
@@ -7,7 +7,6 @@ KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="./vmlinux"
 
 # Initrd/Initramfs Options
-COMPRESS_INITRD="yes"
 USECOLOR="yes"
 NOINITRDMODULES="yes"
 BUSYBOX=1
@@ -22,6 +21,7 @@ CMD_INSTALL=0
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD="yes"
 DEFAULT_KERNEL_MAKE=make
 DEFAULT_UTILS_MAKE=make
 DEFAULT_UTILS_CC=gcc
index 3e2049f02d2f9c242ee910c84b6362583c2710ec..c31b316a77f6543b87662e47daec12dfb90abefa 100755 (executable)
@@ -6,12 +6,12 @@ KERNEL_MAKE_DIRECTIVE="vmlinux"
 KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="vmlinux"
 
-COMPRESS_INITRD=yes
-
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index 3e2049f02d2f9c242ee910c84b6362583c2710ec..c31b316a77f6543b87662e47daec12dfb90abefa 100755 (executable)
@@ -6,12 +6,12 @@ KERNEL_MAKE_DIRECTIVE="vmlinux"
 KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="vmlinux"
 
-COMPRESS_INITRD=yes
-
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index e86e926f4b40ce0fa2755b24b586c96bb4c39f43..e661c5a79543da5f5a715e71f3102d59cc084c07 100755 (executable)
@@ -5,12 +5,12 @@
 KERNEL_MAKE_DIRECTIVE="vmlinux"
 KERNEL_BINARY="vmlinux"
 
-COMPRESS_INITRD=yes
-
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index e86e926f4b40ce0fa2755b24b586c96bb4c39f43..e661c5a79543da5f5a715e71f3102d59cc084c07 100755 (executable)
@@ -5,12 +5,12 @@
 KERNEL_MAKE_DIRECTIVE="vmlinux"
 KERNEL_BINARY="vmlinux"
 
-COMPRESS_INITRD=yes
-
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index 34cec7339aa810b60a5f484a7cde94c51247775f..3d6234769b83d2ed87d387e006234999f82547a2 100755 (executable)
@@ -6,13 +6,14 @@ KERNEL_MAKE_DIRECTIVE="vmlinux"
 KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="vmlinux"
 
-COMPRESS_INITRD=yes
 USECOLOR="no"
 
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j1"
 
 DEFAULT_KERNEL_MAKE=make
index d1e37d550088f1c7fd7689dd499ba9df2e24872f..563ebd913d349cc0ed40c3042c89d86699f737dc 100755 (executable)
@@ -6,13 +6,14 @@ KERNEL_MAKE_DIRECTIVE="vmlinux"
 KERNEL_MAKE_DIRECTIVE_2="image"
 KERNEL_BINARY="arch/sparc64/boot/image arch/sparc/boot/image"
 
-COMPRESS_INITRD=yes
 USECOLOR="no"
 
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index 070602e90d15bcc9f0f239fe87feea2517439ba1..7955a85b0fbf4719ae1c6aeca6489c74a8bf522a 100755 (executable)
@@ -6,13 +6,14 @@ KERNEL_MAKE_DIRECTIVE="linux"
 KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="linux"
 
-COMPRESS_INITRD=yes
 ARCH_HAVENOPREPARE=yes
 
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE="make ARCH=um"
index 7f339eac6b4fff03c3d1ca0375d6b0d2021cd423..6f14ceffa5d445539bd0d061610d7122a29d59f2 100755 (executable)
@@ -6,12 +6,12 @@ KERNEL_MAKE_DIRECTIVE="bzImage"
 KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="arch/i386/boot/bzImage"
 
-COMPRESS_INITRD=yes
-
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index 8e692e84ae6e754ee00bd36deb557a206fe26910..0a903e1456cc9f90f2ea16442c54b68c328f2f47 100755 (executable)
@@ -6,12 +6,12 @@ KERNEL_MAKE_DIRECTIVE="bzImage"
 KERNEL_MAKE_DIRECTIVE_2=""
 KERNEL_BINARY="arch/x86_64/boot/bzImage"
 
-COMPRESS_INITRD=yes
-
 #
 # Arch-specific defaults that can be overridden in the config file or on the
 # command line.
 #
+DEFAULT_COMPRESS_INITRD=yes
+
 DEFAULT_MAKEOPTS="-j2"
 
 DEFAULT_KERNEL_MAKE=make
index 703f8e124e4a537111e5a8092b108c056da76c7f..1e02fb7d67e1f9a04d79316f8874ffdb9fd6860c 100644 (file)
@@ -361,6 +361,9 @@ OUTPUT SETTINGS
        Builds or does not build the generated initramfs into the kernel instead
        of keeping it as a separate file.
 
+*--*[*no-*]*compress-initramfs*::
+       Compresses or does not compress the generated initramfs.
+
 
 RAMDISK OPTIONS
 ---------------
index a89636cc9c2e9113cc5e7ce11b20c16ec14d8243..4c04f940b0f2a2eaf06992ab4e5cd6dddea0351e 100755 (executable)
@@ -149,6 +149,8 @@ longusage() {
   echo "       --integrated-initramfs, --no-integrated-initramfs"
   echo "                               Include/exclude the generated initramfs in the kernel"
   echo "                               instead of keeping it as a separate file"
+  echo "       --compress-initramfs, --no-compress-initramfs"
+  echo "                               Compress or do not compress the generated initramfs"
 }
 
 usage() {
@@ -529,6 +531,10 @@ parse_cmdline() {
                        CMD_INTEGRATED_INITRAMFS=`parse_optbool "$*"`
                        print_info 2 "CMD_INTEGRATED_INITRAMFS=${CMD_INTEGRATED_INITRAMFS}"
                        ;;
+               --compress-initramfs|--no-compress-initramfs)
+                       CMD_COMPRESS_INITRD=`parse_optbool "$*"`
+                       print_info 2 "CMD_COMPRESS_INITRD=${CMD_COMPRESS_INITRD}"
+                       ;;
                --config=*)
                        print_info 2 "CMD_GK_CONFIG: `parse_opt "$*"`"
                        ;;
index 66f7ee1aaf1c23eeda87c49a673647f37e8b07bb..b12efcaf85977dc66c0b3a33b6f1232ef870c56b 100755 (executable)
@@ -75,6 +75,7 @@ determine_real_args() {
        set_config_with_override BOOL   KERNEL_SOURCES       CMD_KERNEL_SOURCES       "yes"
        set_config_with_override STRING KNAME                CMD_KERNNAME             "genkernel"
 
+       set_config_with_override STRING COMPRESS_INITRD      CMD_COMPRESS_INITRD      "$DEFAULT_COMPRESS_INITRD"
        set_config_with_override STRING MAKEOPTS             CMD_MAKEOPTS             "$DEFAULT_MAKEOPTS"
        set_config_with_override STRING KERNEL_MAKE          CMD_KERNEL_MAKE          "$DEFAULT_KERNEL_MAKE"
        set_config_with_override STRING UTILS_MAKE           CMD_UTILS_MAKE           "$DEFAULT_UTILS_MAKE"
index cfcfe9792bd9c0197cd5e5200b3174a9ba828dde..32a1b1e09327216a554f7fd8adf219d03ed2a6a0 100755 (executable)
@@ -631,6 +631,7 @@ append_data() {
 }
 
 create_initramfs() {
+       local compress_ext=""
        print_info 1 "initramfs: >> Initializing..."
 
        # Create empty cpio
@@ -673,16 +674,23 @@ create_initramfs() {
                append_data 'overlay'
        fi
 
-       gzip -9 "${CPIO}"
-       mv -f "${CPIO}.gz" "${CPIO}"
+       # Implement support for disabling compression
+       if isTrue "${COMPRESS_INITRD}"
+       then
+               compress_ext=".gz"
+               print_info 1 "        >> Compressing cpio data..."
+               gzip -9 "${CPIO}" || gen_die "Compression failed"
+               mv -f "${CPIO}.gz" "${CPIO}" || gen_die "Rename failed"
+       fi
+
 
        if isTrue "${INTEGRATED_INITRAMFS}"
        then
 #              cp ${TMPDIR}/initramfs-${KV} ${KERNEL_DIR}/usr/initramfs_data.cpio.gz
-               mv ${TMPDIR}/initramfs-${KV} ${TMPDIR}/initramfs-${KV}.cpio.gz
+               mv ${TMPDIR}/initramfs-${KV} ${TMPDIR}/initramfs-${KV}.cpio${compress_ext}
 #              sed -i "s|^.*CONFIG_INITRAMFS_SOURCE=.*$|CONFIG_INITRAMFS_SOURCE=\"${TMPDIR}/initramfs-${KV}.cpio.gz\"|" ${KERNEL_DIR}/.config
                sed -i '/^.*CONFIG_INITRAMFS_SOURCE=.*$/d' ${KERNEL_DIR}/.config
-               echo -e "CONFIG_INITRAMFS_SOURCE=\"${TMPDIR}/initramfs-${KV}.cpio.gz\"\nCONFIG_INITRAMFS_ROOT_UID=0\nCONFIG_INITRAMFS_ROOT_GID=0" >> ${KERNEL_DIR}/.config
+               echo -e "CONFIG_INITRAMFS_SOURCE=\"${TMPDIR}/initramfs-${KV}.cpio${compress_ext}\"\nCONFIG_INITRAMFS_ROOT_UID=0\nCONFIG_INITRAMFS_ROOT_GID=0" >> ${KERNEL_DIR}/.config
        fi
 
        if isTrue "${CMD_INSTALL}"
index b39a952ab3df9371a15786986e417f187396a39c..7032ac718cebb96a11893b6674cb8c32ae57deab 100644 (file)
@@ -317,6 +317,10 @@ GPG_BINCACHE="%%CACHE%%/gnupg-${GPG_VER}-%%ARCH%%.bz2"
 #INTEGRATED_INITRAMFS="1"
 
 
+# Compress generated initramfs
+#COMPRESS_INITRD="yes"
+
+
 # Create a self-contained env in the initramfs
 #NETBOOT="1"