From patchwork Thu Dec 15 18:06:02 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: 2327 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Thu, 15 Dec 2022 19:06:47 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-qk1-f191.google.com (mail-qk1-f191.google.com [209.85.222.191]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 2BFI6jiJ012803 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 19:06:46 +0100 Received: by mail-qk1-f191.google.com with SMTP id bl21-20020a05620a1a9500b006fa35db066asf6464816qkb.19; Thu, 15 Dec 2022 10:06:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671127600; cv=pass; d=google.com; s=arc-20160816; b=KqBi37IACksxyksm0TLIFlFVM1i6miQ/Xvz1n/JEaxT4oMdft1GfSTNZ094qTfBZeP M2Y3xljhZFWsHsUwsbWnbH3qO1NSY2aZHNAsCx57NyJA4bQAIzf2V6e39NO/yyRirJQW cI6giBbTCaCNZ7vmTdipXgHkcIG6EnwI4B+nxhW6rXxzFhoaBEI5YDLvmtaJNdk+DsaL 5rAnayTu1zl6KV8dshkVuA03f5xuTNdgGkMEApVlC8WDHP2rkqKqH7pKjSAuFXtu7Cxo OuLK1xlO8FIagfiosKgUv93jKBViwC+AAPZ9x2T8CGlj1Rtbw4NYSz5oZ5GyBnAuX1Zp VOQQ== 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=y4jjlMbpWBdS5/jyNvhokMoJ/nGow+DvLuCNVwLkWxc=; b=1LTAsDGCchfE0TRwCmOlaKyKe3lkyPAvUolxmPUMeSPcaNR9hKuPtGn9P4ud6JGPAf JTcsue0/Q2q4Khsq4vIa1d/SJ0uPp+jqE0FLogJHOkk0YPRKYr6uiGxLXz/5SUg06RZe GcMFNiyDovDLXQIcxyohGChiHwgOGtcQtYsSPrijllByp5jLSUIMoF1AF5s8mzJ07oJz +7QDd+YiGsLh4wMeqYSiR3++vNrLZkrb8zzhqVUfmlh1kg26m/ICPzEOWDW1lH8oWBCs iVlHa6cUrADlmwvBzmMPz9Pp4kbHMr/+ox+27IbP5XEwXEOrasMzuiOhsWH4AkITGCd9 vOzQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DnT6gFjX; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::731 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=y4jjlMbpWBdS5/jyNvhokMoJ/nGow+DvLuCNVwLkWxc=; b=bzeqbnVwSuNTwywy1ehtpdFIZ/wQNAGb/gUgHhNc1G+CPq9KWtmWppmvQf/GfP/RMi pIfjK8YXYKudJHUKHwsV3aXZl0gcXnfUPwmCc5mGfr+rN1FeDYZK9HNJHPjxVgjyzczh 3ufYGyMnDowmnCYVnaXwlewA8rdL2QIqf41/8BNe/RbgEOope8tRgoz3MJgmxlT0x/Mc GbnP3dde8+xao8OkJdquhUlALU57KOyL51Svp+KljJC0KF69ieuTA48BvBcEem9Ezuc6 4kJ5/WhpHTYJVtbu5meW0mvLeYR0q+kjP1iJ0RWBdeRDvW+gijfv/mxOFqaFOyq2JXMa iNfg== 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=y4jjlMbpWBdS5/jyNvhokMoJ/nGow+DvLuCNVwLkWxc=; b=ju8RdKJZSDCO7yZ9SVAsMSvYDsQj1W1IdWalQ+cJPKg+QIvJGykDDY5aDvU8qTVWbs bjt43Y9JhdmHvu+u94bKjUmGWH1y6316921PHjyaocZ/ZWnL9W3diBJDavuTRBP1p13j yUF2i5ONPw2omSMKRRifq0o0WKut+xxRmUBFXPInxxHDXTZdXgSgVRKACTW62nXbxL7M DkeAQMY9lB19GaOBpVlEqmBqvFt4F1BrPLB7YCE+7Il3GmTm2fXACd+xuaH+hy0ovbEN Spw5rt9QCUG6R9MkkxTYFJ+8b4cMeVKECVGYGoKBLmlGR7YnGt+zVmNWiPHew32weuD1 QlKQ== 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=y4jjlMbpWBdS5/jyNvhokMoJ/nGow+DvLuCNVwLkWxc=; b=U9IRwtz8vG3QVVP6zdZQaL+9iqfZQEQ7Y26uYanEqFkUHmKi34fgpXWnVt8mmqYJWm GsQAh0f5WsDAuzjP3RnypRNEeOs5xAg4WmIWhQNFlax1AIDyfHjcNMj3xiXQNibgO3Mk +jcMwjV/R2NXyl/zO3IqIAe0GK0neFNC+/e/Sp/57V4yW9ZJbpsRJHKQ+bys0rUgH5zz pgjpvOz+V7WIbp6W1QxFZxJ56Od17QOGpKvl0C1alVhTQvN10y5+3Pd/aUL47aOEnSRU +WROVFtCdR79EwOAF2h9jCpu6PaejXs2reI6RyoKoJ7Hw7EcFaxfWZ7qs23xRDmbUaax RPvw== Sender: isar-users@googlegroups.com X-Gm-Message-State: ANoB5pnEtjtI2vviRxsyBV1gCyEZzBss9EwBQKrSlTboHo5ZDKjDcd0V 44LvFUxc8CQfdX5HbMZHa7Q= X-Google-Smtp-Source: AA0mqf7EaaYZICv8PxQfdwd8EcUorFTXNoC1XN0F5RxIM8Cr7z+kYyKsKVW3DprnvObQXhxkp47O5A== X-Received: by 2002:ac8:70c1:0:b0:3a6:68cb:cabe with SMTP id g1-20020ac870c1000000b003a668cbcabemr57149576qtp.248.1671127599955; Thu, 15 Dec 2022 10:06:39 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:622a:5c88:b0:39b:34e:f248 with SMTP id ge8-20020a05622a5c8800b0039b034ef248ls117795qtb.6.-pod-prod-gmail; Thu, 15 Dec 2022 10:06:39 -0800 (PST) X-Received: by 2002:ac8:7418:0:b0:3a7:e599:1ee0 with SMTP id p24-20020ac87418000000b003a7e5991ee0mr37954683qtq.63.1671127599145; Thu, 15 Dec 2022 10:06:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671127599; cv=none; d=google.com; s=arc-20160816; b=zoO/v5r+Ba29lt6zczXoqjENRBchnimWjFyjpJiXS2Idr+ynZpQIK9ZZfz7WNKDmll kL4YR0L8TIgcgsmjd5gE9km1QhaeasQDQhhGyD71aD0i6MHyaGnMI60L816MRLfJUzUr PiFvkGWCJwZpwYCgSTOWpSqkJl4rzzwQNS8v40iqQwkB13xhyJKJPSMrpyOYr8RQ4ZEW 5PsIfJ5RrXNRqYDocY2vQDEZsnIJGOUxRWAfOwgP3wZfv2OB2sNL6Hr5EQTBA1VITdHt OyAHBHn9SHEswWa7dsp/fy4ABcTsySZ0kDKDxqWufZxq3JFE096s8YYZCi5dDIoArpjc EDVQ== 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=fw0gGctaER6wYcKdvQnOBJQ96tDaQae5ZvP2ex/Pw8U=; b=HldORJKieBj7jq+UNn646YXjfPCCLvITOJL/02KJasnrSMPbxwVxmBgr/9BMzsSTLe TmU/DDWKxSeqUenOzfViUjdkA2AFDYmJKh7Z8goCww/tsrdwMbNAwLF+eW3B0V0Wnsuq vepv+pgRMfufcp4No3mTwJoZu6c3YEGu1+u1yna8ulkrJlVavdSYyCqkXwxJMkQ2+ekV vE70VSOUBzPjGv2jwvuVcnFiYCRC6X3pt4L47K2qjA7kVcqgwucjRk23P15vFYrFefOD iBDMKiss2nPiFL2BUrtZZl+lCL5Lwhpe88/NXp90D5Dr/gjannPLryhp3ZAntmOw+8ZD nN5g== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DnT6gFjX; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::731 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-x731.google.com (mail-qk1-x731.google.com. [2607:f8b0:4864:20::731]) by gmr-mx.google.com with ESMTPS id l12-20020ac84ccc000000b003a7fa08057asi342487qtv.1.2022.12.15.10.06.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Dec 2022 10:06:39 -0800 (PST) Received-SPF: pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::731 as permitted sender) client-ip=2607:f8b0:4864:20::731; Received: by mail-qk1-x731.google.com with SMTP id h8so3000673qkk.8 for ; Thu, 15 Dec 2022 10:06:39 -0800 (PST) X-Received: by 2002:a05:620a:45a7:b0:6ff:9cee:d086 with SMTP id bp39-20020a05620a45a700b006ff9ceed086mr520643qkb.119.1671127598545; Thu, 15 Dec 2022 10:06:38 -0800 (PST) MIME-Version: 1.0 From: "Roberto A. Foglietta" Date: Thu, 15 Dec 2022 19:06:02 +0100 Message-ID: Subject: [PATCHSET] expand last partition script and its usage To: isar-users@googlegroups.com Cc: Anton Mikanovich 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=DnT6gFjX; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::731 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=-1.0 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_H2, 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?= Hi all, all these patches are just sent by elastic mail SMTP and they are waiting in moderation. * 9ab1ca3 - In expand last partition few improvements and a bugfix * 565e850 - In expand last partition trap exitnlog EXIT logs with simpler code * b207566 - The expand last partition might support full volumes also, to test * 0e1748e - In expand last partition checking the size is useless * 4112390 - If expand last partition fails, unsupervised systems reboot * f5a72cd - In expand last partition script btrfs support added * d3aded1 - In expand last partition wait for udev have finished I am going to attach them for immediate reviewing and they can also be found in this branch https://github.com/robang74/isar/tree/rafnext or they can be found in this branch which has been merged with the current ISAR next head https://github.com/robang74/isar/tree/next Files changed list: meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service Best regards, R- Signed-off-by: Roberto A. Foglietta Signed-off-by: Roberto A. Foglietta From f5a72cdfd3f429895893412b0c835edba223c608 Mon Sep 17 00:00:00 2001 From: "Roberto A. Foglietta" Date: Sat, 10 Dec 2022 04:13:42 +0100 Subject: [PATCH 2/7] 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 v6: mktemp does a reasonable second try with -p /dev/shm before failing 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..f5bcad1 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 || mktemp -d -p "/dev/shm" btrfs.XXXX) + mount "${LAST_PART}" $tmpdir + btrfs filesystem resize max $tmpdir + umount $tmpdir && rmdir $tmpdir + ;; +esac -- 2.34.1