From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
To: isar-users@googlegroups.com
Subject: [PATCH v2] If expand last partition fails, unsupervised systems reboot
Date: Wed, 14 Dec 2022 08:52:00 +0100 [thread overview]
Message-ID: <CAJGKYO4jQ=b43n+qASC0U8bAzON6R0WSgJhzWhR3Or9ZXyZBKA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1200 bytes --]
Hi all,
in the expand last partition script I read this code
ROOT_DEV="$(findmnt / -o source -n)"
[...]
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
this means that there are no partitions because the boot partition
/dev/sda is equal to root partition /dev/sda, which happens only when
there is no partition table.
roberto$ echo /dev/sda2 | sed 's/p\?[0-9]*$//'
/dev/sda (which is different than /dev/sda2)
roberto$ echo /dev/sda | sed 's/p\?[0-9]*$//'
/dev/sda (there is no partition table)
That's ok but not exit 1 because IMHO, it will retry again the next
time but nothing will change the next time so it will continue to try
and fail at every boot. Because one-time-only in systemd means
one-successful-time-only and exit 1 prevents disabling the operation.
So, exit 0 would be the correct code to execute and this is the reason
because I removed the trap which would make an unsupervised system
reboot.
The patch v2 has been sent using the elastic mail SMTP and went in
moderation, here in attachment.
Best regards, R-
[-- Attachment #2: v2-0001-If-expand-last-partition-fails-unsupervised-syste.patch --]
[-- Type: text/x-patch, Size: 2110 bytes --]
From 14cff2bc150b1be77d5de4253ac3e92df2b4b0f9 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Tue, 13 Dec 2022 07:14:25 +0100
Subject: [PATCH v2] 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 <roberto.foglietta@gmail.com>
---
.../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
next reply other threads:[~2022-12-14 7:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 7:52 Roberto A. Foglietta [this message]
2022-12-14 8:47 ` Henning Schild
2022-12-14 9:05 ` Henning Schild
2022-12-14 9:24 ` Roberto A. Foglietta
2022-12-14 9:26 ` Roberto A. Foglietta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJGKYO4jQ=b43n+qASC0U8bAzON6R0WSgJhzWhR3Or9ZXyZBKA@mail.gmail.com' \
--to=roberto.foglietta@gmail.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox