From: Richard Yao Date: Sat, 28 Jan 2012 01:08:58 +0000 (-0500) Subject: Implement --[no-]compress-initramfs option to complement --[no-]integrated-initramfs X-Git-Tag: v3.4.25~21 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=73520cb6b2e2479bf230d114d0dcb90f6ccd100c;p=genkernel.git Implement --[no-]compress-initramfs option to complement --[no-]integrated-initramfs 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 Signed-off-by: Robin H. Johnson (commit message rewritten). --- diff --git a/arch/alpha/config.sh b/arch/alpha/config.sh index 44494f1..2692f23 100755 --- a/arch/alpha/config.sh +++ b/arch/alpha/config.sh @@ -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 diff --git a/arch/arm/config.sh b/arch/arm/config.sh index 52ec777..7ce427e 100755 --- a/arch/arm/config.sh +++ b/arch/arm/config.sh @@ -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 diff --git a/arch/ia64/config.sh b/arch/ia64/config.sh index 38f1bc1..9b61bce 100755 --- a/arch/ia64/config.sh +++ b/arch/ia64/config.sh @@ -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 diff --git a/arch/mips/config.sh b/arch/mips/config.sh index 9d49c09..939fb96 100755 --- a/arch/mips/config.sh +++ b/arch/mips/config.sh @@ -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 diff --git a/arch/parisc/config.sh b/arch/parisc/config.sh index 3e2049f..c31b316 100755 --- a/arch/parisc/config.sh +++ b/arch/parisc/config.sh @@ -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 diff --git a/arch/parisc64/config.sh b/arch/parisc64/config.sh index 3e2049f..c31b316 100755 --- a/arch/parisc64/config.sh +++ b/arch/parisc64/config.sh @@ -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 diff --git a/arch/ppc/config.sh b/arch/ppc/config.sh index e86e926..e661c5a 100755 --- a/arch/ppc/config.sh +++ b/arch/ppc/config.sh @@ -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 diff --git a/arch/ppc64/config.sh b/arch/ppc64/config.sh index e86e926..e661c5a 100755 --- a/arch/ppc64/config.sh +++ b/arch/ppc64/config.sh @@ -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 diff --git a/arch/sparc/config.sh b/arch/sparc/config.sh index 34cec73..3d62347 100755 --- a/arch/sparc/config.sh +++ b/arch/sparc/config.sh @@ -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 diff --git a/arch/sparc64/config.sh b/arch/sparc64/config.sh index d1e37d5..563ebd9 100755 --- a/arch/sparc64/config.sh +++ b/arch/sparc64/config.sh @@ -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 diff --git a/arch/um/config.sh b/arch/um/config.sh index 070602e..7955a85 100755 --- a/arch/um/config.sh +++ b/arch/um/config.sh @@ -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" diff --git a/arch/x86/config.sh b/arch/x86/config.sh index 7f339ea..6f14cef 100755 --- a/arch/x86/config.sh +++ b/arch/x86/config.sh @@ -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 diff --git a/arch/x86_64/config.sh b/arch/x86_64/config.sh index 8e692e8..0a903e1 100755 --- a/arch/x86_64/config.sh +++ b/arch/x86_64/config.sh @@ -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 diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt index 703f8e1..1e02fb7 100644 --- a/doc/genkernel.8.txt +++ b/doc/genkernel.8.txt @@ -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 --------------- diff --git a/gen_cmdline.sh b/gen_cmdline.sh index a89636c..4c04f94 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -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 "$*"`" ;; diff --git a/gen_determineargs.sh b/gen_determineargs.sh index 66f7ee1..b12efca 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -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" diff --git a/gen_initramfs.sh b/gen_initramfs.sh index cfcfe97..32a1b1e 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -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}" diff --git a/genkernel.conf b/genkernel.conf index b39a952..7032ac7 100644 --- a/genkernel.conf +++ b/genkernel.conf @@ -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"