From b816dca3ed06da3a8fc70e1b48c0116986902f20 Mon Sep 17 00:00:00 2001 From: Biao Lu Date: Thu, 9 Nov 2023 21:12:30 +0800 Subject: [PATCH] image-builder: fix incorrect part start position The 'part_start' of image and dax_image should exactly specify the same location, according to the parted documentation, to exactly specify the location, the units of start and end should use MiB. https://www.gnu.org/software/parted/manual/parted.html#IEC-binary-units Fixes: #8435 Signed-off-by: Biao Lu --- tools/osbuilder/image-builder/image_builder.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/osbuilder/image-builder/image_builder.sh b/tools/osbuilder/image-builder/image_builder.sh index 24381ff4ec65..50264d514681 100755 --- a/tools/osbuilder/image-builder/image_builder.sh +++ b/tools/osbuilder/image-builder/image_builder.sh @@ -406,15 +406,20 @@ create_disk() { # The partition is the rootfs content info "Creating partitions" + if [ "${rootfs_end}" == "-1" ]; then + rootfs_end_unit="s" + else + rootfs_end_unit="MiB" + fi if [ "${MEASURED_ROOTFS}" == "yes" ]; then info "Creating partitions with hash device" # The hash data will take less than one percent disk space to store hash_start=$(echo $img_size | awk '{print $1 * 0.99}' |cut -d $(locale decimal_point) -f 1) - partition_param="mkpart primary ${fs_type} ${part_start}M ${hash_start}M " - partition_param+="mkpart primary ${fs_type} ${hash_start}M ${rootfs_end}M " + partition_param="mkpart primary ${fs_type} ${part_start}MiB ${hash_start}MiB " + partition_param+="mkpart primary ${fs_type} ${hash_start}MiB ${rootfs_end}${rootfs_end_unit} " partition_param+="set 1 boot on" else - partition_param="mkpart primary ${fs_type} ${part_start}M ${rootfs_end}M" + partition_param="mkpart primary ${fs_type} ${part_start}MiB ${rootfs_end}${rootfs_end_unit}" fi parted -s -a optimal "${image}" -- \