public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] In expand last partition checking the size is useless
@ 2022-12-14 11:49 Roberto A. Foglietta
  2022-12-14 12:01 ` Roberto A. Foglietta
  0 siblings, 1 reply; 5+ messages in thread
From: Roberto A. Foglietta @ 2022-12-14 11:49 UTC (permalink / raw)
  To: isar-users

[-- 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-14 13:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14 11:49 [PATCH] In expand last partition checking the size is useless Roberto A. Foglietta
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

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