Skip to content

fix(convert): support GCP-style images with a separate ESP grub.cfg and vendor kernels#130

Open
Wilbert957 wants to merge 1 commit into
openanolis:masterfrom
0gfoundation:fix/gcp-convert-esp-sync
Open

fix(convert): support GCP-style images with a separate ESP grub.cfg and vendor kernels#130
Wilbert957 wants to merge 1 commit into
openanolis:masterfrom
0gfoundation:fix/gcp-convert-esp-sync

Conversation

@Wilbert957

Copy link
Copy Markdown

Problem

cryptpilot-convert cannot produce a bootable image from a GCP Ubuntu 24.04 cloud image. Two independent issues:

  1. Stale ESP grub.cfg. GCP images keep a full, firmware-read grub.cfg on the EFI System Partition (/boot/efi/EFI/<distro>/grub.cfg), while convert only regenerates the boot-partition copy (/boot/grub/grub.cfg). After conversion the ESP copy still references the pre-conversion kernel, so the firmware boots a stale (often already-removed) kernel and the boot fails with error: file '/vmlinuz-...' not found / error: file '/EFI/ubuntu/x86_64-efi/bli.mod' not found.

  2. zram module detection hard-codes -generic. install_zram_module_if_needed greps dpkg -l for linux-image-...-generic. On an image whose only kernel is a cloud-vendor flavor (e.g. -gcp, -aws), the match is empty and convert aborts with Could not determine kernel version.

Fix

  1. After regenerating the boot-partition grub.cfg, propagate it (and the grub module directory, e.g. x86_64-efi) to each separate ESP grub.cfg. No-op when there is no separate ESP copy; skips the case where grub-mkconfig already wrote straight to the ESP (e.g. the alinux symlink), detected with -ef.
  2. Select the highest-versioned installed vmlinuz regardless of flavor, matching the kernel already chosen for the initrd later (ls /boot/vmlinuz-* | sort -V | tail -1).

Both changes are scoped to behavior that was already broken for these images and are no-ops on layouts that already worked (e.g. alinux UEFI, single-grub.cfg images).

Testing

End-to-end on a GCP Ubuntu 24.04 image converted with a 6.17.0-1018-gcp kernel, with the equivalent out-of-tree post-processing removed so convert alone is exercised:

  • convert logs Syncing regenerated grub.cfg to ESP: /boot/efi/EFI/ubuntu/grub.cfg; the ESP grub.cfg default entry now points at the -gcp kernel and the x86_64-efi module dir (incl. bli.mod) is present.
  • zram detection resolves 6.17.0-1018-gcp instead of aborting.
  • The converted image boots successfully both under QEMU/OVMF and on a real GCP TDX Confidential VM: cryptpilot-fde before-sysroot sets up dm-verity + zram + dm-snapshot, /sysroot mounts, after-sysroot completes, switch-root succeeds, and the system reaches multi-user.

…nd vendor kernels

Two issues prevented cryptpilot-convert from producing a bootable image on
GCP Ubuntu cloud images:

1. Stale ESP grub.cfg. GCP images keep a full, firmware-read grub.cfg on the
   EFI System Partition (/boot/efi/EFI/<distro>/grub.cfg), while convert only
   regenerates the boot-partition copy (/boot/grub/grub.cfg). After convert the
   ESP copy still references the pre-conversion kernel, so the firmware boots a
   stale (often already-removed) kernel and fails with "vmlinuz-... not found"
   / "*.mod not found". Propagate the regenerated grub.cfg and the grub module
   directory to each separate ESP grub.cfg. This is a no-op when there is no
   separate ESP copy, and skips the case where grub-mkconfig already wrote
   straight to the ESP (e.g. the alinux symlink), detected with -ef.

2. zram kernel-module detection hard-coded "-generic". On images whose only
   kernel is a cloud-vendor flavor (e.g. -gcp, -aws) the detection returned
   empty and aborted with "Could not determine kernel version". Select the
   highest-versioned installed vmlinuz regardless of flavor, matching the
   kernel chosen for the initrd later.

Verified end-to-end on a GCP Ubuntu 24.04 image converted with a -gcp kernel:
the ESP grub.cfg and module set become byte-equivalent to a known-bootable
image, and zram detection resolves the -gcp kernel.
@shankailun-aliyun

Copy link
Copy Markdown

@Wilbert957 ,您好,您的请求已接收,请耐心等待结果。

@shankailun-aliyun

Copy link
Copy Markdown

@Wilbert957 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants