From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6836626675367673856 X-Received: by 2002:a17:906:e0cf:: with SMTP id gl15mr2313043ejb.501.1591776189471; Wed, 10 Jun 2020 01:03:09 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a17:906:7248:: with SMTP id n8ls524636ejk.2.gmail; Wed, 10 Jun 2020 01:03:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyry9hGI+dPZshLcqaIy8zOR525sVOcrTpiWaODqGsUm9DVRDGV/liWn++0wTdVxnjzKXLY X-Received: by 2002:a17:906:76c4:: with SMTP id q4mr2322903ejn.371.1591776188931; Wed, 10 Jun 2020 01:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591776188; cv=none; d=google.com; s=arc-20160816; b=arB7kTTA3pEsibhbRfeKmQ4zsGddHuiv9HqBPwqZa2cFPtgNgnxEXPA82hdUE0Fqxs bUFtgGZdSm1qpBDzLKmq2CHQJp48OduxgoyYCrd5yNzL6bDQzgQd4/ZwoCoDGScBGHDJ scs6YXwiGcAc+dpud6OMHqbajZZMGRxqrLUYA1HkeF1To3c9MjSLxbKXsmUhOE+e/bn2 FD5UHpHl5rTGkrqzk1YhR4LKgX1ZSmQS6AjqwA9qrhuq130reL+udl75r/PpaHvlyWrR TwR/xrDoZXvLbUsdje0eBIQpafZlxYZ/uxnxeo/3lHuND7FWR9tnumZrErr4Scb7nSXW Ptpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=CCXpXIBODHBqq4fc28qLhMDigkbHg1HJDLbzfF8Yt2c=; b=Jqbx7A2Nt00m1U5fpfbH3Q/Pompwm6K0KLqZdrdcPwHTgvHZtaqc1XzmSQMrfEFu25 HwrwY3q+kjLcXzP5FX2SBmGpldJ5dn8PA56yr7DXb4G2GHhtIIjzUlAVL5HYPTL3oRqD Mnxn5EzDMvwbpR+8wsyhTU3rx82dlgiEtdpXIG0DgBHhMStjLGRK+Xny6k1odOV15hWA N8w+HWB0LtzLQbc7mHoUuJ2bcg8+J/9Z8zpX2J3pk93lZkedbDl2rmm/jEP5fQYbsAbq tO31plMUm0NzJRBfg/mxD6xHjHJuoPZ/KQ8qLHyBT6do5f13IBc5Pq4ZXXAwrdR0MnWo lhWQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of hws@denx.de) smtp.mailfrom=hws@denx.de Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id r19si1011871eja.1.2020.06.10.01.03.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jun 2020 01:03:08 -0700 (PDT) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of hws@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of hws@denx.de) smtp.mailfrom=hws@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 49hfcX4LKKz1rxM2; Wed, 10 Jun 2020 10:03:08 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 49hfcX45fsz1r56G; Wed, 10 Jun 2020 10:03:08 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id vloN24ZhJwG8; Wed, 10 Jun 2020 10:03:07 +0200 (CEST) X-Auth-Info: x7SGo32/nbZYhFqGSKLhYH0+y9k/ZZt9UvUGCGgHJHY= Received: from maia.denx.de (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 10 Jun 2020 10:03:07 +0200 (CEST) From: Harald Seiler To: isar-users Cc: Harald Seiler , Jan Kiszka Subject: [PATCH] expand-on-first-boot: Allow expanding extended MBR partitions Date: Wed, 10 Jun 2020 10:02:47 +0200 Message-Id: <20200610080247.385697-1-hws@denx.de> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: stlN5iQ8XTiw 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 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