From ecaed3bbfa87b09451bb1b6eddbccc451d8902c7 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Thu, 27 Jun 2019 16:22:30 +0200 Subject: [PATCH] stages/grub2: don't set up a partition table We only need the filesystem with the correct fs-UUID to chroot into, there is no need to set up a whole partition table. Signed-off-by: Tom Gundersen --- stages/io.weldr.grub2 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/stages/io.weldr.grub2 b/stages/io.weldr.grub2 index 0aad6bba..f9574dcf 100755 --- a/stages/io.weldr.grub2 +++ b/stages/io.weldr.grub2 @@ -36,7 +36,7 @@ def mount_api(dest): @contextlib.contextmanager def loop_device(image): - r = subprocess.run(["losetup", "--partscan", "--show", "--find", image], stdout=subprocess.PIPE, encoding="utf-8", check=True) + r = subprocess.run(["losetup", "--show", "--find", image], stdout=subprocess.PIPE, encoding="utf-8", check=True) loop = r.stdout.strip() try: yield loop @@ -64,20 +64,16 @@ def main(tree, input_dir, options): size = int(math.ceil(tree_size(tree) * 1.2 / 512) * 512) subprocess.run(["truncate", "--size", str(size), image], check=True) - # Set up the partition table of the image - partition_table = "label: mbr\nlabel-id: {partition_table_id}\nbootable, type=83" - subprocess.run(["sfdisk", "-q", image], input=partition_table, encoding='utf-8', check=True) - # Mount the created image as a loopback device with loop_device(image) as loop: # Populate the first partition of the image with an ext4 fs and fill it with the contents of the # tree we are operating on. - subprocess.run(["mkfs.ext4", "-d", tree, "-U", root_fs_uuid, f"{loop}p1"], check=True) + subprocess.run(["mkfs.ext4", "-d", tree, "-U", root_fs_uuid, loop], check=True) # Mount the partition. The contents is now exactly the same as the input tree, with the only # difference that when it inspects its own filesystem it will see what has been configured, # rather than a tmpfs. - with mount(f"{loop}p1", mountpoint): + with mount(loop, mountpoint): # Run the tool in the image we created. with mount_api(mountpoint): subprocess.run(["chroot", mountpoint, "grub2-mkconfig", "--output=/boot/grub2/grub.cfg"], check=True)