* [PATCHSET] expand last partition script and its usage
@ 2022-12-15 18:06 Roberto A. Foglietta
2022-12-15 18:27 ` Roberto A. Foglietta
0 siblings, 1 reply; 6+ messages in thread
From: Roberto A. Foglietta @ 2022-12-15 18:06 UTC (permalink / raw)
To: isar-users; +Cc: Anton Mikanovich
[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]
Hi all,
all these patches are just sent by elastic mail SMTP and they are
waiting in moderation.
* 9ab1ca3 - In expand last partition few improvements and a bugfix
* 565e850 - In expand last partition trap exitnlog EXIT logs with simpler code
* b207566 - The expand last partition might support full volumes also, to test
* 0e1748e - In expand last partition checking the size is useless
* 4112390 - If expand last partition fails, unsupervised systems reboot
* f5a72cd - In expand last partition script btrfs support added
* d3aded1 - In expand last partition wait for udev have finished
I am going to attach them for immediate reviewing and they can also be
found in this branch
https://github.com/robang74/isar/tree/rafnext
or they can be found in this branch which has been merged with the
current ISAR next head
https://github.com/robang74/isar/tree/next
Files changed list:
meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
Best regards, R-
[-- Attachment #2: 0007-In-expand-last-partition-few-improvements-and-a-bugf.patch --]
[-- Type: text/x-patch, Size: 1867 bytes --]
From 9ab1ca3d1f980b3f05759ca2d2f3db6abaae11ea Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Thu, 15 Dec 2022 18:40:28 +0100
Subject: [PATCH 7/7] In expand last partition few improvements and a bugfix
Some improvements and a bugfix in expanding last partition.
Improvements: filesystems ext2 and ext3 also supported, warning in dmesg in
case of unsupported filesystem, the variable tmpdir is used with double
quotes even if unneeded but be consistent with the original script notation.
Bugfix: even if btrfs resize fails, umount the last partition and return error.
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../files/expand-last-partition.sh | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
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 1c8abf0..5cd6fc3 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
@@ -84,11 +84,16 @@ fi
export EXT2FS_NO_MTAB_OK=1
case $(lsblk -fno FSTYPE "${LAST_PART}") in
- ext4) resize2fs "${LAST_PART}"
+ ext[234]) resize2fs "${LAST_PART}"
;;
- btrfs) tmpdir=$(mktemp -d -p "$TMPDIR" btrfs.XXXX || mktemp -d -p "/dev/shm" btrfs.XXXX)
- mount "${LAST_PART}" $tmpdir
- btrfs filesystem resize max $tmpdir
- umount $tmpdir && rmdir $tmpdir
+ btrfs) err=0
+ tmpdir=$(mktemp -d -p "$TMPDIR" btrfs.XXXX || \
+ mktemp -d -p "/dev/shm" btrfs.XXXX)
+ mount "${LAST_PART}" "$tmpdir"
+ btrfs filesystem resize max "$tmpdir" || err=1
+ umount "$tmpdir" && rmdir "$tmpdir"
+ exit $err
+ ;;
+ *) echo "WARNING: $0 unsupported filesystem" >/dev/kmsg || true
;;
esac
--
2.34.1
[-- Attachment #3: 0004-In-expand-last-partition-checking-the-size-is-useles.patch --]
[-- Type: text/x-patch, Size: 2477 bytes --]
From 0e1748ebcd8641943b056c10c266a7ca6841271a Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Wed, 14 Dec 2022 12:37:26 +0100
Subject: [PATCH 4/7] In expand last partition checking the size is useless
code maintenance, superflous operations commented, kept for the future
Tests shown that resize in full a ext4 or btrfs partition/filesystem does not
hurt and does not report a failure, so nothing changes without the size check
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../files/expand-last-partition.sh | 34 +++++++++++--------
1 file changed, 19 insertions(+), 15 deletions(-)
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 2c52b16..4d36733 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
@@ -27,22 +27,26 @@ if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then
exit 0
fi
-# this value is in blocks. Normally a block has 512 bytes.
-BUFFER_SIZE=32768
-BOOT_DEV_NAME=${BOOT_DEV##*/}
-DISK_SIZE="$(cat /sys/class/block/"${BOOT_DEV_NAME}"/size)"
-ALL_PARTS_SIZE=0
-for PARTITION in /sys/class/block/"${BOOT_DEV_NAME}"/"${BOOT_DEV_NAME}"*; do
- PART_SIZE=$(cat "${PARTITION}"/size)
- ALL_PARTS_SIZE=$((ALL_PARTS_SIZE + PART_SIZE))
-done
+# full resizing of ext4 and btrfs does not fail nor hurt but supporting more
+# filesystems in future might change this condition, so commenting this code
+useless_for_now() {
+ # this value is in blocks. Normally a block has 512 bytes.
+ BUFFER_SIZE=32768
+ BOOT_DEV_NAME=${BOOT_DEV##*/}
+ DISK_SIZE="$(cat /sys/class/block/"${BOOT_DEV_NAME}"/size)"
+ ALL_PARTS_SIZE=0
+ for PARTITION in /sys/class/block/"${BOOT_DEV_NAME}"/"${BOOT_DEV_NAME}"*; do
+ PART_SIZE=$(cat "${PARTITION}"/size)
+ ALL_PARTS_SIZE=$((ALL_PARTS_SIZE + PART_SIZE))
+ 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
+ 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
+}
LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
--
2.34.1
[-- Attachment #4: 0006-In-expand-last-partition-trap-exitnlog-EXIT-logs-wit.patch --]
[-- Type: text/x-patch, Size: 1793 bytes --]
From 565e8505097e490239a91c106695896f3f058f9b Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Thu, 15 Dec 2022 17:51:17 +0100
Subject: [PATCH 6/7] In expand last partition trap exitnlog EXIT logs with
simpler code
improvement, the script log at exit with the status of completion and its full path
in this way the - in case of failure - the user will find in dmesg the error and
also the script full path to debug. It uses /dev/kmsg to log. Code simplified.
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../files/expand-last-partition.sh | 20 ++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
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 90e8d93..1c8abf0 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
@@ -7,9 +7,22 @@
#
# SPDX-License-Identifier: MIT
-set -e
+exitnlog() {
+ ec=$?
+ set +e
+ if [ "$ec" != "0" ]; then
+ echo "ERROR: $0 failed"
+ else
+ echo "$0 succeded"
+ fi >/dev/kmsg
+ if [ "$ec" != "0" -a -e /etc/unsupervised ]; then
+ reboot
+ fi
+}
+export -f exitnlog
+trap exitnlog EXIT
-test -e /etc/unsupervised && trap reboot EXIT
+set -e
udevadm settle
@@ -36,7 +49,6 @@ useless_for_now() {
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
}
@@ -80,5 +92,3 @@ case $(lsblk -fno FSTYPE "${LAST_PART}") in
umount $tmpdir && rmdir $tmpdir
;;
esac
-
-trap - EXIT
--
2.34.1
[-- Attachment #5: 0005-The-expand-last-partition-might-support-full-volumes.patch --]
[-- Type: text/x-patch, Size: 3552 bytes --]
From b20756675715b02db3515b4564b85cf4b3c95ff4 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Wed, 14 Dec 2022 12:51:48 +0100
Subject: [PATCH 5/7] The expand last partition might support full volumes
also, to test
Improvement, expansion of unpartitioned volumes supported also but to test
TODO, 14.12.2022: this change should be tested with a single volume system
preliminary tests shown that ext4 and btrfs entire volumes cam be resized
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../files/expand-last-partition.sh | 48 +++++++++----------
1 file changed, 24 insertions(+), 24 deletions(-)
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 4d36733..90e8d93 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
@@ -20,13 +20,6 @@ if [ -n "${ROOT_DEV_SLAVE}" ]; then
ROOT_DEV=/dev/${ROOT_DEV_SLAVE##*/}
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 0
-fi
-
# full resizing of ext4 and btrfs does not fail nor hurt but supporting more
# filesystems in future might change this condition, so commenting this code
useless_for_now() {
@@ -46,26 +39,33 @@ useless_for_now() {
trap - EXIT
exit 0
fi
-}
+}
-LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
+# TODO, 14.12.2022: this change should be tested with a single volume system
+# preliminary tests shown that ext4 and btrfs entire volumes cam be resized
+BOOT_DEV="$(echo "${ROOT_DEV}" | sed 's/p\?[0-9]*$//')"
+if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then
+ LAST_PART="${BOOT_DEV}"
+else
+ LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
-# Transform the partition table as follows:
-#
-# - Remove any 'last-lba' header so sfdisk uses the entire available space.
-# - If this partition table is MBR and an extended partition container (EBR)
-# exists, we assume this needs to be expanded as well; remove its size
-# field so sfdisk expands it.
-# - For the previously fetched last partition, also remove the size field so
-# sfdisk expands it.
-sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
- grep -v last-lba | \
- sed 's|^\(.*, \)size=[^,]*, \(type=[f5]\)$|\1\2|' | \
- sed 's|^\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \
- sfdisk --force "${BOOT_DEV}"
+ # Transform the partition table as follows:
+ #
+ # - Remove any 'last-lba' header so sfdisk uses the entire available space.
+ # - If this partition table is MBR and an extended partition container (EBR)
+ # exists, we assume this needs to be expanded as well; remove its size
+ # field so sfdisk expands it.
+ # - For the previously fetched last partition, also remove the size field so
+ # sfdisk expands it.
+ sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
+ grep -v last-lba | \
+ sed 's|^\(.*, \)size=[^,]*, \(type=[f5]\)$|\1\2|' | \
+ sed 's|^\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \
+ sfdisk --force "${BOOT_DEV}"
-# Inform the kernel about the partitioning change
-partx -u "${LAST_PART}"
+ # Inform the kernel about the partitioning change
+ partx -u "${LAST_PART}"
+fi
# Do not fail resize2fs if no mtab entry is found, e.g.,
# when using systemd mount units.
--
2.34.1
[-- Attachment #6: 0003-If-expand-last-partition-fails-unsupervised-systems-.patch --]
[-- Type: text/x-patch, Size: 2111 bytes --]
From 4112390519d01a7fb28d2a326002dff876786190 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 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 <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
[-- Attachment #7: 0001-In-expand-last-partition-wait-for-udev-have-finished.patch --]
[-- Type: text/x-patch, Size: 2292 bytes --]
From d3aded1198e598b2c0612f2c0528c6aab26d98c2 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Mon, 12 Dec 2022 21:14:26 +0100
Subject: [PATCH 1/7] In expand last partition wait for udev have finished
bugfix, expand last partition, wait for udev completion
On some hardware the udev did not created the links to the disk partitions
while this script is working thus it fails. This patch fixes that cases.
v2: as underlined by Tobias this script requires systemd-udevd.service and
it can safely runs only after that service has been started otherwise might
fail. This dependency will reorder the boot procedure but not slow down it
unless the hardware is slow to get mapped by udev but in that case resize
the last partition would have failed. Thus, no regression are expected.
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../expand-on-first-boot/files/expand-last-partition.sh | 2 ++
.../expand-on-first-boot/files/expand-on-first-boot.service | 2 ++
2 files changed, 4 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 57055cc..4d55645 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
+udevadm settle
+
ROOT_DEV="$(findmnt / -o source -n)"
ROOT_DEV_NAME=${ROOT_DEV##*/}
ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth 1 -print -quit 2>/dev/null || true)
diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
index fda5001..2c120c4 100644
--- a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
+++ b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
@@ -7,7 +7,9 @@
Description=Expand last partition
DefaultDependencies=no
Conflicts=shutdown.target
+Requires=systemd-udevd.service
After=systemd-remount-fs.service
+After=systemd-udevd.service
Before=local-fs-pre.target shutdown.target
ConditionPathIsReadWrite=/etc
--
2.34.1
[-- Attachment #8: 0002-In-expand-last-partition-script-btrfs-support-added.patch --]
[-- Type: text/x-patch, Size: 3998 bytes --]
From f5a72cdfd3f429895893412b0c835edba223c608 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Sat, 10 Dec 2022 04:13:42 +0100
Subject: [PATCH 2/7] In expand last partition script btrfs support added
Improvement, expand-on-first-boot: support for btrfs added
v2: the mount point for btrfs filesystem to resize is under /dev/shm
by default but a variable defined in the running environment can
change the temporary directory path. The /dev/shm has been chosen
because in some systems /tmp can be on a RO root filesystem and
/tmp not yet mounted with tmpfs. This requires the system to have
/dev/shm configured into the kernel.
v3: the previous version was using a bashism but the shebang is /bin/sh
this means that the script will fail in a customized system in which /bin/sh
do not link to bash or bash is not available.
v4: Felix suggested using mktemp for the temporary directory in which to
mount the btrfs filesystem to resize. The default path /tmp could be changed
using the variable TMPDIR to set in the running environment.
v5: typo fixes into the patch description
v6: mktemp does a reasonable second try with -p /dev/shm before failing
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../expand-on-first-boot_1.2.bb | 2 +-
.../files/expand-last-partition.sh | 37 ++++++-------------
2 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
index 0996000..fe7b72b 100644
--- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
+++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
@@ -10,7 +10,7 @@ inherit dpkg-raw
DESCRIPTION = "This service grows the last partition to the full medium during first boot"
MAINTAINER = "isar-users <isar-users@googlegroups.com>"
-DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux"
+DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux, btrfs-progs"
SRC_URI = " \
file://expand-on-first-boot.service \
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 4d55645..f5bcad1 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
@@ -59,29 +59,16 @@ sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
# Inform the kernel about the partitioning change
partx -u "${LAST_PART}"
-# this is for debian stretch or systemd < 236
-if [ ! -x /lib/systemd/systemd-growfs ]; then
- # Do not fail resize2fs if no mtab entry is found, e.g.,
- # when using systemd mount units.
- export EXT2FS_NO_MTAB_OK=1
+# Do not fail resize2fs if no mtab entry is found, e.g.,
+# when using systemd mount units.
+export EXT2FS_NO_MTAB_OK=1
- resize2fs "${LAST_PART}"
- exit 0
-fi
-
-if grep -q x-systemd.growfs /etc/fstab; then
- echo "Found x-systemd.growfs option in /etc/fstab, won't call it explicitly." >&2
- exit 0
-fi
-
-# mount $LAST_PART out of tree, so we won't conflict with other mounts
-MOUNT_POINT=$(mktemp -d -p /mnt "$(basename "$0").XXXXXXXXXX")
-if [ ! -d "${MOUNT_POINT}" ]; then
- echo "Cannot create temporary mount point ${MOUNT_POINT}." >&2
- exit 1
-fi
-
-mount "${LAST_PART}" "${MOUNT_POINT}"
-/lib/systemd/systemd-growfs "${MOUNT_POINT}"
-umount "${MOUNT_POINT}"
-rmdir "${MOUNT_POINT}"
+case $(lsblk -fno FSTYPE "${LAST_PART}") in
+ ext4) resize2fs "${LAST_PART}"
+ ;;
+ btrfs) tmpdir=$(mktemp -d -p "$TMPDIR" btrfs.XXXX || mktemp -d -p "/dev/shm" btrfs.XXXX)
+ mount "${LAST_PART}" $tmpdir
+ btrfs filesystem resize max $tmpdir
+ umount $tmpdir && rmdir $tmpdir
+ ;;
+esac
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHSET] expand last partition script and its usage
2022-12-15 18:06 [PATCHSET] expand last partition script and its usage Roberto A. Foglietta
@ 2022-12-15 18:27 ` Roberto A. Foglietta
2022-12-15 23:00 ` Roberto A. Foglietta
0 siblings, 1 reply; 6+ messages in thread
From: Roberto A. Foglietta @ 2022-12-15 18:27 UTC (permalink / raw)
To: isar-users; +Cc: Anton Mikanovich
[-- Attachment #1: Type: text/plain, Size: 450 bytes --]
On Thu, 15 Dec 2022 at 19:06, Roberto A. Foglietta
<roberto.foglietta@gmail.com> wrote:
>
> Hi all,
>
> all these patches are just sent by elastic mail SMTP and they are
> waiting in moderation.
>
> * 9ab1ca3 - In expand last partition few improvements and a bugfix
Version 2 of the last patch
* 082d8af - In expand last partition few improvements and a bugfix
I forgot to mention Henning on which code I took inspiration from.
Best regards, R-
[-- Attachment #2: v2-0001-In-expand-last-partition-wait-for-udev-have-finis.patch --]
[-- Type: text/x-patch, Size: 2295 bytes --]
From d3aded1198e598b2c0612f2c0528c6aab26d98c2 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Mon, 12 Dec 2022 21:14:26 +0100
Subject: [PATCH v2 1/7] In expand last partition wait for udev have finished
bugfix, expand last partition, wait for udev completion
On some hardware the udev did not created the links to the disk partitions
while this script is working thus it fails. This patch fixes that cases.
v2: as underlined by Tobias this script requires systemd-udevd.service and
it can safely runs only after that service has been started otherwise might
fail. This dependency will reorder the boot procedure but not slow down it
unless the hardware is slow to get mapped by udev but in that case resize
the last partition would have failed. Thus, no regression are expected.
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../expand-on-first-boot/files/expand-last-partition.sh | 2 ++
.../expand-on-first-boot/files/expand-on-first-boot.service | 2 ++
2 files changed, 4 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 57055cc..4d55645 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
+udevadm settle
+
ROOT_DEV="$(findmnt / -o source -n)"
ROOT_DEV_NAME=${ROOT_DEV##*/}
ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth 1 -print -quit 2>/dev/null || true)
diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
index fda5001..2c120c4 100644
--- a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
+++ b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
@@ -7,7 +7,9 @@
Description=Expand last partition
DefaultDependencies=no
Conflicts=shutdown.target
+Requires=systemd-udevd.service
After=systemd-remount-fs.service
+After=systemd-udevd.service
Before=local-fs-pre.target shutdown.target
ConditionPathIsReadWrite=/etc
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHSET] expand last partition script and its usage
2022-12-15 18:27 ` Roberto A. Foglietta
@ 2022-12-15 23:00 ` Roberto A. Foglietta
2022-12-16 8:14 ` Roberto A. Foglietta
0 siblings, 1 reply; 6+ messages in thread
From: Roberto A. Foglietta @ 2022-12-15 23:00 UTC (permalink / raw)
To: isar-users
Cc: Anton Mikanovich, Henning Schild, Moessbauer, Felix, Schmidl,
Tobias, Joe MacDonald
[-- Attachment #1: Type: text/plain, Size: 2275 bytes --]
Hi all,
this is the single patch for rework and generalisation of last
partition expansion.
As usual has been sent by elastic mail SMTP and it went in moderation.
UPDATE: the unpartition volume resizing has been tested in this way
git clone https://github.com/robang74/isar-nvidia-debian.git
cd isar-nvidia-debian
source .profile
build basic-os
wicshell
cd /boot
cp -arf vmlinuz-5.10.0-19-amd64 initrd.img-5.10.0-19-amd64 /work
exit
wicinst file:image.wic
sudo losetup -P $(losetup -f) image.wic
sudo dd if=/dev/loop3p2 bs=1M > disk.wic
dd if=/dev/zero bs=1 seek=$[4*1024*1024*1024] count=1 oflag=append
conv=notrunc,sparse status=none of=disk.wic
sudo qemu-system-x86_64 --cpu host --enable-kvm -smp 4 -m 1024 -drive
format=raw,file=disk.wic -device sdhci-pci -kernel
build/tmp/work/vmlinuz-5.10.0-19-amd64 -initrd
build/tmp/work/initrd.img-5.10.0-19-amd64 -append "root=/dev/sda
console=ttyS0" --nographic; echo ">>> press ENTER"; read; reset
dmesg | grep expand
df -h
poweroff
Best regards, R-
===========================================
The script has been reworked to simplify its code:
- the last partition free space is not computed anymore because useless
- on exit a function take care of some final tasks and logs in /dev/kmsg
and to extend its functionalities supporting new filesystems:
- filesystem type is managed by a switch-case block of code
- temporary directory to mount is created relying on TMPDIR
- unsupervised systems have the option to reboot because error
- if temporary directory creation fails 2nd try with /dev/shm
- additional ext2, ext3 and btrfs filesystems supported
- udev support: udevadm settle is the first task to run
- unpartitioned volumes are resized as well (tested)
This patch has been created by a collection of 7 patches to be applied on
ilbers ISAR, branch next, commit d26660b724b034b602f3889f55a23cd9be2e87bd
Author: Roberto A. Foglietta <roberto.foglietta@gmail.com>
This code has been developed taking inspiration by suggestions and code from:
Felix Moessbauer <felix.moessbauer@siemens.com>
Tobias Schmidl <tobiasschmidl@siemens.com>
Henning Schild <henning.schild@siemens.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
[-- Attachment #2: 0001-The-expand-last-partition-rework-and-generalisation.patch --]
[-- Type: text/x-patch, Size: 12317 bytes --]
From b41bef462289422e9fedc8d87706e11f267b2c37 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Mon, 12 Dec 2022 21:14:26 +0100
Subject: [PATCH] The expand last partition rework and generalisation
The script has been reowrked to simplify its code:
- the last partition free space is not computed anymore because useless
- on exit a function take care of some final tasks and logs in /dev/kmsg
and to extend its functionalities supporting new filesystems:
- filesystem type is managed by a switch-case block of code
- temporary directory to mount is created relying on TMPDIR
- unsupervised systems have the option to reboot because error
- if temporary directory creation fails 2nd try with /dev/shm
- additional ext2, ext3 and btrfs filesystems supported
- udev support: udevadm settle is the first task to run
- unpartitioned volumes are resized as well (tested)
This patch has been created by a collection of 7 patches to be applied on
ilbers ISAR, branch next, commit d26660b724b034b602f3889f55a23cd9be2e87bd
Author: Roberto A. Foglietta <roberto.foglietta@gmail.com>
This code has been developed taking inspiration by suggestions and code from:
Felix Moessbauer <felix.moessbauer@siemens.com>
Tobias Schmidl <tobiasschmidl@siemens.com>
Henning Schild <henning.schild@siemens.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
= 1/7 == In expand last partition wait for udev have finished =================
bugfix, expand last partition, wait for udev completion
On some hardware the udev did not create the links to the disk partitions
while this script is working thus it fails. This patch fixes those cases.
v2: as underlined by Tobias this script requires systemd-udevd.service and
it can safely run only after that service has been started otherwise it might
fail. This dependency will reorder the boot procedure but not slow down it
unless the hardware is slow to get mapped by udev but in that case resize
the last partition would have failed. Thus, no regression is expected.
= 2/7 == In expand last partition script btrfs support added ==================
Improvement, expand-on-first-boot: support for btrfs added
v2: the mount point for btrfs filesystem to resize is under /dev/shm
by default but a variable defined in the running environment can
change the temporary directory path. The /dev/shm has been chosen
because in some systems /tmp can be on a RO root filesystem and
/tmp not yet mounted with tmpfs. This requires the system to have
/dev/shm configured into the kernel.
v3: the previous version was using a bashism but the shebang is /bin/sh
this means that the script will fail in a customized system in which /bin/sh
do not link to bash or bash is not available.
v4: Felix suggested using mktemp for the temporary directory in which to
mount the btrfs filesystem to resize. The default path /tmp could be changed
using the variable TMPDIR to set in the running environment.
v5: typo fixes into the patch description
v6: mktemp does a reasonable second try with -p /dev/shm before failing
= 3/7 == If expand last partition fails, unsupervised systems reboot ==========
Improvement for unsupervised embedded devices which need to reboot if expanding
last partition fails because an 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 requires
that /etc/unsupervised file exists.
v2: if there is no partition table exit 0 instead of exit 1
= 4/7 == In expand last partition checking the size is useless ================
code maintenance, superfluous operations commented, kept for the future
Tests shown that resize in full a ext4 or btrfs partition/filesystem does not
hurt and does not report a failure, so nothing changes without the size check
= 5/7 == The expand last partition might support full volumes also, to test ==
Improvement, expansion of unpartitioned volumes supported also but to test
DONE, 14.12.2022: this change should be tested with a single volume system
preliminary tests shown that ext4 and btrfs entire volumes cam be resized
= 6/7 == In expand last partition trap exitnlog EXIT logs with simpler code ===
Improvement, the script log at exit with the status of completion and its full
path in this way - in case of failure - the user will find in dmesg the error
and also the script full path to debug. It uses /dev/kmsg to log.
Code simplified.
= 7/7 == In expand last partition few improvements and a bugfix ===============
Some improvements and a bugfix in expanding last partition.
Improvements: filesystems ext2 and ext3 also supported, warning in dmesg in
case of unsupported filesystem, the variable tmpdir is used with double
quotes even if unneeded but be consistent with the original script notation.
Bugfix: even if btrfs resize fails, umount the last partition and return error.
---
.../expand-on-first-boot_1.2.bb | 2 +-
.../files/expand-last-partition.sh | 134 ++++++++++--------
.../files/expand-on-first-boot.service | 2 +
3 files changed, 77 insertions(+), 61 deletions(-)
diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
index 0996000..fe7b72b 100644
--- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
+++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
@@ -10,7 +10,7 @@ inherit dpkg-raw
DESCRIPTION = "This service grows the last partition to the full medium during first boot"
MAINTAINER = "isar-users <isar-users@googlegroups.com>"
-DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux"
+DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux, btrfs-progs"
SRC_URI = " \
file://expand-on-first-boot.service \
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 57055cc..5cd6fc3 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
@@ -7,8 +7,25 @@
#
# SPDX-License-Identifier: MIT
+exitnlog() {
+ ec=$?
+ set +e
+ if [ "$ec" != "0" ]; then
+ echo "ERROR: $0 failed"
+ else
+ echo "$0 succeded"
+ fi >/dev/kmsg
+ if [ "$ec" != "0" -a -e /etc/unsupervised ]; then
+ reboot
+ fi
+}
+export -f exitnlog
+trap exitnlog EXIT
+
set -e
+udevadm settle
+
ROOT_DEV="$(findmnt / -o source -n)"
ROOT_DEV_NAME=${ROOT_DEV##*/}
ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth 1 -print -quit 2>/dev/null || true)
@@ -16,70 +33,67 @@ if [ -n "${ROOT_DEV_SLAVE}" ]; then
ROOT_DEV=/dev/${ROOT_DEV_SLAVE##*/}
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
-fi
-
-# this value is in blocks. Normally a block has 512 bytes.
-BUFFER_SIZE=32768
-BOOT_DEV_NAME=${BOOT_DEV##*/}
-DISK_SIZE="$(cat /sys/class/block/"${BOOT_DEV_NAME}"/size)"
-ALL_PARTS_SIZE=0
-for PARTITION in /sys/class/block/"${BOOT_DEV_NAME}"/"${BOOT_DEV_NAME}"*; do
- PART_SIZE=$(cat "${PARTITION}"/size)
- ALL_PARTS_SIZE=$((ALL_PARTS_SIZE + PART_SIZE))
-done
-
-MINIMAL_SIZE=$((ALL_PARTS_SIZE + BUFFER_SIZE))
-if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
- echo "Disk is practically already full, doing nothing." >&2
- exit 0
-fi
+# full resizing of ext4 and btrfs does not fail nor hurt but supporting more
+# filesystems in future might change this condition, so commenting this code
+useless_for_now() {
+ # this value is in blocks. Normally a block has 512 bytes.
+ BUFFER_SIZE=32768
+ BOOT_DEV_NAME=${BOOT_DEV##*/}
+ DISK_SIZE="$(cat /sys/class/block/"${BOOT_DEV_NAME}"/size)"
+ ALL_PARTS_SIZE=0
+ for PARTITION in /sys/class/block/"${BOOT_DEV_NAME}"/"${BOOT_DEV_NAME}"*; do
+ PART_SIZE=$(cat "${PARTITION}"/size)
+ ALL_PARTS_SIZE=$((ALL_PARTS_SIZE + PART_SIZE))
+ done
-LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
+ MINIMAL_SIZE=$((ALL_PARTS_SIZE + BUFFER_SIZE))
+ if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
+ echo "Disk is practically already full, doing nothing." >&2
+ exit 0
+ fi
+}
-# Transform the partition table as follows:
-#
-# - Remove any 'last-lba' header so sfdisk uses the entire available space.
-# - If this partition table is MBR and an extended partition container (EBR)
-# exists, we assume this needs to be expanded as well; remove its size
-# field so sfdisk expands it.
-# - For the previously fetched last partition, also remove the size field so
-# sfdisk expands it.
-sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
- grep -v last-lba | \
- sed 's|^\(.*, \)size=[^,]*, \(type=[f5]\)$|\1\2|' | \
- sed 's|^\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \
- sfdisk --force "${BOOT_DEV}"
-
-# Inform the kernel about the partitioning change
-partx -u "${LAST_PART}"
-
-# this is for debian stretch or systemd < 236
-if [ ! -x /lib/systemd/systemd-growfs ]; then
- # Do not fail resize2fs if no mtab entry is found, e.g.,
- # when using systemd mount units.
- export EXT2FS_NO_MTAB_OK=1
+# TODO, 14.12.2022: this change should be tested with a single volume system
+# preliminary tests shown that ext4 and btrfs entire volumes cam be resized
+BOOT_DEV="$(echo "${ROOT_DEV}" | sed 's/p\?[0-9]*$//')"
+if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then
+ LAST_PART="${BOOT_DEV}"
+else
+ LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
- resize2fs "${LAST_PART}"
- exit 0
-fi
+ # Transform the partition table as follows:
+ #
+ # - Remove any 'last-lba' header so sfdisk uses the entire available space.
+ # - If this partition table is MBR and an extended partition container (EBR)
+ # exists, we assume this needs to be expanded as well; remove its size
+ # field so sfdisk expands it.
+ # - For the previously fetched last partition, also remove the size field so
+ # sfdisk expands it.
+ sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
+ grep -v last-lba | \
+ sed 's|^\(.*, \)size=[^,]*, \(type=[f5]\)$|\1\2|' | \
+ sed 's|^\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \
+ sfdisk --force "${BOOT_DEV}"
-if grep -q x-systemd.growfs /etc/fstab; then
- echo "Found x-systemd.growfs option in /etc/fstab, won't call it explicitly." >&2
- exit 0
+ # Inform the kernel about the partitioning change
+ partx -u "${LAST_PART}"
fi
-# mount $LAST_PART out of tree, so we won't conflict with other mounts
-MOUNT_POINT=$(mktemp -d -p /mnt "$(basename "$0").XXXXXXXXXX")
-if [ ! -d "${MOUNT_POINT}" ]; then
- echo "Cannot create temporary mount point ${MOUNT_POINT}." >&2
- exit 1
-fi
+# Do not fail resize2fs if no mtab entry is found, e.g.,
+# when using systemd mount units.
+export EXT2FS_NO_MTAB_OK=1
-mount "${LAST_PART}" "${MOUNT_POINT}"
-/lib/systemd/systemd-growfs "${MOUNT_POINT}"
-umount "${MOUNT_POINT}"
-rmdir "${MOUNT_POINT}"
+case $(lsblk -fno FSTYPE "${LAST_PART}") in
+ ext[234]) resize2fs "${LAST_PART}"
+ ;;
+ btrfs) err=0
+ tmpdir=$(mktemp -d -p "$TMPDIR" btrfs.XXXX || \
+ mktemp -d -p "/dev/shm" btrfs.XXXX)
+ mount "${LAST_PART}" "$tmpdir"
+ btrfs filesystem resize max "$tmpdir" || err=1
+ umount "$tmpdir" && rmdir "$tmpdir"
+ exit $err
+ ;;
+ *) echo "WARNING: $0 unsupported filesystem" >/dev/kmsg || true
+ ;;
+esac
diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
index fda5001..2c120c4 100644
--- a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
+++ b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
@@ -7,7 +7,9 @@
Description=Expand last partition
DefaultDependencies=no
Conflicts=shutdown.target
+Requires=systemd-udevd.service
After=systemd-remount-fs.service
+After=systemd-udevd.service
Before=local-fs-pre.target shutdown.target
ConditionPathIsReadWrite=/etc
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHSET] expand last partition script and its usage
2022-12-15 23:00 ` Roberto A. Foglietta
@ 2022-12-16 8:14 ` Roberto A. Foglietta
2022-12-16 11:38 ` Roberto A. Foglietta
0 siblings, 1 reply; 6+ messages in thread
From: Roberto A. Foglietta @ 2022-12-16 8:14 UTC (permalink / raw)
To: isar-users
Cc: Anton Mikanovich, Henning Schild, Moessbauer, Felix, Joe MacDonald
On Fri, 16 Dec 2022 at 00:00, Roberto A. Foglietta
<roberto.foglietta@gmail.com> wrote:
>
> Hi all,
> - udev support: udevadm settle is the first task to run
[...]
> - unpartitioned volumes are resized as well (tested)
about these points the latency introduced by udevadm settle is
irrelevant in most cases about 0.1 seconds and because I commented the
code that checks for the free space in the last partition (all
resizing tools do that more efficiently) - in general the execution
time will be smaller - faster. In those platforms in which the boot
time grows up - most probably are the same that would fail because
they boot from a small internal storage device and might use
unpartitioned devices for rootfs or RW. Likely the qemu test that I
presented here in which vmlinuz and initrd image are separated from
the unpartitioned volume. In such a case the mount cannot trigger the
kernel to map the device because rootfs and bootfs are on different
devices. This is also the reason because I denominated the patch
"generalisation" - not only for having added btrfs. That support was
been in place since September 30th.
Best regards, R-
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHSET] expand last partition script and its usage
2022-12-16 8:14 ` Roberto A. Foglietta
@ 2022-12-16 11:38 ` Roberto A. Foglietta
2022-12-18 13:50 ` Roberto A. Foglietta
0 siblings, 1 reply; 6+ messages in thread
From: Roberto A. Foglietta @ 2022-12-16 11:38 UTC (permalink / raw)
To: isar-users
Cc: Anton Mikanovich, Henning Schild, Moessbauer, Felix, Joe MacDonald
[-- Attachment #1: Type: text/plain, Size: 1692 bytes --]
On Fri, 16 Dec 2022 at 09:14, Roberto A. Foglietta
<roberto.foglietta@gmail.com> wrote:
>
> On Fri, 16 Dec 2022 at 00:00, Roberto A. Foglietta
> <roberto.foglietta@gmail.com> wrote:
> >
> > Hi all,
>
> > - udev support: udevadm settle is the first task to run
>
A dependency needed added, this grants that udevd and udevadm will be installed
Many systems might not need udevadm settle for expanding last partition but few
others which rely on separated couple of bootfs/rootfs where last
partition is on
a volume connected through a kind of bus which not be fully ready at boot time
until udevd will end to populate the /dev tree.
Moreover, expanding the last partition is a single time task which runs only on
the first machine boot and then will be disabled forever. Thus, even if it
would take some time on some systems, it is acceptable in order to grant to the
widest variety of systems this service. Alternative is to accept that some
system will be left unprovided of the storage space they have been designed for.
This patch is for applying on top of the other previous 7 patches
- In expand last partition few improvements and a bugfix
- In expand last partition trap exitnlog EXIT logs with simpler code
- The expand last partition might support full volumes also, to test
- In expand last partition checking the size is useless
- If expand last partition fails, unsupervised systems reboot
- In expand last partition script btrfs support added
- In expand last partition wait for udev have finished
or their combination:
- The expand last partition rework and generalisation
Sent by elastic mail SMTP and went in moderation, here in attachment.
Best regards, R-
[-- Attachment #2: 0001-In-expand-last-partition-recipe-udev-pacakge-added.patch --]
[-- Type: text/x-patch, Size: 2651 bytes --]
From c798b7fa7469022e052b7034e4e0e226b7152615 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Fri, 16 Dec 2022 12:17:50 +0100
Subject: [PATCH] In expand last partition recipe udev pacakge added
A dependency needed added, this grants that udevd and udevadm will be installed
Many systems might not need udevadm settle for expanding last partition but few
others which rely on separated couple of bootfs/rootfs where last partition is on
a volume connected through a kind of bus which not be fully ready at boot time
until udevd will end to populate the /dev tree.
Moreover, expanding the last partition is a single time task which runs only on
the first machine boot and then will be disabled forever. Thus, even if it
would take some time on some systems, it is acceptable in order to grant to the
widest variety of systems this service. Alternative is to accept that some
system will be left unprovided of the storage space they have been designed for.
This patch is for applying on top of the other previous 7 patches
- In expand last partition few improvements and a bugfix
- In expand last partition trap exitnlog EXIT logs with simpler code
- The expand last partition might support full volumes also, to test
- In expand last partition checking the size is useless
- If expand last partition fails, unsupervised systems reboot
- In expand last partition script btrfs support added
- In expand last partition wait for udev have finished
or their combination:
- The expand last partition rework and generalisation
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../expand-on-first-boot/expand-on-first-boot_1.2.bb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
index fe7b72b..de4a9bb 100644
--- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
+++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
@@ -10,7 +10,7 @@ inherit dpkg-raw
DESCRIPTION = "This service grows the last partition to the full medium during first boot"
MAINTAINER = "isar-users <isar-users@googlegroups.com>"
-DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux, btrfs-progs"
+DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux, btrfs-progs, udev"
SRC_URI = " \
file://expand-on-first-boot.service \
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHSET] expand last partition script and its usage
2022-12-16 11:38 ` Roberto A. Foglietta
@ 2022-12-18 13:50 ` Roberto A. Foglietta
0 siblings, 0 replies; 6+ messages in thread
From: Roberto A. Foglietta @ 2022-12-18 13:50 UTC (permalink / raw)
To: isar-users
Cc: Anton Mikanovich, Henning Schild, Moessbauer, Felix, Joe MacDonald
[-- Attachment #1: Type: text/plain, Size: 3207 bytes --]
On Fri, 16 Dec 2022 at 12:38, Roberto A. Foglietta
<roberto.foglietta@gmail.com> wrote:
>
> On Fri, 16 Dec 2022 at 09:14, Roberto A. Foglietta
> <roberto.foglietta@gmail.com> wrote:
> >
> > On Fri, 16 Dec 2022 at 00:00, Roberto A. Foglietta
> > <roberto.foglietta@gmail.com> wrote:
> > >
> > > Hi all,
> >
> > > - udev support: udevadm settle is the first task to run
> >
>
> A dependency needed added, this grants that udevd and udevadm will be installed
>
> Many systems might not need udevadm settle for expanding last partition but few
> others which rely on separated couple of bootfs/rootfs where last
> partition is on
> a volume connected through a kind of bus which not be fully ready at boot time
> until udevd will end to populate the /dev tree.
>
> Moreover, expanding the last partition is a single time task which runs only on
> the first machine boot and then will be disabled forever. Thus, even if it
> would take some time on some systems, it is acceptable in order to grant to the
> widest variety of systems this service. Alternative is to accept that some
> system will be left unprovided of the storage space they have been designed for.
>
> This patch is for applying on top of the other previous 7 patches
>
> - In expand last partition few improvements and a bugfix
> - In expand last partition trap exitnlog EXIT logs with simpler code
> - The expand last partition might support full volumes also, to test
> - In expand last partition checking the size is useless
> - If expand last partition fails, unsupervised systems reboot
> - In expand last partition script btrfs support added
> - In expand last partition wait for udev have finished
>
> or their combination:
>
> - The expand last partition rework and generalisation
>
> Sent by elastic mail SMTP and went in moderation, here in attachment.
>
I decided to leverage the MIT license to change the copyright notice
and license after the work and generalisation.
As usual, I sent this patch by elastic mail SMTP so it went on
moderation. Here in attachment.
This patch applies on the top of the patches listed above.
>From aeb885595b53d08ed101ccc08032a6dfcfe3decb Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Sun, 18 Dec 2022 14:10:40 +0100
Subject: [PATCH] Copyright changes of expand last partition script after
rework
Script to resize last partition to full medium size, changed the copyright
and the license by the author of the rework and generalisation as following:
. This software was originally a part of ISAR
. Copyright (c) Siemens AG, 2018-2022
. SPDX-License-Identifier: MIT
.
. After its rework and generalisation this file was relicensed
. (C) 2022, Roberto A. Foglietta <roberto.foglietta@gmail.com>
. SPDX-License-Identifier: all rights reserved, but fair use allowed
. Fair use includes test, learning and marketing but not sales, redistribution
. leasing, renting or every other commercial/business activities without the
. consent of the author. Every company or individual allowed to use this
. code behind these limitations will be listed here below, if any.
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Best regards, R-
[-- Attachment #2: 0001-Copyright-changes-of-expand-last-partition-script-af.patch --]
[-- Type: text/x-patch, Size: 2413 bytes --]
From aeb885595b53d08ed101ccc08032a6dfcfe3decb Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Sun, 18 Dec 2022 14:10:40 +0100
Subject: [PATCH] Copyright changes of expand last partition script after
rework
Script to resize last partition to full medium size, changed the copyright
and the license by the author of the rework and generalisation as following:
. This software was originally a part of ISAR
. Copyright (c) Siemens AG, 2018-2022
. SPDX-License-Identifier: MIT
.
. After its rework and generalisation this file was relicensed
. (C) 2022, Roberto A. Foglietta <roberto.foglietta@gmail.com>
. SPDX-License-Identifier: all rights reserved, but fair use allowed
. Fair use includes test, learning and marketing but not sales, redistribution
. leasing, renting or every other commercial/business activities without the
. consent of the author. Every company or individual allowed to use this
. code behind these limitations will be listed here below, if any.
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
expand-last-partition.sh
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
.../files/expand-last-partition.sh | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
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 5cd6fc3..82b74a6 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
@@ -2,10 +2,18 @@
#
# Resize last partition to full medium size
#
-# This software is a part of ISAR.
+# This software was originally a part of ISAR
# Copyright (c) Siemens AG, 2018-2022
-#
# SPDX-License-Identifier: MIT
+#
+# After its rework and generalisation this file was relicensed
+# (C) 2022, Roberto A. Foglietta <roberto.foglietta@gmail.com>
+# SPDX-License-Identifier: all rights reserved, but fair use allowed
+# Fair use includes test, learning and marketing but not sales, redistribution
+# leasing, renting or every other commercial/business activities without the
+# consent of the author. Every company or individual allowed to use this
+# code behind these limitations will be listed here below, if any.
+#
exitnlog() {
ec=$?
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-18 13:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 18:06 [PATCHSET] expand last partition script and its usage Roberto A. Foglietta
2022-12-15 18:27 ` Roberto A. Foglietta
2022-12-15 23:00 ` Roberto A. Foglietta
2022-12-16 8:14 ` Roberto A. Foglietta
2022-12-16 11:38 ` Roberto A. Foglietta
2022-12-18 13:50 ` Roberto A. Foglietta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox