* [PATCH v3 0/1] expand-on-first-boot: Check size before resizing
@ 2022-07-13 8:21 Tobias Schmidl
2022-07-13 8:21 ` [PATCH v3 1/1] " Tobias Schmidl
2022-07-21 12:23 ` [PATCH v3 0/1] " Anton Mikanovich
0 siblings, 2 replies; 3+ messages in thread
From: Tobias Schmidl @ 2022-07-13 8:21 UTC (permalink / raw)
To: isar-users
Cc: Florian Bezdeka, Jan Kiszka, Henning Schild,
Felix Mößbauer, Tobias Schmidl
Diff to v2:
- Repaired size comparison for device nodes with prefix, thanks to Uladzimir Bely
Diff to v1:
- Reduced console output
Tobias Schmidl (1):
expand-on-first-boot: Check size before resizing
.../files/expand-last-partition.sh | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
--
2.36.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 1/1] expand-on-first-boot: Check size before resizing
2022-07-13 8:21 [PATCH v3 0/1] expand-on-first-boot: Check size before resizing Tobias Schmidl
@ 2022-07-13 8:21 ` Tobias Schmidl
2022-07-21 12:23 ` [PATCH v3 0/1] " Anton Mikanovich
1 sibling, 0 replies; 3+ messages in thread
From: Tobias Schmidl @ 2022-07-13 8:21 UTC (permalink / raw)
To: isar-users
Cc: Florian Bezdeka, Jan Kiszka, Henning Schild,
Felix Mößbauer, Tobias Schmidl
If the disk is too small, resizing might have detrimental effects.
Because of aligning issues, it could happen the the final partition is
_smaller_ than desired, which might lead to an unusable last partition.
Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com>
---
.../files/expand-last-partition.sh | 16 ++++++++++++++++
1 file changed, 16 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 c0edde7..759ff8b 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
@@ -22,6 +22,22 @@ if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then
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
+
LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
# Transform the partition table as follows:
--
2.36.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3 0/1] expand-on-first-boot: Check size before resizing
2022-07-13 8:21 [PATCH v3 0/1] expand-on-first-boot: Check size before resizing Tobias Schmidl
2022-07-13 8:21 ` [PATCH v3 1/1] " Tobias Schmidl
@ 2022-07-21 12:23 ` Anton Mikanovich
1 sibling, 0 replies; 3+ messages in thread
From: Anton Mikanovich @ 2022-07-21 12:23 UTC (permalink / raw)
To: Tobias Schmidl, isar-users
Cc: Florian Bezdeka, Jan Kiszka, Henning Schild, Felix Mößbauer
13.07.2022 11:21, Tobias Schmidl wrote:
> Diff to v2:
> - Repaired size comparison for device nodes with prefix, thanks to Uladzimir Bely
>
> Diff to v1:
> - Reduced console output
>
> Tobias Schmidl (1):
> expand-on-first-boot: Check size before resizing
>
> .../files/expand-last-partition.sh | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
Applied to next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-21 12:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 8:21 [PATCH v3 0/1] expand-on-first-boot: Check size before resizing Tobias Schmidl
2022-07-13 8:21 ` [PATCH v3 1/1] " Tobias Schmidl
2022-07-21 12:23 ` [PATCH v3 0/1] " Anton Mikanovich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox