From 4112390519d01a7fb28d2a326002dff876786190 Mon Sep 17 00:00:00 2001 From: "Roberto A. Foglietta" Date: Tue, 13 Dec 2022 07:14:25 +0100 Subject: [PATCH 3/7] If expand last partition fails, unsupervised systems reboot Improvement for unsupervised embedded devices which need to reboot if expand last partition fails because a under-provided system should not even complete the boot in the field in order to avoid functioning failures at unexpected future time. This patch do not affect the previous behaviour because requirs /etc/unsupervised This patch applies after the following other patches: - In expand last partition script btrfs support added - In expand last partition wait for udev have finished v2: if there is no partition table exit 0 instead of exit 1 Signed-off-by: Roberto A. Foglietta --- .../expand-on-first-boot/files/expand-last-partition.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh index f5bcad1..2c52b16 100755 --- a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh +++ b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh @@ -9,6 +9,8 @@ set -e +test -e /etc/unsupervised && trap reboot EXIT + udevadm settle ROOT_DEV="$(findmnt / -o source -n)" @@ -21,7 +23,8 @@ fi BOOT_DEV="$(echo "${ROOT_DEV}" | sed 's/p\?[0-9]*$//')" if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then echo "Boot device equals root device - no partitioning found" >&2 - exit 1 + trap - EXIT + exit 0 fi # this value is in blocks. Normally a block has 512 bytes. @@ -37,6 +40,7 @@ done MINIMAL_SIZE=$((ALL_PARTS_SIZE + BUFFER_SIZE)) if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then echo "Disk is practically already full, doing nothing." >&2 + trap - EXIT exit 0 fi @@ -72,3 +76,5 @@ case $(lsblk -fno FSTYPE "${LAST_PART}") in umount $tmpdir && rmdir $tmpdir ;; esac + +trap - EXIT -- 2.34.1