From e95ed472a1ecccf489474103df940550d5b07f21 Mon Sep 17 00:00:00 2001 From: sakaki Date: Thu, 3 May 2018 19:09:06 +0100 Subject: [PATCH] Bump version to 1.0.30 Use XZ compression for integrated initramfs by default now; some systems will not boot if a large, uncompressed initramfs is used (even though the enclosing kernel is compressed). --- buildkernel | 38 +++++++++++++++++++++++++++++--------- buildkernel.8 | 4 ++-- buildkernel.conf | 6 ++++++ buildkernel.conf.5 | 14 ++++++++++++-- 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/buildkernel b/buildkernel index 1b26544..89cb6d1 100755 --- a/buildkernel +++ b/buildkernel @@ -3,7 +3,7 @@ # Build kernel, modules and initial ramdisk in correct sequence, ensuring kernel # config is conformed, then sign if possible and copy to EFI boot partition. # -# Copyright (c) 2014-2017 sakaki +# Copyright (c) 2014-2018 sakaki # # License (GPL v3.0) # ------------------ @@ -31,7 +31,7 @@ shopt -s nullglob # ********************** variables ********************* PROGNAME="$(basename "${0}")" CONFFILE="/etc/${PROGNAME}.conf" -VERSION="1.0.29" +VERSION="1.0.30" ETCPROFILE="/etc/profile" DEFAULTEFIBOOTFILE="bootx64.efi" EFIBOOTFILE="${DEFAULTEFIBOOTFILE}" @@ -77,6 +77,8 @@ CMDLINE_REAL_ROOT="/dev/mapper/vg1-root" CMDLINE_REAL_RESUME="/dev/mapper/vg1-swap" declare -i DEFAULTCREATEEFIBOOT=1 declare -i CREATEEFIBOOT="${DEFAULTCREATEEFIBOOT}" +declare -i DEFAULTCOMPRESSINITRAMFS=1 +declare -i COMPRESSINITRAMFS="${DEFAULTCOMPRESSINITRAMFS}" # you can use xconfig etc if you like - override in /etc/buildkernel.conf CONFIGTYPE="menuconfig" # following should already be in the environment; but to be safe... @@ -1633,12 +1635,28 @@ conform_config_file() { set_kernel_config "CMDLINE" "\"${KERNEL_CMD_LINE}\"" show "Setting up initramfs location and type..." set_kernel_config "INITRAMFS_SOURCE" "\"${UNCOMPRESSEDINITRAMFS}\"" - # initramfs compression must be 'none' - not as big a deal as it sounds, - # since the encapsulating kernel image will itself be compressed... - for COMP_TYPE in "GZIP" "BZIP2" "LZMA" "XZ" "LZO"; do - unset_kernel_config "INITRAMFS_COMPRESSION_${COMP_TYPE}" - done - set_kernel_config "INITRAMFS_COMPRESSION_NONE" "y" + # unless the user specifically directs, we will compress the initramfs with + # XZ - although the enclosing kernel will be compressed anyway, this can + # help on low-memory systems; also the need to leave compression off seems + # to no longer apply with modern kernels + if ((COMPRESSINITRAMFS==1)); then + show "Using XZ compression for built-in initramfs" + unset_kernel_config "INITRAMFS_COMPRESSION_NONE" + for COMP_TYPE in "GZIP" "BZIP2" "LZMA" "LZO" "LZ4"; do + unset_kernel_config "INITRAMFS_COMPRESSION_${COMP_TYPE}" + done + set_kernel_config "INITRAMFS_COMPRESSION_XZ" "y" + set_kernel_config "INITRAMFS_COMPRESSION" ".xz" + else + warning "As requested, not compressing the built-in initramfs" + warning "This can lead to boot failure on memory-constrained systems" + for COMP_TYPE in "GZIP" "BZIP2" "LZMA" "XZ" "LZO" "LZ4"; do + unset_kernel_config "INITRAMFS_COMPRESSION_${COMP_TYPE}" + done + set_kernel_config "INITRAMFS_COMPRESSION_NONE" "y" + set_kernel_config "INITRAMFS_COMPRESSION" "" + fi + # ensure we can get at the LUKS volume! note that these could also be # modules really, since we copy all modules into the initramfs show "Ensuring Serpent, Whirlpool and SHA-512 are included..." @@ -1767,7 +1785,9 @@ rebuild_external_modules_if_necessary() { create_initramfs_using_genkernel() { show "Creating initramfs (uncompressed)..." # this is a partial use of genkernel, we don't use it to build the kernel - # itself; also note, EFI kernels *require* an uncompressed ramdisk + # itself; also note, we build an uncompressed ramdisk, as the kernel + # build process will compress it on integration into the + # unified kernel image # we suppress gpg here as we don't want to add gpg v2 which is installed, # but rather our static gpg v1, which will be inserted into the initramfs local PLYMOUTH_OPTS="" diff --git a/buildkernel.8 b/buildkernel.8 index 0fd8a36..6fa3ba8 100644 --- a/buildkernel.8 +++ b/buildkernel.8 @@ -1,4 +1,4 @@ -.TH BUILDKERNEL 8 "Version 1.0.29: January 2018" +.TH BUILDKERNEL 8 "Version 1.0.30: May 2018" .SH NAME buildkernel \- build secure boot kernel, save to EFI system partition .SH SYNOPSIS @@ -244,7 +244,7 @@ A post-reboot run of \fBgenup\fR(8) will achieve this. .SH COPYRIGHT .nf -Copyright \(co 2014-2017 sakaki +Copyright \(co 2014-2018 sakaki License GPLv3+ (GNU GPL version 3 or later) diff --git a/buildkernel.conf b/buildkernel.conf index 790f7da..582f6cc 100644 --- a/buildkernel.conf +++ b/buildkernel.conf @@ -73,6 +73,12 @@ # the below (capitalization is unimportant) #INITSYSTEM="openrc" +# if you want to revert to the old (<=1.0.29) behaviour of _not_ compressing +# the built-in initramfs, uncomment the line below; XZ compression is now +# used by default; some systems will not boot large kernels that contain an +# uncompressed ramfs, even though the enclosing kernel is itself compressed +#COMPRESSINITRAMFS=0 + # if you need to conform the config file for some reason, uncomment this # hook function and fill it out to suit your requirements # NB you should only really need to do this to override a setting forced diff --git a/buildkernel.conf.5 b/buildkernel.conf.5 index be37f09..b7db57c 100644 --- a/buildkernel.conf.5 +++ b/buildkernel.conf.5 @@ -1,4 +1,4 @@ -.TH BUILDKERNEL 5 "Version 1.0.29: January 2018" +.TH BUILDKERNEL 5 "Version 1.0.30: May 2018" .SH NAME buildkernel.conf \- a configuration file for \fBbuildkernel\fR(8) .SH SYNOPSIS @@ -176,6 +176,16 @@ Set to \fB0\fR only if you have your own EFI bootloader, or want to insert appropriate EFI boot settings manually. Most users will not need to override the default. +.br +.TP +.BR COMPRESSINITRAMFS +When set to \fB0\fR the \fBbuildkernel\fR script will \fInot\fR +intruct the kernel to XZ compress its integral initrams (the default +behaviour prior to version 1.0.30); doing so may cause boot +issues on certain systems with modest RAM. + +Most users will not need to override the default. + .RE .SH FUNCTIONS The following hook functions \fImay\fR be specified in \fB/etc/buildkernel.conf\fR if @@ -201,7 +211,7 @@ function exit. .RE .SH COPYRIGHT .nf -Copyright \(co 2014-2017 sakaki +Copyright \(co 2014-2018 sakaki License GPLv3+ (GNU GPL version 3 or later)