coreos-assembler: OSBuild without compression yields GRUB failures

When we switched OSbuild over to not compressing we started getting failures where images wouldn’t boot like:

  Booting `Fedora CoreOS 40.20240207.dev.1 (ostree:0)'

error: ../../grub-core/fs/fshelp.c:257:file
`/boot/ostree/fedora-coreos-f25027bf4dfb2213
7b7c8401ed2396924ba112482afc30d62b7a4ab1310b09db/vmlinuz-6.8.0-0.rc0.20240112gi
t70d201a40823.5.fc40.x86_64' not found.
error: ../../grub-core/loader/i386/pc/linux.c:422:you need to load the kernel
first.
 
Press any key to continue...

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 25 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Patch from dchinner:

https://lore.kernel.org/linux-xfs/20240220224928.3356-1-david@fromorbit.com/T/#u

Still trying to craft a simple reproducer though.

Oh, absolutely, the (source) filesystem does matter. I just meant the target filesystem of the copy/convert operation (for qemu.qcow2), which I changed to tmpfs, and still saw the problem.

I do believe that the (seemingly) incorrect hole information for disk.img is XFS-related.

It’s extremely suspicious though. Usually qcow2 and qemu-img are rock solid tools.

Yes 😃. I’d like to take a moment here and thank you and all the other maintainers of those tools over the years. You’ve truly built something that is load bearing for half of the internet and the world’s economy at this point.

I currently don’t think it’s an issue in qemu-img, but will let you know if that changes.

I do appreciate you weighing in here, though.

So I don’t know if it’s this, but the classic failure mode when you create a disk image and then boot from it shortly afterwards is:

  • You create the disk image using regular tools, qemu-img etc.
  • The data is written to the kernel page cache, but not necessarily synched to disk yet.
  • You boot the image using the cache=none mode (which uses O_DIRECT)
  • qemu reads directly from the disk without looking at the page cache
  • Result is corruption and woe

If this is the scenario, then you need to modify your image creation pipeline so that it does an fsync or similar on the disk image before qemu runs.

Here’s how virt-builder does that:

https://github.com/libguestfs/guestfs-tools/blob/acebc8b9962a78d36afe01cae78c11410b483248/builder/builder.ml#L803

Talked to @jlebon on this. We think (actually more @jlebon, I was just nodding my head to everything he said) that this might be a bug with reflinks on XFS.

The cache qcow2 is an XFS filesystem and when we switch to not using compression for the org.osbuild.qemu stage we think it enables qemu-img convert to use reflinks for some of the data ranges in the image (i.e. to share between the source raw image and newly created qcow2 image).

i.e. this is a theory that could explain why we see issues only after switching off compression. This particular issue reminded @jlebon of https://github.com/coreos/coreos-assembler/pull/935 which we never fully got to the bottom of.