From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
To: isar-users@googlegroups.com
Subject: [PATCH] In expand last partition checking the size is useless
Date: Wed, 14 Dec 2022 12:49:44 +0100 [thread overview]
Message-ID: <CAJGKYO4WG90BaENOJOetNmE2-cO-3PVadkBwqesq+SsnmVYJ5w@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 308 bytes --]
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
Patch sent by elastic mail SMTP went into moderation, attached here
Best, R-
[-- Attachment #2: 0001-In-expand-last-partition-checking-the-size-is-useles.patch --]
[-- Type: text/x-patch, Size: 2473 bytes --]
From c0d56a45db8a38f7121a13eff4e68c10a6cf0db7 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] 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
next reply other threads:[~2022-12-14 11:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 11:49 Roberto A. Foglietta [this message]
2022-12-14 12:01 ` Roberto A. Foglietta
2022-12-14 12:08 ` Anton Mikanovich
2022-12-14 12:46 ` Roberto A. Foglietta
2022-12-14 13:52 ` 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=CAJGKYO4WG90BaENOJOetNmE2-cO-3PVadkBwqesq+SsnmVYJ5w@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