From patchwork Tue Dec 13 21:46:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Roberto A. Foglietta" X-Patchwork-Id: 2317 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Tue, 13 Dec 2022 22:47:25 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-pl1-f187.google.com (mail-pl1-f187.google.com [209.85.214.187]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 2BDLlNV8003840 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 22:47:24 +0100 Received: by mail-pl1-f187.google.com with SMTP id b17-20020a170903229100b00189da3b178bsf856285plh.7; Tue, 13 Dec 2022 13:47:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670968037; cv=pass; d=google.com; s=arc-20160816; b=OMIe7eMr4mrAzEMjMbgSlqlgyH7XwEgMjRLhAbmunKyuldv27WmhAdz0VuoL348IcP 5rUOnGJCETmapo1snoIyWXBBypgvd166jDJ3y2PPSl/NnXdFvo3rJSbrv+xaTlsCFDld WfDNo7VF/1ZikScSZhmFzHeGSbDbVC5F6bCrj12x6kWUvWOUbQE/9mIa8Vtv6KemNjAE 4H9/28Q5ztr3IXVLKbgqHWajL1kdgHiKn5eZzL82V0IODgOddviSlZNSceIfk8GF8JtQ Q/rnKKhMB4843qS8tETh/Hb6l/r3h5cP8tEjJxK0z6s+OTivOIxX5mnbpaXkgarUKLOb 4T4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:cc:to:subject:message-id:date:from :mime-version:sender:dkim-signature:dkim-signature; bh=UHgRXqSgbICWjxebswvqmzdSHmcPmCuE4g8tjAouiM4=; b=NS3HqSLSIcLXmb0N3jqg4OOYyaEbva6PVkRNyPDrQiOeUIyU8nCe9srMKS3Jz5qmHn /CKLwhaYgW4SqxKaZrG6CEYm/vhUFhaKa/zrVkUWifAuvJbQV+qFmYhc4981l8LZ1Da1 xLxLOCUneNDIH4tHt0390E303IHj/WgOHh4NtPa1WE6678gQbcx9BVIW8R+CmCacQojH qVr1csvaqIbYeMR8koi8WiYcd8u9OqRTPXfLflH6DlcMrQB0YFHNbPVjDfLLxD5zLPMC rspr6pPYPnv3HQBKcTNnFGqsl7uEDL5huPmHC6vUyk3V1uc9JMXp8x7iZsDkR/83EZvB YOMA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KMB1tW3w; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::736 as permitted sender) smtp.mailfrom=roberto.foglietta@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:cc:to:subject:message-id:date:from:mime-version :sender:from:to:cc:subject:date:message-id:reply-to; bh=UHgRXqSgbICWjxebswvqmzdSHmcPmCuE4g8tjAouiM4=; b=QLr3yBlL+XMuNwMuqDzjV1FFDWiISjEfTTkenKkS2CDg2pDSN+kixqFoIofQtd95Q8 UkEY9d8HKtZq/xUnZtap6n1XbCSwbJ2nCrJy55mWwtAnhoGYiDSGmJKzhZn8NhoTaMbU vUpmcfDi9xQuTGHOyMRsKgFy5G2jxftL3WmoDoUfscV19jiW2fU/gC/3p4mkTYY7kue9 61GPLQobsyubX/VSLSMjrvY6GgL/pk1+kxStsmuf3g5Etu1PrO27F7Sq8utQ6EU2DBp/ c9/rZPXSv0p7Nu4KCs61Pteme4kbVfAkiU3/dzHElt5rxA9IZm9jYoB4qWtxIDSuBR1J Pk2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:cc:to:subject:message-id:date:from:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=UHgRXqSgbICWjxebswvqmzdSHmcPmCuE4g8tjAouiM4=; b=OuS4ey2qqy0L39iBOQauuxgHT+Sl6C+IEULzOwlChhy0WF7Zy9fQYNvW2xaqK8hy5W B59ENzrRO3ljbdIF5lSCH2DjahSZZuc7y3v3utw8LjCUpNryi8lM+3el8+LfDGbC23wK xPzvKAcesI5tS3r28qRHmBw0V9Mu87dMVA/HDoeJpZDGLP2NDOVdyZRCYukGLW+bSw3u RU4gFNimJAEfxER+0CYTAc1UvK1thziB0YrYqfv/w6Wq0utoXSM20XMzD2ITupO3oMFm mJyX1Yi8xof+621NrjTVc3QC9TJnLPE9amYv52aM0NKZGUQi84t2yaUmNPgXnbTcTzpc CJqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:cc:to:subject :message-id:date:from:mime-version:x-gm-message-state:sender:from:to :cc:subject:date:message-id:reply-to; bh=UHgRXqSgbICWjxebswvqmzdSHmcPmCuE4g8tjAouiM4=; b=QwII3t1J/o9OBW+LcjjUxUf1I7nJ5bCrIf330eHRxWiA2SFILwLwmr2O9v5fAVthIp bXDIH4ReBuXndD7XBkDikZnhlWM1sx4/zIVlEd1TuX8mKHVUAyqpMysfZPnYSH37DjNK hVDETtQGK88lZXm/ZO7SCLd4syNofNDpwfsNZBeb11pQJXi4XqW4c9yrabfRnKxMisgx E6bN+sCB/GkhIkkDCgARbr24owPwKKA5g4y1kkDkHO1BEKTaGr2DeuZeJgA9FBTT3dAN 7ksrufHtk1plWfCPim4IcQHfRUU660eu3p6d4GMjyO2XOR0kgpMNyyG9Ddzm0hBddouF lhmA== Sender: isar-users@googlegroups.com X-Gm-Message-State: ANoB5pmeL2hLF9t0OKwlElil8wkVgT8vU0i3rdW81S6ItUNflhqvupLY trW0I1uuqDnUjVaPEYIoYWE= X-Google-Smtp-Source: AA0mqf78oIxLhVoYZM1IgD0BndRI6XGjGY3jSk8IWK7x2e714KSZZL10Yh0DbqHnHw/n2YEUKiUpxQ== X-Received: by 2002:a17:90a:658a:b0:219:4ee5:ccc9 with SMTP id k10-20020a17090a658a00b002194ee5ccc9mr29167pjj.63.1670968037573; Tue, 13 Dec 2022 13:47:17 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a17:902:f609:b0:188:b504:8ce4 with SMTP id n9-20020a170902f60900b00188b5048ce4ls20053869plg.7.-pod-prod-gmail; Tue, 13 Dec 2022 13:47:16 -0800 (PST) X-Received: by 2002:a17:902:8303:b0:18d:4b59:cae5 with SMTP id bd3-20020a170902830300b0018d4b59cae5mr17329426plb.49.1670968036530; Tue, 13 Dec 2022 13:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670968036; cv=none; d=google.com; s=arc-20160816; b=AokRh2oh7q5qRPrM/aZRTGfcixk4El+DKqPuvauMUpPr9LV6GOusuwWBN4w2i8orm/ HR2De9lmGo/xVt//NDBFU0mP1X8La5l45REnnviIoiz4UHl+KHg6z2O9to59SS5H1A82 wZd7JlX42gG6jr9gqm942OEcnEK5fIfzoF1q07KTxvoVTAAGLXHuqtGm2puUvFPz9fo7 3hVeva4dj5NxjjWlYgGU2F7hUqAOox22CdvBodBZTcunrYP+E5OxTcKj8METfQzhysH+ Q2Wl9Lcpej2uBq1r37M9cHr+AmU7szDryBVJQ39uT6Ou0SUftVRtN3ulupb6pFgVyech j7dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:mime-version:dkim-signature; bh=uAVKEmLrv8vBXEXd4sn9Elvwbmi9a/bC080Rmw/OXMA=; b=FLYAsBbI7U4H0e+3WjwxTcUb+rv+hdFrIl1k1gH/5fcI1lw6Ig4G8A78WAlFx/gc3A IBS0Qxul+faMJkhq4OSuwFCh54RHGlLcK01IqJ1KDPZ4JawxYv9bPkwerdoKUHGujTd4 wggwHrBeUwhozWe0yZy33MPTEusPllC4GfnwXVRoAJ+ulg8AxAqA540sMTCVTzr3O5tX u7l2/G35HK+1f8cJNgHHykpf3uaY9DpbxFCUVyymCFLOU/0OGVCG9cx5lIRjrcG2q7C6 6KTjBB6K8vDFB004WOlOAXUfmQp4OplyZSeGCCsVXgopfhcXOJjxXSq/41nCD7g1xWhu NflA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KMB1tW3w; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::736 as permitted sender) smtp.mailfrom=roberto.foglietta@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com. [2607:f8b0:4864:20::736]) by gmr-mx.google.com with ESMTPS id d2-20020a170903230200b00174ea015ef2si124667plh.5.2022.12.13.13.47.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Dec 2022 13:47:16 -0800 (PST) Received-SPF: pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::736 as permitted sender) client-ip=2607:f8b0:4864:20::736; Received: by mail-qk1-x736.google.com with SMTP id pe2so500605qkn.1 for ; Tue, 13 Dec 2022 13:47:16 -0800 (PST) X-Received: by 2002:a37:de19:0:b0:6fa:8954:b767 with SMTP id h25-20020a37de19000000b006fa8954b767mr68995476qkj.50.1670968035438; Tue, 13 Dec 2022 13:47:15 -0800 (PST) MIME-Version: 1.0 From: "Roberto A. Foglietta" Date: Tue, 13 Dec 2022 22:46:37 +0100 Message-ID: Subject: [PATCH v5] In expand last partition script btrfs support added To: isar-users@googlegroups.com Cc: Joe MacDonald , "Moessbauer, Felix" X-Original-Sender: roberto.foglietta@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KMB1tW3w; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::736 as permitted sender) smtp.mailfrom=roberto.foglietta@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Improvement, expand-on-first-boot: support for btrfs added v2: the mount point for btrfs filesystem to resize is under /dev/shm by default but a variable defined in the running environment can change the temporary directory path. The /dev/shm has been chosen because in some systems /tmp can be on a RO root filesystem and /tmp not yet mounted with tmpfs. This requires the system to have /dev/shm configured into the kernel. v3: the previous version was using a bashism but the shebang is /bin/sh this means that the script will fail in a customized system in which /bin/sh do not link to bash or bash is not available. v4: Felix suggested using mktemp for the temporary directory in which to mount the btrfs filesystem to resize. The default path /tmp could be changed using the variable TMPDIR to set in the running environment. v5: typo fixes into the patch description Sent as usual with elastic mail SMTP and went in moderation mode. Here in attachment. Best, R- From aab836d3de585b030b01b780bcf60249216c2800 Mon Sep 17 00:00:00 2001 From: "Roberto A. Foglietta" Date: Sat, 10 Dec 2022 04:13:42 +0100 Subject: [PATCH v5] In expand last partition script btrfs support added Improvement, expand-on-first-boot: support for btrfs added v2: the mount point for btrfs filesystem to resize is under /dev/shm by default but a variable defined in the running environment can change the temporary directory path. The /dev/shm has been chosen because in some systems /tmp can be on a RO root filesystem and /tmp not yet mounted with tmpfs. This requires the system to have /dev/shm configured into the kernel. v3: the previous version was using a bashism but the shebang is /bin/sh this means that the script will fail in a customized system in which /bin/sh do not link to bash or bash is not available. v4: Felix suggested using mktemp for the temporary directory in which to mount the btrfs filesystem to resize. The default path /tmp could be changed using the variable TMPDIR to set in the running environment. v5: typo fixes into the patch description Signed-off-by: Roberto A. Foglietta --- .../expand-on-first-boot_1.2.bb | 2 +- .../files/expand-last-partition.sh | 37 ++++++------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb index 0996000..fe7b72b 100644 --- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb +++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb @@ -10,7 +10,7 @@ inherit dpkg-raw DESCRIPTION = "This service grows the last partition to the full medium during first boot" MAINTAINER = "isar-users " -DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux" +DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux, btrfs-progs" SRC_URI = " \ file://expand-on-first-boot.service \ 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 4d55645..3bf5835 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 @@ -59,29 +59,16 @@ sfdisk -d "${BOOT_DEV}" 2>/dev/null | \ # Inform the kernel about the partitioning change partx -u "${LAST_PART}" -# this is for debian stretch or systemd < 236 -if [ ! -x /lib/systemd/systemd-growfs ]; then - # Do not fail resize2fs if no mtab entry is found, e.g., - # when using systemd mount units. - export EXT2FS_NO_MTAB_OK=1 +# Do not fail resize2fs if no mtab entry is found, e.g., +# when using systemd mount units. +export EXT2FS_NO_MTAB_OK=1 - resize2fs "${LAST_PART}" - exit 0 -fi - -if grep -q x-systemd.growfs /etc/fstab; then - echo "Found x-systemd.growfs option in /etc/fstab, won't call it explicitly." >&2 - exit 0 -fi - -# mount $LAST_PART out of tree, so we won't conflict with other mounts -MOUNT_POINT=$(mktemp -d -p /mnt "$(basename "$0").XXXXXXXXXX") -if [ ! -d "${MOUNT_POINT}" ]; then - echo "Cannot create temporary mount point ${MOUNT_POINT}." >&2 - exit 1 -fi - -mount "${LAST_PART}" "${MOUNT_POINT}" -/lib/systemd/systemd-growfs "${MOUNT_POINT}" -umount "${MOUNT_POINT}" -rmdir "${MOUNT_POINT}" +case $(lsblk -fno FSTYPE "${LAST_PART}") in + ext4) resize2fs "${LAST_PART}" + ;; + btrfs) tmpdir=$(mktemp -d -p "$TMPDIR" btrfs.XXXX) + mount "${LAST_PART}" $tmpdir + btrfs filesystem resize max $tmpdir + umount $tmpdir && rmdir $tmpdir + ;; +esac -- 2.34.1