From 7e427814b9fdf21d0fec9081683435a0403005e8 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 3 Feb 2021 17:42:04 +0100 Subject: [PATCH] Fix partition resize for MBR for all sizes (#1193) (#1204) It seems that Busybox shell (ash) cannot calculate the disk size properly probably due to integer overflow. Use jq to calculate the last usable LBA which seems to be able to handle large integers. --- buildroot-external/rootfs-overlay/usr/libexec/hassos-expand | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/buildroot-external/rootfs-overlay/usr/libexec/hassos-expand b/buildroot-external/rootfs-overlay/usr/libexec/hassos-expand index f3fef3ad2..3b39fc390 100755 --- a/buildroot-external/rootfs-overlay/usr/libexec/hassos-expand +++ b/buildroot-external/rootfs-overlay/usr/libexec/hassos-expand @@ -31,8 +31,7 @@ else # For MBR, we have to calculate the last usable sector by ourselfs DEVICE_SIZE=$(blockdev --getsize64 "${DEVICE_ROOT}") - SECTOR_SIZE=$(echo "${PART_TABLE}" | jq -r '.partitiontable.sectorsize') - LAST_USABLE_LBA="$((DEVICE_SIZE / SECTOR_SIZE))" + LAST_USABLE_LBA=$(echo "${PART_TABLE}" | jq -r "${DEVICE_SIZE} / .partitiontable.sectorsize") fi echo "[INFO] Last usable logical block ${LAST_USABLE_LBA}"