From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6599936908158042112 X-Received: by 2002:a2e:6390:: with SMTP id s16-v6mr153613lje.15.1536831025160; Thu, 13 Sep 2018 02:30:25 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a2e:421c:: with SMTP id p28-v6ls518973lja.2.gmail; Thu, 13 Sep 2018 02:30:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaGYvAvXbhXlvb7YR+JMQwOCeGKHFUn0Nw2pTEiTupalRuCHroJ5VRVzmdm5Py8A7tdNunu X-Received: by 2002:a2e:7819:: with SMTP id t25-v6mr156754ljc.35.1536831024711; Thu, 13 Sep 2018 02:30:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536831024; cv=none; d=google.com; s=arc-20160816; b=liOyZxnh3Q0lmY8rJ+xme8FMg4LYpALNNB7Yjfjs6PJ+ABoS5Ik6IIDYBPCnbZLC4Y 4Hh7vbglU3GOrJgMjg0Lni7u6WkHFA3cRSwMewgMlYxEpxXpHdIq/maViG11mVTVK0cS bXK8B6OcZ3QTaGBFXti+KPVw0yRvNmxhyFPqHp+BvI8hy1y+u4aYDQW3osCfR+HwwKYV g4gXXXDn7Kc+Uc0wb0gbuJrUR29KHLt9tV8Xx9FQe9DO21e4IVjcH41DWiD/yj2xFUIl 9NarJEOGzO3pE5/nvdf5ynRo9O4+G7kvP2LhwxnRl+7xJYLfOG5UEKjxyNd04Ysfcj7/ h3CA== 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=KUrl5ukY9xxqkbMaMKzwLWbC83ThRwtyvsOMhJ7d4hg=; b=JhB3Nk8W9Ob7QswVe/kLckrT7MBcY0rqUA6OB7vuAsUCUKWBGobmzKphTvB8X6kxrr 2HbrrwfAqt+xH6sJHs43noYJlbs95hmsTUIVkXiwncXZYv4GGuQ6tUciZ8TXyBr6ilZj BjfLEeEChaKejZjjW/0z4OQCWAzSr7PgoPsIs2UbGa1sRbc/Ji5Pgx8E3udml6C95nTt cQfIqZ1dKFtf6sL8M83uH5K2DjzVp8ehoQpGtnW4mNd6g0Q9tXFPN8cjZP+LHo3rsgGO fX4kfiirnZGp1DjVN5lCuokjx1+f400uqHmrKN0DQzqM+jEDWp4h9BSDCcWXRcvZctoI AdMw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id n42-v6si154401lfi.2.2018.09.13.02.30.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Sep 2018 02:30:24 -0700 (PDT) Received-SPF: pass (google.com: domain of henning.schild@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 henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@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 w8D9UNkU006682 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 13 Sep 2018 11:30:23 +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 w8D9UNBh014548; Thu, 13 Sep 2018 11:30:23 +0200 Date: Thu, 13 Sep 2018 11:30:23 +0200 From: Henning Schild To: Jan Kiszka Cc: isar-users Subject: Re: [PATCH 12/16] meta: Add expand-on-first-boot support package Message-ID: <20180913113023.2591edc7@md1pvb1c.ad001.siemens.net> In-Reply-To: <140f8df3-b0b8-8fe8-7ef3-a15bf1331330@siemens.com> References: <20180912154610.363a1bbb@md1pvb1c.ad001.siemens.net> <140f8df3-b0b8-8fe8-7ef3-a15bf1331330@siemens.com> 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: 8+Xrwyqb5wXq Am Thu, 13 Sep 2018 10:33:59 +0200 schrieb Jan Kiszka : > On 12.09.18 15:46, Henning Schild wrote: > > 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. > > ConditionFirstBoot was my first try as well, but it does not work > here because - my guess, didn't analyze deeply - the debootstrap run > or the rootfs installation step count as such, and the condition is > false on FirstRealBoot. I would suggest leaving a mark with "touch" from within the script and using "ConditionPathExists=!", calling systemd from systemd sounds like a bad idea. Unless that is the officialy documented way of doing such things. Henning > Jan >