From patchwork Wed Dec 14 07:22:43 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: 2318 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Wed, 14 Dec 2022 08:23:28 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-il1-f184.google.com (mail-il1-f184.google.com [209.85.166.184]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 2BE7NQfU005723 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 08:23:27 +0100 Received: by mail-il1-f184.google.com with SMTP id l13-20020a056e0212ed00b00304c6338d79sf4047368iln.21; Tue, 13 Dec 2022 23:23:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671002601; cv=pass; d=google.com; s=arc-20160816; b=PxIfVgDdXudgzMuhfmOFTFRTrxp5GLQF3afSLWsFU7G8Ck6ejRFVqZwznbzD4+pKNV SDNzdmffZ6ptMlCg0zqLctv0BywoyPjRE/p8pRT5T4wzYhQ1q0hI65DLPX1a7bG6igOF V98EdxIZoUthVrfTmqhVkCZ8tR1yUj5nQYPrv+nKLrpLMltawPEdXEQlH5BhtfqcN6xI t+oDJLtxAAV/T8Q7FC6kL6OMBw8tATLZCyB9Rrh4vxoctcky6e5sAS/fwx0znsUeQDqU r3QYWJyeAgL4JhgAWC+i95olzk7jmyl1t+DIzYRKYikujrEO261SeKixFipaXue/FcLQ 5rgA== 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=h+v4Y/NdN3ugGcAE7y7ci257W6ODCvXcWGJYlQKYzFM=; b=PPLococ1Rv+Jhd7u+h0u/bOBecMK444dF+JnnTSo/Ycy8pJtEyFZUnIbrK4paZQ59Y QxpwQi+NgENHrN3vsQJyEdmv69tHXtupnnVdVb/AnWamxrrxsF95UsEkSB9LRG8xC2w4 wKbifGUPv8i7/h9OxiJfRSMAkjb/7kQXEI10ZvHZJhFdQ/AW5xXGWa+hOCI3bMk5D23P I1nl4I9fIoaEjitMRZ+d3GTXmN7i2Whw9lm5irWdpcaRcNKixJcd+FfdzOd7PHAmb7HO I5q0eSCytTnyF8OXdx0hadghfuR9kCKRj9tzfkXuBJFlhOZOA/wbQNxySSORW8BdG+5i FxSQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fl4zmMMK; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::732 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=h+v4Y/NdN3ugGcAE7y7ci257W6ODCvXcWGJYlQKYzFM=; b=XlAHEPa+aHiU9C77IZrlnh2GgBpQ5lSMUbBB0Vi8jN57xM7LzAsnGov+/d0jdQLcfZ 3m+t4fYWnP0WvJIfl0BPUHo1m36u9FSQeHQMUSqSXKMHBwliBO2r1e+FZkABScsEfEI9 grxDQmBMO3kqc4JftBLxrrqVflDgEnwBNIJwQQqSZ0g/bFpifXkqUZWVyq7FrN8JGTOl 1JP62Sm5SCelG/gkYkAnqK/Vus6YNxhprzsOM0ON2iF/HOV5bm6/b8TGbyKU1wBZ3ID7 ut+D56X7nse3RFMyAINs9pZajqnpecyXRysmLONo5ySUpyv7ghivu1fdgfSw9phACwpO ZNMA== 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=h+v4Y/NdN3ugGcAE7y7ci257W6ODCvXcWGJYlQKYzFM=; b=qE1na+yLTAHlY26tuoFNsJV5FK7L3tA4mZQgKSDROstl/7RH0b3/bwt9e4mfUHU4n7 pRVsxaJKyhXvU82oCVuvoPecroEfaeqQOJBuiEbLo/3puSlsfor7x6245NGl97Rj0A1c oZ/XEOpcYBJV3FfaCrXJfei74xs1agIHQibI7lFPW8RiS4/PpJxPQfeqMgLconRVLcSu fJ9wNSEv4TzRW56X61Sm7ORPzfCN8Lb6uUm3kptgJIz7c13R/bKSOiTKLla4AAh0JGJX BkX1TbXMEB+yjy3i9odrdZDpZrcKfBlxk+U/QstdprxYJrSyw+23Wy8MjrtHtBZdjGTr 7ZoA== 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=h+v4Y/NdN3ugGcAE7y7ci257W6ODCvXcWGJYlQKYzFM=; b=pV9KYpqQVM/g0uISTCshS7UFQiAnmg0qn6Lb0BivPVfa3f3BUpbc75Ambgid9UD5U2 +ik8e4HULe4fk7TiXCSHp5ujbxgL+42TzCy3uuvBo6iryFcsLAA5VQXpLNs4UWP5Sh2T YDNI2Xz/dtD46UzOqu5W3fSGA7veQ5DO8/ib36nKrHbNvl31cH7xpOMi8OrLC0E3BPiE dM+x3PUksD4azcLZaUsc5LWrsv19ZHJq69PdmBdQ9lMDuXrRkIJCZex4rpxv8fgpFLoO oeCDuLuDrMnrPzYduUA7yCWHkErb2OsP+v/MvNd6B06OFuBOFsq+sTVXhssvRxbhyT6+ vmbA== Sender: isar-users@googlegroups.com X-Gm-Message-State: ANoB5pl4mq+RrjAkIdEeCXwOnOWtaHuvzzkmKhZhlPzslEfIuPeACZ4P 14oOseAgigGOv0CS68xgDd4= X-Google-Smtp-Source: AA0mqf6d8nQMnKrsIWm3apdAyupKPLyNHt+wmXwlJ1MqN9+zDeUDEG2urzCxh3AuX2MJrxYXv4RDOg== X-Received: by 2002:a6b:fb13:0:b0:6de:383e:4146 with SMTP id h19-20020a6bfb13000000b006de383e4146mr37640993iog.48.1671002601123; Tue, 13 Dec 2022 23:23:21 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a6b:144e:0:b0:6e0:16e5:8907 with SMTP id 75-20020a6b144e000000b006e016e58907ls2855288iou.7.-pod-prod-gmail; Tue, 13 Dec 2022 23:23:20 -0800 (PST) X-Received: by 2002:a5d:9284:0:b0:6df:3b35:4a2d with SMTP id s4-20020a5d9284000000b006df3b354a2dmr6075530iom.16.1671002600590; Tue, 13 Dec 2022 23:23:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671002600; cv=none; d=google.com; s=arc-20160816; b=B1boXSBjBH+tayM7A7r85OJ0ftxTT+q/kUoFg3dZzSdh14mcFO2kTKAMWdeM8p9d2q B2MnRMUSAKHXw4E+hJjheYfnO8Klp1QUdTgDLnethi9Z7D0XYAXP6lMPUIINR2Xh3h1X zrqdII1EFKG2wfVYkiFNLO3Feebp5htAXPwGb/RzGNdhNtg9jByNvpI1R8pETZpCi/gS Sqa/Dnk/ZJmNRdjMCbS66O2BmVoeiP6oZ2bJdCnE9ODAKCbHEELvM7R0TnfoYmbRuAKu dbR6ooXPDcivlY/+OEIJH+0i+TD9CgkbjZ7lIpIVMrlao4q1jwuNGQBYDZHLsENObng0 aPTA== 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=LNfV5n8N5G6EBLJMJcirnO6Sp6+/I8cqXzJmlwHBdGU=; b=uyOIxhOz1WAWMxcJs4OplIztDPR1T091z5t5iAhOzHIlpO0Xqdk1yTEUpH5we0tsxG 4umwXkMl5o8p++Sk+6ShzfCzoXJvYXCIHZBvpcK1/NZgYibKvbfR8/vH3gFfX0TaR1LA qtns+9cygJpBp7c6xBL+RCFsvDIM2MHn+ZxmraKcbgDukXJGXPQ4mXhcdaKsQ7xMrY7X 97KDaUxtMPNpfz6MC1YGugPTz2YBKdB1ekhJZJr4Jyp0sj4gqiPaqgRRmKeeeboeh66L D8Cc370NM5vOoB2Ofhn5OKgcZMWKz9Ydb8MuK28TSh7WPFnPUaySO4+xn1IrKMCG5sx9 uiGg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fl4zmMMK; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::732 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-x732.google.com (mail-qk1-x732.google.com. [2607:f8b0:4864:20::732]) by gmr-mx.google.com with ESMTPS id e8-20020a02a508000000b00389e1c7a64esi310642jam.6.2022.12.13.23.23.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Dec 2022 23:23:20 -0800 (PST) Received-SPF: pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::732 as permitted sender) client-ip=2607:f8b0:4864:20::732; Received: by mail-qk1-x732.google.com with SMTP id x24so889844qkf.5 for ; Tue, 13 Dec 2022 23:23:20 -0800 (PST) X-Received: by 2002:a37:de19:0:b0:6fa:8954:b767 with SMTP id h25-20020a37de19000000b006fa8954b767mr69036922qkj.50.1671002599775; Tue, 13 Dec 2022 23:23:19 -0800 (PST) MIME-Version: 1.0 From: "Roberto A. Foglietta" Date: Wed, 14 Dec 2022 08:22:43 +0100 Message-ID: Subject: [PATCH v6] 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=fl4zmMMK; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::732 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,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?= 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 Sent by elastic mail SMTP and gone in moderation, also here in attachment. Best, R- From b5a81d68365c5b0a1326a6be3af9494f4fceb353 Mon Sep 17 00:00:00 2001 From: "Roberto A. Foglietta" Date: Sat, 10 Dec 2022 04:13:42 +0100 Subject: [PATCH v6] 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