fix: rebuild the initramfs after upgrading the kernel in system AMIs

On Alpine 3.21 apk does not run the mkinitfs trigger inside the libguestfs
appliance, so apk upgrade left the old initramfs beside the new kernel. The
guest could not load virtio_blk and dropped to the emergency shell, which
stalled EKS cluster creation. Run mkinitfs for the installed kernel and fail
the build if the initramfs lacks its virtio_blk module.
This commit is contained in:
Julian Sommer
2026-10-19 13:11:03 +10:00
parent 3dbe352d1b
commit be84b73abe
+3
View File
@@ -287,6 +287,9 @@ if [[ "$DISTRO" == "alpine" ]] && [[ -n "${APK_PACKAGES:-}" ]]; then
# The base cloud image's kernel is only as fresh as its release; upgrade so
# the AMI ships the branch's current linux-virt and security fixes.
CUST+=(--run-command 'apk upgrade')
# apk's mkinitfs trigger does not always fire in the appliance; a new kernel
# with the old initramfs cannot load virtio_blk and never mounts root.
CUST+=(--run-command 'k=$(ls /lib/modules | sort -V | tail -1) && mkinitfs "$k" && zcat /boot/initramfs-virt | cpio -t | grep -qE "^(usr/)?lib/modules/$k/.*/virtio_blk\.ko"')
CUST+=(--run-command "apk add ${APK_PACKAGES}")
elif [[ "$DISTRO" == "ubuntu" ]] && [[ -n "${APT_PACKAGES:-}" ]]; then
echo "Will install packages: ${APT_PACKAGES}"