From d9488e5f8bdff9ddaccf2ae628e48b8085fc0463 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Wed, 26 Jun 2019 12:57:20 +0200 Subject: [PATCH] losetup: make sure image sizes are multiples of 512K sectors Signed-off-by: Tom Gundersen --- assemblers/io.weldr.qcow2 | 3 ++- stages/io.weldr.grub2 | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/assemblers/io.weldr.qcow2 b/assemblers/io.weldr.qcow2 index 12f396d9..b055ae71 100755 --- a/assemblers/io.weldr.qcow2 +++ b/assemblers/io.weldr.qcow2 @@ -2,6 +2,7 @@ import contextlib import json +import math import os import shutil import subprocess @@ -54,7 +55,7 @@ def main(tree, input_dir, output_dir, options): mountpoint = f"{workdir}/mnt" # Create an empty image file of the right size - size = int(tree_size(tree) * 1.2) + 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 diff --git a/stages/io.weldr.grub2 b/stages/io.weldr.grub2 index fb626194..a03f31b9 100755 --- a/stages/io.weldr.grub2 +++ b/stages/io.weldr.grub2 @@ -2,6 +2,7 @@ import contextlib import json +import math import os import shutil import subprocess @@ -58,7 +59,7 @@ def main(tree, input_dir, options): mountpoint = f"{workdir}/mnt" # Create an empty image file of the right size - size = int(tree_size(tree) * 1.2) + 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