start the first partition with a 32MiB "offset"
Since Kickstart no longer has the '--start' and '--end' options for the
partition command, we need to do this manually.
3e655d4c5d
Why do we need to do this at all? Well, because some SoCs read U-Boot
from the boot media at a particular offset. Normally, the first
partition starts at 2048 (with fdisk) or at 8192 (if using Kickstart)
which means that something from the first partition will be erased, or
data written here will eventually overwrite U-Boot if U-Boot is greater
than 2MiB.
Looking at the biggest file in 'uboot-images-armv8' package, the biggest
file is ~12 MiB so the double of closest 2's exponent results in 32MiB.
This commit is contained in:
parent
cbbee2dbbe
commit
2d2ee0a676
@ -15,6 +15,41 @@ for COMMAND in "${COMMANDS_TO_CHECK[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
function create_new_image {
|
||||
UBOOT_MAX_SIZE='32'
|
||||
EFI_END=$(( 512 + 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}"
|
||||
|
||||
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
|
||||
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"
|
||||
sync; sync; sync; sync;
|
||||
sleep 10
|
||||
|
||||
losetup -d "${LOOPBACK_02}"
|
||||
losetup -d "${LOOPBACK_01}"
|
||||
mv "${NEW_IMAGE_NAME}" "${IMAGE_NAME}"
|
||||
sync; sync; sync; sync;
|
||||
sleep 10
|
||||
}
|
||||
|
||||
appliance-creator \
|
||||
--config "${KICKSTART_FILE}" \
|
||||
--name "${APPLIANCE_NAME}" \
|
||||
@ -28,6 +63,10 @@ appliance-creator \
|
||||
if [[ -d "${APPLIANCE_NAME}" ]]; then
|
||||
pushd "${APPLIANCE_NAME}" || exit 1
|
||||
mv "${APPLIANCE_NAME}-sda.raw" "${IMAGE_NAME}"
|
||||
create_new_image
|
||||
zstd --compress -9 "${IMAGE_NAME}"
|
||||
sha512sum -- *.raw* > SHA512SUMS
|
||||
sha256sum -- *.raw* > SHA256SUMS
|
||||
popd || exit 0
|
||||
else
|
||||
>&2 echo "$0: ERROR: unable to find the appliance output directory"
|
||||
|
Loading…
Reference in New Issue
Block a user