From 1ca1330eaeb36fbc07abd4ec9922f8e40e99c1fd Mon Sep 17 00:00:00 2001 From: David Krauser Date: Mon, 6 Jul 2020 16:30:24 -0400 Subject: [PATCH 1/4] Boot with an initramfs by default in cloud images Generic cloud images with the linux-generic kernel are not able to boot without an initramfs. Previously, these images attempted to boot without an initramfs, would fail, and then retry with an initramfs. This slows the boot and is confusing behavior. --- .../ubuntu-cpc/hooks.d/base/disk-image-uefi.binary | 10 ---------- live-build/ubuntu-cpc/hooks.d/base/disk-image.binary | 11 ----------- 2 files changed, 21 deletions(-) diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary index 98c08f81..2d298ec9 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary @@ -73,14 +73,6 @@ install_grub() { efi_boot_dir="/boot/efi/EFI/BOOT" chroot mountpoint mkdir -p "${efi_boot_dir}" - if [ -n "$partuuid" ]; then - # FIXME: code duplicated between disk-image.binary - # and disk-image-uefi.binary. We want to fix this to not - # have initramfs-tools installed at all on these images. - echo "partuuid found for root device; omitting initrd" - echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid.cfg - fi - chroot mountpoint apt-get -y update # UEFI GRUB modules are meant to be used equally by Secure Boot and @@ -154,8 +146,6 @@ create_empty_disk_image "${disk_image}" create_partitions "${disk_image}" mount_image "${disk_image}" 1 -partuuid=$(blkid -s PARTUUID -o value "$rootfs_dev_mapper") - # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}" mkdir mountpoint diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary index 5884fe61..14e9bc65 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary @@ -73,8 +73,6 @@ create_empty_partition "${disk_image}" "$ROOTPART" "$ROOTPART_START" -1 ext2 "$R mount_image "${disk_image}" "$ROOTPART" -partuuid=$(blkid -s PARTUUID -o value "$rootfs_dev_mapper") - # Copy the chroot in to the disk make_ext4_partition "${rootfs_dev_mapper}" mkdir mountpoint @@ -122,15 +120,6 @@ if [ "${should_install_grub}" -eq 1 ]; then ${loop_device} rm mountpoint/tmp/device.map - - if [ -n "$partuuid" ]; then - echo "partuuid found for root device; forcing it in Grub" - mkdir -p mountpoint/etc/default/grub.d - echo "GRUB_FORCE_PARTUUID=$partuuid" >> mountpoint/etc/default/grub.d/40-force-partuuid.cfg - divert_grub mountpoint - chroot mountpoint update-grub - undivert_grub mountpoint - fi fi if [ "$ARCH" = "s390x" ]; then From 8a2cdec470f976ad57b95d25dd42e41595401063 Mon Sep 17 00:00:00 2001 From: David Krauser Date: Mon, 6 Jul 2020 16:34:29 -0400 Subject: [PATCH 2/4] 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 } From e8e3e6760f058857e2b19ff1b7fa193715e9acf0 Mon Sep 17 00:00:00 2001 From: David Krauser Date: Mon, 6 Jul 2020 16:38:21 -0400 Subject: [PATCH 3/4] Drop hack in kvm image that forces initramfs-less boot Since the kvm image now boots without an initramfs by default, we don't need to force it in the build hook. --- live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary | 3 --- 1 file changed, 3 deletions(-) diff --git a/live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary b/live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary index 094cb375..f9782d0b 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/kvm-image.binary @@ -49,9 +49,6 @@ replace_kernel ${mount_d} "linux-kvm" chroot "${mount_d}" update-grub undivert_grub "${mount_d}" -env DEBIAN_FRONTEND=noninteractive chroot "${mount_d}" rm \ - -rf /boot/initrd.img-* /boot/initrd.img - # Remove indices env DEBIAN_FRONTEND=noninteractive chroot "${mount_d}" apt-get \ clean From 5a4541b01e64001eabe0036a86553c036a973998 Mon Sep 17 00:00:00 2001 From: David Krauser Date: Mon, 6 Jul 2020 17:28:59 -0400 Subject: [PATCH 4/4] Add changelog entry for initramfs changes --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index 343ce228..ea3f8584 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.670) UNRELEASED; urgency=medium + + * Boot with an initramfs by default in cloud images, except when + using a non-generic kernel. + + -- David Krauser Mon, 06 Jul 2020 17:25:20 -0400 + livecd-rootfs (2.669) groovy; urgency=medium * chroot: disable amd64 codepath on riscv64