public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] If expand last partition fails, unsupervised systems reboot
@ 2022-12-13  6:21 roberto.foglietta
  0 siblings, 0 replies; only message in thread
From: roberto.foglietta @ 2022-12-13  6:21 UTC (permalink / raw)
  To: isar-users; +Cc: roberto.foglietta

From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>

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

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../expand-on-first-boot/files/expand-last-partition.sh     | 6 ++++++
 1 file changed, 6 insertions(+)

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 e314f70..46f3019 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,6 +23,7 @@ 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
+	trap - EXIT
 	exit 1
 fi
 
@@ -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
 
@@ -73,3 +77,5 @@ case $(lsblk -fno FSTYPE "${LAST_PART}") in
 		umount $tmp/btrfs && rmdir $tmp/btrfs
 		;;
 esac
+
+trap - EXIT
-- 
2.34.1


https://16F0H.trk.elasticemail.com/tracking/unsubscribe?d=k8b5tU6T3wzslpuxK4LJeIK0teDer-E0YhqiiD6-xRlYeYHHXmReVBuTI40TvZtKXtFA3zy8svB8aEFPpT3VZDtcG4yRxgul7f12efFHZyV10

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-13  6:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13  6:21 [PATCH] If expand last partition fails, unsupervised systems reboot roberto.foglietta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox