public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Harald Seiler <hws@denx.de>, isar-users <isar-users@googlegroups.com>
Subject: Re: [PATCH] expand-on-first-boot: Allow expanding extended MBR partitions
Date: Fri, 12 Jun 2020 20:42:12 +0200	[thread overview]
Message-ID: <f0eaa7ab-7cbd-a62d-b88a-227112736422@siemens.com> (raw)
In-Reply-To: <323b50f39ca1ce6ac21a705bcbf6f24e4e6e5c0d.camel@denx.de>

On 12.06.20 11:53, Harald Seiler wrote:
> Hello Jan,
> 
> On Wed, 2020-06-10 at 14:50 +0200, Jan Kiszka wrote:
>> On 10.06.20 10:02, Harald Seiler wrote:
>>> 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

That reason is "parted mkpart extended" which always creates a type-f
extended partition.

>>>     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`.
>>
>> Wikipedia says about 0x5:
>>
>> "Extended partition with CHS addressing. It must reside within the first
>> physical 8 GB of disk, else use 0Fh instead"
>>
>> So we likely need to account for that case as well.
>>
> 
> Hm, this is getting quite complicated ... And I suppose this is only one
> of many corner cases.  I'm not sure how much effort is worth here: This
> change is only relevant to legacy systems that (have to) use MBR *and*
> deal with more than 4 partitions which is most likely not too many.
> 
> What do you think?  Is it likely that other projects would benefit from
> a general solution or would it make more sense to keep this a) project
> specific or b) detect one supported case and only do EBR expansion for
> that one.

How did you test this? I ran sfdisk on buster the way the script does,
just without type changing, and it happily created a type-f extended
partition AND expanded the last logical part inside that:

root@552c35371e6b:/# sfdisk -d disk | \
  sed 's|^\(.*, \)size=[^,]*, \(type=[f5]\)$|\1\2|' | \
  sed 's|^\(disk6 .*, \)size=[^,]*, |\1|' | \
  sfdisk --force disk
Checking that no-one is using this disk right now ... OK

Disk disk: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7f8c0892

Old situation:

Device Boot  Start     End Sectors  Size Id Type
disk1         2048 1953791 1951744  953M  f W95 Ext'd (LBA)
disk5         4096  194559  190464   93M 83 Linux
disk6       196608  217087   20480   10M 83 Linux

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x7f8c0892.
disk1: Created a new partition 1 of type 'W95 Ext'd (LBA)' and of size 4
GiB.
disk2: Created a new partition 5 of type 'Linux' and of size 93 MiB.
disk6: Created a new partition 6 of type 'Linux' and of size 3.9 GiB.
disk7: Done.

New situation:
Disklabel type: dos
Disk identifier: 0x7f8c0892

Device Boot  Start     End Sectors  Size Id Type
disk1         2048 8388607 8386560    4G  f W95 Ext'd (LBA)
disk5         4096  194559  190464   93M 83 Linux
disk6       196608 8388607 8192000  3.9G 83 Linux

The partition table has been altered.
Syncing disks.


Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

      reply	other threads:[~2020-06-12 18:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10  8:02 Harald Seiler
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 [this message]

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=f0eaa7ab-7cbd-a62d-b88a-227112736422@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=hws@denx.de \
    --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