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 <ryao@cs.stonybrook.edu>
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
(commit message rewritten).
cleanup-cruft
Richard Yao 13 years ago committed by Robin H. Johnson
parent 7879a0c74c
commit 73520cb6b2

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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"

@ -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

@ -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

@ -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
---------------

@ -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 "$*"`"
;;

@ -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"

@ -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}"

@ -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"

Loading…
Cancel
Save