From: "T. Schaffner" <tobias.schaffner@siemens.com>
To: <isar-users@googlegroups.com>
Cc: <henning.schild@siemens.com>,
Tobias Schaffner <tobias.schaffner@siemens.com>
Subject: [PATCH 2/2] Always try resizing the fs in expand on first boot
Date: Tue, 8 Nov 2022 12:28:37 +0100 [thread overview]
Message-ID: <20221108112837.435213-3-tobias.schaffner@siemens.com> (raw)
In-Reply-To: <20221108112837.435213-1-tobias.schaffner@siemens.com>
From: Tobias Schaffner <tobias.schaffner@siemens.com>
If the filesystem resize fails or gets interrupted we have no way to recover
from this as the script always exits if the partition was already resized.
Check if we have to resize the partition but alway run the chosen fs resize
tool. Leave the decision if the filesystem has to be resized to resize2fs /
systemd-growfs.
If the filesystem was already expanded the resize2fs / systemd-growfs call is a
noop.
Signed-off-by: Tobias Schaffner <tobias.schaffner@siemens.com>
---
.../files/expand-last-partition.sh | 35 +++++++++----------
1 file changed, 16 insertions(+), 19 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 0d662cc..b21b958 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
@@ -35,26 +35,23 @@ LAST_PART_START="$(cat /sys/class/block/"${LAST_PART_NAME}"/start)"
GPT_BACKUP_SIZE=33
if [ $((LAST_PART_START + LAST_PART_SIZE + GPT_BACKUP_SIZE)) -lt "${DISK_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}"
-# 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
# this is for debian stretch or systemd < 236
if [ ! -x /lib/systemd/systemd-growfs ]; then
--
2.34.1
next prev parent reply other threads:[~2022-11-08 11:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 11:28 [PATCH 0/2] expand-on-first-boot: try fs resize on expanded partitions T. Schaffner
2022-11-08 11:28 ` [PATCH 1/2] Check if last partition ends at GPT backup header T. Schaffner
2022-11-09 8:26 ` Henning Schild
2022-11-09 9:40 ` Schaffner, Tobias
2022-11-09 14:54 ` Henning Schild
2022-11-08 11:28 ` T. Schaffner [this message]
2022-11-09 8:52 ` [PATCH 2/2] Always try resizing the fs in expand on first boot Henning Schild
2022-11-09 10:11 ` Schaffner, Tobias
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=20221108112837.435213-3-tobias.schaffner@siemens.com \
--to=tobias.schaffner@siemens.com \
--cc=henning.schild@siemens.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