From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6599936908158042112 X-Received: by 2002:a1c:9e94:: with SMTP id h142-v6mr212693wme.13.1536759972933; Wed, 12 Sep 2018 06:46:12 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:ac16:: with SMTP id v22-v6ls653219wrc.7.gmail; Wed, 12 Sep 2018 06:46:12 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbGiyC+utkf6Alo0cgUn6XBgp0vf26p1052fHumjTam7yQtwPulL0bofTrIVrttyVpfrXFa X-Received: by 2002:adf:f787:: with SMTP id q7-v6mr193706wrp.5.1536759972529; Wed, 12 Sep 2018 06:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536759972; cv=none; d=google.com; s=arc-20160816; b=TMCfzn00Zj4UsbMdpJ+/6WllGkHe1MIytYAxfJPfwiMTf9YmuE3JQM1UgUR13489oA i7k+1nEwnrVHewW0VyNXftLKgbCoiFv5VF49hQaa1rOifePKGfzhNGcFl8U6aXjuUgKc F+0RArQHqdxUlYzoWZh0KiHBBhvLyCHmUGNtI5RwmMoq4KMS9y53i7qdzg8F+yUg60SF q28+rg5SDXIGDadfaiasdvz3TXETz2yT9uqIbaCerPsKtv0bZTqtsqZOPLbam+4W8H6Y 30RLpGJva9XiIEsisg55UMgc1uJgbdie/lG65lPDovyG5dDBY6zD/uYWMsteo88pDCUK Ryfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date; bh=VdzEbaOYKypcBJGsSrCMyoOpUMV/erQrayx+YQWrrEs=; b=HKgPa2CZqTb7cO6RJIMXPa19f2UGbqmh7LLhmpMaFa2CjyZspZslc/I/HbzWMHiTK9 myuZDBisBKoM9cW/NNukoL2DGFY5Pyz0x/nGb3JV2KAzql0QX+4QD3k5hazOIJ/4t3Rk QYg+MphSXIZZt+vAeHT0fIsKMH7HC+ISqg2JhydlYZXKxuxpj49BwFRHah46RLXxRyD9 AKG28e00J7cxkYkcdIACxuiL8hApjK8Gk34Db8Lua6MY6ONhzl8rBvpkT5k8YSXQczM5 GoJFqhrc9Lf5+3Lk3yPGHCI3u7OsBK1PyZFERGCHNdEABePN1nNjDpa6OskXG2KsHRQD x8tQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Return-Path: Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id g14-v6si420391wmg.0.2018.09.12.06.46.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 06:46:12 -0700 (PDT) Received-SPF: pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w8CDkB9V010986 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 12 Sep 2018 15:46:11 +0200 Received: from md1pvb1c.ad001.siemens.net (md1pvb1c.ad001.siemens.net [139.25.68.40]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id w8CDkBLr002655; Wed, 12 Sep 2018 15:46:11 +0200 Date: Wed, 12 Sep 2018 15:46:10 +0200 From: Henning Schild To: "[ext] Jan Kiszka" Cc: isar-users Subject: Re: [PATCH 12/16] meta: Add expand-on-first-boot support package Message-ID: <20180912154610.363a1bbb@md1pvb1c.ad001.siemens.net> In-Reply-To: References: X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TUID: N4Hw9A1fehnD Am Tue, 11 Sep 2018 14:05:52 +0200 schrieb "[ext] Jan Kiszka" : > From: Jan Kiszka > > When installed, this systemd service expands the last partition on a > the boot medium to the full size of that medium. It then deactivates > itself. > > Based on sysvinit version by Henning Schild. > > Signed-off-by: Jan Kiszka > --- > .../expand-on-first-boot/expand-on-first-boot.bb | 25 > +++++++++++++++++ .../files/expand-last-partition.sh > | 31 > ++++++++++++++++++++++ .../files/expand-on-first-boot.service > | 23 > ++++++++++++++++ .../expand-on-first-boot/files/postinst > | 3 +++ 4 files changed, 82 insertions(+) create mode 100644 > meta/recipes-support/expand-on-first-boot/expand-on-first-boot.bb > create mode 100644 > meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh > create mode 100644 > meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service > create mode 100644 > meta/recipes-support/expand-on-first-boot/files/postinst > > diff --git > a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot.bb > b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot.bb > new file mode 100644 index 0000000..49d6c3b --- /dev/null > +++ > b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot.bb > @@ -0,0 +1,25 @@ +# Resize last partition to full medium size on fist > boot +# > +# This software is a part of ISAR. > +# Copyright (c) Siemens AG, 2018 > +# > +# SPDX-License-Identifier: MIT > + > +inherit dpkg-raw > + > +DESCRIPTION = "This service grows the last partition to the full > medium during first boot" + > +DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, > util-linux" + > +SRC_URI = " \ > + file://expand-on-first-boot.service \ > + file://expand-last-partition.sh \ > + file://postinst" > + > +do_install() { > + install -d -m 755 ${D}/lib/systemd/system > + install -m 644 ${WORKDIR}/expand-on-first-boot.service > ${D}/lib/systemd/system/ + > + install -d -m 755 ${D}/usr/share/expand-on-first-boot > + install -m 755 ${WORKDIR}/expand-last-partition.sh > ${D}/usr/share/expand-on-first-boot/ +} > 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 > new file mode 100644 index 0000000..913e63b --- /dev/null > +++ > b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh > @@ -0,0 +1,31 @@ +#!/bin/sh > +# > +# Resize last partition to full medium size > +# > +# This software is a part of ISAR. > +# Copyright (c) Siemens AG, 2018 > +# > +# SPDX-License-Identifier: MIT > + > +set -e > + > +ROOT_DEV=$(findmnt / -o source -n) > +BOOT_DEV=$(echo ${ROOT_DEV} | sed 's/p\?[0-9]*$//') > + > +if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then > + echo "Boot device equals root device - no partitioning > found" >&2 > + exit 1 > +fi > + > +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|' | \ > + sfdisk --force ${BOOT_DEV} > + > +# Inform the kernel about the partitioning change > +partx -u ${LAST_PART} > + > +resize2fs ${LAST_PART} > diff --git > a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service > b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service > new file mode 100644 index 0000000..cbe3857 --- /dev/null > +++ > b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service > @@ -0,0 +1,23 @@ +# This software is a part of ISAR. > +# Copyright (c) Siemens AG, 2018 > +# > +# SPDX-License-Identifier: MIT > + > +[Unit] > +Description=Expand last partition > +DefaultDependencies=no > +Conflicts=shutdown.target > +After=systemd-remount-fs.service > +Before=sysinit.target shutdown.target > +ConditionPathIsReadWrite=/etc > + > +[Service] > +Type=oneshot > +RemainAfterExit=yes > +ExecStart=/usr/share/expand-on-first-boot/expand-last-partition.sh > +ExecStartPost=-/bin/systemctl disable expand-on-first-boot.service Ok, this seems to be how you try to make sure this is done only once at the first boot. Is this a hack or somehow documented in systemd? I just read something about "ConditionFirstBoot=" in systemd. Henning > +StandardOutput=syslog > +StandardError=syslog > + > +[Install] > +WantedBy=sysinit.target > diff --git a/meta/recipes-support/expand-on-first-boot/files/postinst > b/meta/recipes-support/expand-on-first-boot/files/postinst new file > mode 100644 index 0000000..a190b01 > --- /dev/null > +++ b/meta/recipes-support/expand-on-first-boot/files/postinst > @@ -0,0 +1,3 @@ > +#!/bin/sh > + > +systemctl enable expand-on-first-boot.service