From 40dfee985554fe71b3a6d1675c678ded6b01aad6 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Thu, 18 Jul 2019 19:45:02 +0200 Subject: [PATCH] assemblers/qcow2: don't rely on partition loopback devices Create a loopback device for the raw partiton, rather than relying on the partition devices the kernel puts in /dev. This requires us to specify the part_msdos module directly as grub2-install now seems unable to detect the partition table type. Signed-off-by: Tom Gundersen --- assemblers/io.weldr.qcow2 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/assemblers/io.weldr.qcow2 b/assemblers/io.weldr.qcow2 index 8171cfa5..6e2d946b 100755 --- a/assemblers/io.weldr.qcow2 +++ b/assemblers/io.weldr.qcow2 @@ -72,11 +72,12 @@ def main(tree, output_dir, options): f"{int(partition_size / 1024)}k"], input="y", encoding='utf-8', check=True) # Mount the created image as a loopback device - with loop_device(image, size) as loop, \ - mount(f"{loop}p1", mountpoint): + with loop_device(image, partition_offset) as loop_block, \ + loop_device(image, partition_size, partition_offset) as loop_part, \ + mount(loop_part, mountpoint): # Install grub2 into the boot sector of the image, and copy the grub2 imagise into /boot/grub2 with mount_api(mountpoint): - subprocess.run(["chroot", mountpoint, "grub2-install", "--no-floppy", "--target", "i386-pc", loop], + subprocess.run(["chroot", mountpoint, "grub2-install", "--no-floppy", "--modules=part_msdos", "--target=i386-pc", loop_block], check=True) subprocess.run(["qemu-img", "convert", "-O", "qcow2", "-c", image, f"{output_dir}/{filename}"], check=True)