|
|
|
@ -987,4 +987,52 @@ 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
|
|
|
|
|
force_boot_without_initramfs ${mountpoint}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
track_initramfs_boot_fallback() {
|
|
|
|
|
mountpoint=$1
|
|
|
|
|
cat <<END > "${mountpoint}/etc/grub.d/01_track_initrdless_boot_fallback"
|
|
|
|
|
#! /bin/sh
|
|
|
|
|
# ${IMAGE_STR}
|
|
|
|
|
# This will detect if we attempt to boot with an initramfs and fail.
|
|
|
|
|
# In the case of a failure, initrdless_boot_fallback_triggered is set to
|
|
|
|
|
# a non-zero value in the grubenv. This value can be checked after boot
|
|
|
|
|
# by looking in /boot/grub/grubenv or by using the grub-editenv list command.
|
|
|
|
|
set -e
|
|
|
|
|
END
|
|
|
|
|
cat <<"END" >> "${mountpoint}/etc/grub.d/01_track_initrdless_boot_fallback"
|
|
|
|
|
cat <<"EOF"
|
|
|
|
|
if [ -n "${have_grubenv}" ]; then
|
|
|
|
|
if [ -n "${initrdfail}" ]; then
|
|
|
|
|
set initrdless_boot_fallback_triggered="${initrdfail}"
|
|
|
|
|
else
|
|
|
|
|
set initrdless_boot_fallback_triggered=0
|
|
|
|
|
fi
|
|
|
|
|
save_env initrdless_boot_fallback_triggered
|
|
|
|
|
fi
|
|
|
|
|
EOF
|
|
|
|
|
END
|
|
|
|
|
chmod +x "${mountpoint}/etc/grub.d/01_track_initrdless_boot_fallback"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
force_boot_without_initramfs() {
|
|
|
|
|
mountpoint=$1
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|