diff --git a/assemblers/org.osbuild.qemu b/assemblers/org.osbuild.qemu index 99e772f0..728a6890 100755 --- a/assemblers/org.osbuild.qemu +++ b/assemblers/org.osbuild.qemu @@ -360,15 +360,25 @@ def partition_table_from_options(options) -> PartitionTable: def grub2_write_boot_image(boot_f: BinaryIO, - image_f: BinaryIO): + image_f: BinaryIO, + core_location: int): """Write the boot image (grub2 stage 1) to the MBR""" # The boot.img file is 512 bytes, but we must only copy the first 440 # bytes, as these contain the bootstrapping code. The rest of the # first sector contains the partition table, and must not be # overwritten. + image_f.seek(0) image_f.write(boot_f.read(440)) + # Additionally, write the location (in sectors) of + # the grub core image, into the boot image, so the + # latter can find the former. To exact location is + # taken from grub2's "boot.S": + # GRUB_BOOT_MACHINE_KERNEL_SECTOR 0x5c (= 92) + image_f.seek(0x5c) + image_f.write(struct.pack("