From: Jan Kiszka <jan.kiszka@siemens.com>
To: Henning Schild <henning.schild@siemens.com>
Cc: isar-users <isar-users@googlegroups.com>
Subject: Re: [PATCH 12/16] meta: Add expand-on-first-boot support package
Date: Thu, 13 Sep 2018 10:33:59 +0200 [thread overview]
Message-ID: <140f8df3-b0b8-8fe8-7ef3-a15bf1331330@siemens.com> (raw)
In-Reply-To: <20180912154610.363a1bbb@md1pvb1c.ad001.siemens.net>
On 12.09.18 15:46, Henning Schild wrote:
> Am Tue, 11 Sep 2018 14:05:52 +0200
> schrieb "[ext] Jan Kiszka" <jan.kiszka@siemens.com>:
>
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> 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 <jan.kiszka@siemens.com>
>> ---
>> .../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.
Jan
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2018-09-13 8:34 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-11 12:05 [PATCH 00/16] Cleanups, linux-custom fix, auto-expansion helper Jan Kiszka
2018-09-11 12:05 ` [PATCH 01/16] meta-isar: Adjust kernel params in sdimage-efi.wks Jan Kiszka
2018-09-11 12:05 ` [PATCH 02/16] meta-isar: Reduce grub timeout to 3 seconds Jan Kiszka
2018-09-11 12:05 ` [PATCH 03/16] meta-isar: Fix bananapi root disk specification Jan Kiszka
2018-09-12 8:57 ` Henning Schild
2018-09-12 8:59 ` Henning Schild
2018-09-11 12:05 ` [PATCH 04/16] meta-isar: Remove "=" after wic parameters Jan Kiszka
2018-09-11 12:05 ` [PATCH 05/16] u-boot-script: Become independent of target /etc/fstab Jan Kiszka
2018-09-11 12:05 ` [PATCH 06/16] isar-image-base: Disable rootfs check by default Jan Kiszka
2018-09-11 12:05 ` [PATCH 07/16] isar-image-base: Use generic parameters for rootfs entry in fstab Jan Kiszka
2018-09-11 12:05 ` [PATCH 08/16] meta: Remove ROOTFS_TYPE Jan Kiszka
2018-09-11 12:05 ` [PATCH 09/16] start_vm: Rename QEMU_ROOTFS_DEV to QEMU_DISK_ARGS Jan Kiszka
2018-09-11 12:05 ` [PATCH 10/16] start_vm: Rename ROOTFS_DEV to QEMU_ROOTFS_DEV Jan Kiszka
2018-09-11 12:05 ` [PATCH 11/16] RECIPE-API-CHANGELOG: Add ROOTFS_DEV/TYPE removal Jan Kiszka
2018-09-11 12:05 ` [PATCH 12/16] meta: Add expand-on-first-boot support package Jan Kiszka
2018-09-12 13:46 ` Henning Schild
2018-09-13 8:33 ` Jan Kiszka [this message]
2018-09-13 9:30 ` Henning Schild
2018-09-13 13:17 ` Jan Kiszka
2018-09-11 12:05 ` [PATCH 13/16] image: Limit ROOTFS_EXTRA to non-wic image type Jan Kiszka
2018-09-11 12:05 ` [PATCH 14/16] linux-custom: Simplify and clarify KERNEL_NAME-to-recipe matching Jan Kiszka
2018-09-11 12:05 ` [PATCH 15/16] meta-isar: Move init preinstallation into distro conf Jan Kiszka
2018-09-11 12:05 ` [PATCH 16/16] meta: Add enable-fsck helper recipe Jan Kiszka
2018-09-25 11:27 ` [PATCH 00/16] Cleanups, linux-custom fix, auto-expansion helper Maxim Yu. Osipov
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=140f8df3-b0b8-8fe8-7ef3-a15bf1331330@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=henning.schild@siemens.com \
--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