From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: Nishanth Menon <nm@ti.com>
Subject: [PATCH 9/9] expand-on-first-boot: Preserve MBR on expansion of GPT disks
Date: Sun, 7 Jan 2024 13:54:16 +0100 [thread overview]
Message-ID: <beff349aa8453fab1e13d87fb1bf5367bed41df2.1704632056.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1704632056.git.jan.kiszka@siemens.com>
From: Jan Kiszka <jan.kiszka@siemens.com>
In order to keep potential hybrid partition setups intact, preserve the
legacy MBR when a GPT disk is being expanded. This is needed because we
rewrite the partitioning via sfdisk which overwrites the MBR. In the
hypbrid setup, the legacy MBR plays no role regarding the expanded
partition, thus can be simply left untouched.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
.../files/expand-last-partition.sh | 10 ++++++++++
1 file changed, 10 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 7d658864..e6dbd62e 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
@@ -38,6 +38,11 @@ if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
exit 0
fi
+IS_GPT="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | grep -q "label: gpt" && echo 1)"
+if [ "$IS_GPT" = "1" ]; then
+ dd if="${BOOT_DEV}" of=/dev/shm/__mbr__.bak count=1
+fi
+
LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
# Transform the partition table as follows:
@@ -54,6 +59,11 @@ sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
sed 's|^\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \
sfdisk --force "${BOOT_DEV}"
+if [ "$IS_GPT" = "1" ]; then
+ dd if=/dev/shm/__mbr__.bak of="${BOOT_DEV}"
+ rm /dev/shm/__mbr__.bak
+fi
+
# Inform the kernel about the partitioning change
partx -u "${LAST_PART}"
--
2.35.3
next prev parent reply other threads:[~2024-01-07 12:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-07 12:54 [PATCH 0/9] Add support for BeaglePlay Jan Kiszka
2024-01-07 12:54 ` [PATCH 1/9] meta-isar: linux-mainline: Update to 6.6.10 Jan Kiszka
2024-01-07 12:54 ` [PATCH 2/9] optee-os: Switch default binary to tee-raw.bin Jan Kiszka
2024-01-07 12:54 ` [PATCH 3/9] u-boot-custom: Allow to set BL31 and TEE from recipes Jan Kiszka
2024-01-07 12:54 ` [PATCH 4/9] u-boot-custom: Allow to define different installation binaries Jan Kiszka
2024-01-07 12:54 ` [PATCH 5/9] beagleplay: Add TF-A recipe Jan Kiszka
2024-01-08 12:49 ` Florian Bezdeka
2024-01-07 12:54 ` [PATCH 6/9] beagleplay: Add OP-TEE recipe Jan Kiszka
2024-01-07 12:54 ` [PATCH 7/9] beagleplay: Add U-Boot recipe Jan Kiszka
2024-01-08 13:17 ` Florian Bezdeka
2024-01-08 13:19 ` Jan Kiszka
2024-01-07 12:54 ` [PATCH 8/9] Add support for the BeaglePlay board Jan Kiszka
2024-01-07 16:40 ` Jan Kiszka
2024-01-07 12:54 ` Jan Kiszka [this message]
2024-01-08 8:51 ` [PATCH 0/9] Add support for BeaglePlay Anton Mikanovich
2024-01-08 12:18 ` Jan Kiszka
2024-01-08 13:53 ` Anton Mikanovich
2024-01-08 15:07 ` Jan Kiszka
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=beff349aa8453fab1e13d87fb1bf5367bed41df2.1704632056.git.jan.kiszka@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=isar-users@googlegroups.com \
--cc=nm@ti.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