public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Harald Seiler <hws@denx.de>
To: isar-users <isar-users@googlegroups.com>
Cc: Harald Seiler <hws@denx.de>, Jan Kiszka <jan.kiszka@siemens.com>
Subject: [PATCH] expand-on-first-boot: Allow expanding extended MBR partitions
Date: Wed, 10 Jun 2020 10:02:47 +0200	[thread overview]
Message-ID: <20200610080247.385697-1-hws@denx.de> (raw)

Extended partitions cannot be resized like primary partitions because
both the last logical partition and the EBR primary partition containing
it need to be expanded.

To do this, add a second SED directive for removing the parition size of
the EBR partition.  This part is detected by having either type `f` (Win
95 Ext') or `5` (Extended).

Signed-off-by: Harald Seiler <hws@denx.de>
---

Notes:
    I have tested this in an ongoing project and it seems to work
    reliably.  For some reason WIC creates an extended partition of
    type `f` but this can't be kept because while fdisk can read it,
    it is only happy about writing the EBR with type `5`.
    
    While probably a very uncommon layout, I am not sure how this
    would behave when the EBR is not the last partition, but
    somewhere in between.  I am a bit worried it would silently wreak
    havoc ...

 .../expand-on-first-boot/files/expand-last-partition.sh      | 5 +++--
 1 file changed, 3 insertions(+), 2 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 08c69db30529..ddf1a089e87d 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
@@ -17,12 +17,13 @@ if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then
 	exit 1
 fi
 
-LAST_PART="$(sfdisk -d ${BOOT_DEV} 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
+LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
 
 # Remove all hints to the current medium (last-lba) and last partition size,
 # then ask sfdisk to recreate the partitioning
 sfdisk -d "${BOOT_DEV}" 2>/dev/null | grep -v last-lba | \
-	sed 's|\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \
+	sed 's|^\(.*, \)size=[^,]*, type=[f5]$|\1type=5|' | \
+	sed 's|^\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \
 	sfdisk --force "${BOOT_DEV}"
 
 # Inform the kernel about the partitioning change
-- 
2.25.4


             reply	other threads:[~2020-06-10  8:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10  8:02 Harald Seiler [this message]
2020-06-10 12:50 ` Jan Kiszka
2020-06-10 13:03   ` Baurzhan Ismagulov
2020-06-12  9:53   ` Harald Seiler
2020-06-12 18:42     ` 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=20200610080247.385697-1-hws@denx.de \
    --to=hws@denx.de \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.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