From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6836626675367673856 X-Received: by 2002:a1c:9d53:: with SMTP id g80mr288029wme.13.1591987335545; Fri, 12 Jun 2020 11:42:15 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:82ce:: with SMTP id 72ls687968wrc.1.gmail; Fri, 12 Jun 2020 11:42:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjLmWRESRMXFCI7oCS6md7yoa1wXiLrCWFA0TSOwtBSqsgBwDOiPJzD3+cTNkVvDQXVnV7 X-Received: by 2002:adf:f00f:: with SMTP id j15mr17848601wro.347.1591987334901; Fri, 12 Jun 2020 11:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591987334; cv=none; d=google.com; s=arc-20160816; b=XRPBIg86HsU3D0TSZ99coTtFkDu1s7OVHkKbnC9VX2TeRXNG5MOzRaUsTC3J6odzM0 JxBd/kHiHPiW3qZBl0tVCfv8nddWSx/SOtb7sQJ73Nxi5LBAYFSfHQbJEHwGnMLxLGf0 qkpQb8cVPnx8FX7qKb1906VaU8fMuu6uiUC6DHN38rys/TMWOEV8NkMyBlqZ8fpty2Bw aNgWBSjjFZ3+1aepYJ4NYYperTpyEhogSs7Bxzy6xeZjM9HvjOre2dRZBJZjaTUI0N3c +2bZ1AzCz3lsDVqxzcC3GETOtILCHKqJw42ozm2KwM7FtaQkYENOWxDfVDcuV89IHRnV +AzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject; bh=NM/9OyhufhkIA4UqStkCxzc3Q8zKmzfDFkwn4+IscDo=; b=rt8QH//pu/ObIR3/9DOZqdpqNtRyZTHF7DxBhkrk/69idn6Ppl10GFxDqV8RQWDRI4 T87C+VP4fS3+R0dkcEiyhgD3Ms21n3kFM3R3qP2Xc2y3ertM28D9eEFm9HD6P8ckPmlS dHJH4Crue61SbIuu6L7F5cZOvpTB2QsQntpP7e8Q1bEVgdmooowGWCffi1tIqb2JvJ3e JZo23X6VwYNV9rSXhSHbeN6bFl20oMjpBgTmMRxq53kbhVjjA/Nszow1RR8o+S85EwVH xVc9hBWfS/KMSZ031qPfPmtGl+uUQRWzyWcHYr/YmZebNEBvoeIG417O4XL+Z8AaQYWs phQw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id l4si461480wrc.0.2020.06.12.11.42.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jun 2020 11:42:14 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) client-ip=194.138.37.39; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 05CIgCGD000834 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 20:42:13 +0200 Received: from [167.87.11.220] ([167.87.11.220]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 05CIgCZC001900; Fri, 12 Jun 2020 20:42:12 +0200 Subject: Re: [PATCH] expand-on-first-boot: Allow expanding extended MBR partitions To: Harald Seiler , isar-users References: <20200610080247.385697-1-hws@denx.de> <323b50f39ca1ce6ac21a705bcbf6f24e4e6e5c0d.camel@denx.de> From: Jan Kiszka Message-ID: Date: Fri, 12 Jun 2020 20:42:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <323b50f39ca1ce6ac21a705bcbf6f24e4e6e5c0d.camel@denx.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: 3UNWCQnUp5Jr 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 >>> --- >>> >>> 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