From 8a2cdec470f976ad57b95d25dd42e41595401063 Mon Sep 17 00:00:00 2001 From: David Krauser Date: Mon, 6 Jul 2020 16:34:29 -0400 Subject: [PATCH] Boot without an initramfs by default if running a custom kernel Initramfs-less boot, which is a boot optimization, should only be applied where we know it could work for users and provide an improved boot boot experience; images with custom kernels are candidates for that. --- live-build/functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/live-build/functions b/live-build/functions index ac08d5de..85faa08a 100644 --- a/live-build/functions +++ b/live-build/functions @@ -924,4 +924,20 @@ replace_kernel () { install --assume-yes "${new_kernel}" env DEBIAN_FRONTEND=noninteractive chroot "${mountpoint}" apt-get \ autoremove --purge --assume-yes + + # If running a custom kernel, we should try to boot without an initramfs + # We do this by setting GRUB_FORCE_PARTUUID, which forces initramfs-less boot + partuuid=$(blkid -s PARTUUID -o value $(findmnt -n -o SOURCE --target "${mountpoint}")) + if [ -n "${partuuid}" ]; then + echo "Force booting without an initramfs..." + mkdir -p "${mountpoint}/etc/default/grub.d" + cat << EOF >> "${mountpoint}/etc/default/grub.d/40-force-partuuid.cfg" +# Force boot without an initramfs by setting GRUB_FORCE_PARTUUID +# Remove this line to enable boot with an initramfs +GRUB_FORCE_PARTUUID=${partuuid} +EOF + divert_grub "${mountpoint}" + chroot "${mountpoint}" update-grub + undivert_grub "${mountpoint}" + fi }