From 15a158431a5c6c781cacac626f78f2bb5dc263c6 Mon Sep 17 00:00:00 2001 From: Pratham Patel Date: Tue, 17 Oct 2023 09:16:01 +0530 Subject: [PATCH] fix incorrect partition layout because of size mismatch of /boot/efi --- create-image.sh | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/create-image.sh b/create-image.sh index 907f901..c95b655 100755 --- a/create-image.sh +++ b/create-image.sh @@ -17,32 +17,28 @@ done function create_new_image { UBOOT_MAX_SIZE='32' - EFI_END=$(( 512 + UBOOT_MAX_SIZE )) + EFI_END=$(( 256 + UBOOT_MAX_SIZE )) BOOT_START=$(( EFI_END + 1 )) BOOT_END=$(( BOOT_START + 1024 )) ROOT_START=$(( BOOT_END + 1 )) IMAGE_SIZE=$(( $(stat -c '%s' "${IMAGE_NAME}") / 1024 / 1024 )) NEW_IMAGE_NAME="${IMAGE_NAME}.new" - truncate -s "$(( IMAGE_SIZE + UBOOT_MAX_SIZE ))"MiB "${NEW_IMAGE_NAME}" + truncate -s "$(( IMAGE_SIZE + (UBOOT_MAX_SIZE * 2) ))"MiB "${NEW_IMAGE_NAME}" LOOPBACK_01=$(losetup -f -P --show "${IMAGE_NAME}") LOOPBACK_02=$(losetup -f -P --show "${NEW_IMAGE_NAME}") - parted -s "${LOOPBACK_02}" mklabel gpt - parted -s "${LOOPBACK_02}" mkpart efi fat32 "${UBOOT_MAX_SIZE}"MiB "${EFI_END}"MiB - parted -s "${LOOPBACK_02}" mkpart boot ext4 "${BOOT_START}"MiB "${BOOT_END}"MiB - parted -s "${LOOPBACK_02}" mkpart root ext4 "${ROOT_START}"MiB 100% - parted -s "${LOOPBACK_02}" set 1 boot on + parted -s "${LOOPBACK_02}" -- mklabel gpt + parted -s "${LOOPBACK_02}" -- mkpart rockyefi fat32 "${UBOOT_MAX_SIZE}"MiB "${EFI_END}"MiB + parted -s "${LOOPBACK_02}" -- mkpart rockyboot ext4 "${BOOT_START}"MiB "${BOOT_END}"MiB + parted -s "${LOOPBACK_02}" -- mkpart rockyroot ext4 "${ROOT_START}"MiB 100% sync; sync; sync; sync; sleep 10 hdparm -z "${LOOPBACK_02}" - dd bs=4M conv=sync status=progress if="${LOOPBACK_01}p1" if="${LOOPBACK_02}p1" - dd bs=4M conv=sync status=progress if="${LOOPBACK_01}p2" if="${LOOPBACK_02}p2" - dd bs=4M conv=sync status=progress if="${LOOPBACK_01}p3" if="${LOOPBACK_02}p3" - cat << EOF | fdisk "${LOOPBACK_02}" - w -EOF + dd bs=4M conv=sync status=progress if="${LOOPBACK_01}p3" of="${LOOPBACK_02}p3" + dd bs=4M conv=sync status=progress if="${LOOPBACK_01}p2" of="${LOOPBACK_02}p2" + dd bs=4M conv=sync status=progress if="${LOOPBACK_01}p1" of="${LOOPBACK_02}p1" sync; sync; sync; sync; sleep 10