From patchwork Wed Dec 14 07:52:00 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: 2319 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:52:44 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-oo1-f55.google.com (mail-oo1-f55.google.com [209.85.161.55]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 2BE7qha5005883 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Dec 2022 08:52:44 +0100 Received: by mail-oo1-f55.google.com with SMTP id i3-20020a4a9283000000b004a05ad0a3e7sf6100303ooh.6; Tue, 13 Dec 2022 23:52:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671004358; cv=pass; d=google.com; s=arc-20160816; b=PNi51RCv0ycQ7W6fz6Xb5NpNkhFx9TMuyO7dGN6LcgvT2OVxc0DO6JxmAIe6kYt5Jz +fjAD3ahxVRSKCh4iGlTiYSXq277H9ijt7qptwY+Sxn5Qrjnlua7nWkrrMjholrYD8UJ ndCg//21OqLIb9MTYmypS6/3aC3ZRoyS7qs6Bvxw0h0u96mZ/scDXK8JOzHI6OU+MI8s g4eYZWrpFLI8Dxd2w5r5wNkHMqNrAv4KOEzce2rCW3RZ+yf9oCJq2rFHqlbjGe+2c9OR qSaFWOfZO4IHOPqXvQlvrQ1Pgm8V5ggLcyBZl86p5f2sRr371ShkRjtVv+pKgwHWkTqw zz3Q== 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:to:subject:message-id:date:from :mime-version:sender:dkim-signature:dkim-signature; bh=09i6abwrpWAsmQes9CJktSrAD9G8r26tsBK5cbqTOO0=; b=SaFgdzgQafFnD8zPILyIi7dFRwuLYLXkhUlTmSTHxPdiPDfeezm9x/wpxXdS85eXkF YNKiOuIzVPKYEeRL+wdCXqQPrpISghlgqBBAchvFPVYgzlxfQs4Gg4xF03eGHKK3kyen Rv/YP55DF0PK+05YG0xQv6MY9+YHMfHMbx3genGWRX+FO7CmfHLmzdE+f/B5ER+wnGkH QTweXjKBcCvua5d6myK5fchMAEPMZ9oxkMz22NQAcfYw/J9VHKi+15BbysB1DeLWv04b W0koalX4RLlObvxlJCZbGeDXMm8chlBSKkWUZt317o3KRZxEclNRTyWgT32Sy1EboJOc w8Lg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YYKLFE1h; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::82a 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:to:subject:message-id:date:from:mime-version :sender:from:to:cc:subject:date:message-id:reply-to; bh=09i6abwrpWAsmQes9CJktSrAD9G8r26tsBK5cbqTOO0=; b=DxMpSiZBG6YMXQR1CEZ564WyLtKr/C54u4nZteFyBlpPqpZlQnL9cw4cSHr/eQz212 tS3He84hitsH9DQPM3LBVCOcv/xn46i6AZ0vZvkwmwkaUNb85jPTN+KKVhNVO+sp8CqO +EtuQsTPb/pzlpSg02/7GxU2KJQp5CdjyXl1K/MEt9HJ+fbaNRJ3N0kuazNyCCLxT3ye XsLucTxMi5hmN1YADK4zGiJLf/qwxCHObWAeWt82Wqx5wksL9Sk8huF6hn0KPOC6VRbt cMODqN9n/HhpjDC113vc2+pgGqg8VKp5fAlNnr0ITxC5FRLaKgpXs48CYReCeCzNCOcZ taRA== 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:to:subject:message-id:date:from:mime-version:from :to:cc:subject:date:message-id:reply-to; bh=09i6abwrpWAsmQes9CJktSrAD9G8r26tsBK5cbqTOO0=; b=DJ7upR6Wb6h03mXM3YEq6cZFCqyOdDJTTPGDa1F58mnweHBgOOCc6q3sTL91WnpK4I ySiRNvlOacxykGpgpsztIz53rLbBoOwua+QGOhJbgNbT4LcJPdTOR7IW0u/cDQxmr8jy y6E6yMNRdrCBhUpVPh4ZMSmlrMAJIvRQYZhq7efF5iiYJEL0Ie7w87oFYqxVQIWqsA3J 6D2m1e5ekzoNc3zgWvLl7J7PIH7mzWt2Vsc2QsykpDw1mhTqM5l+CTfwE8k+qxGfBFRc KcBtdL6NOqitXfoUSn6o1u0MLP+Xwwqo/tKX8rY0sapRfncbjPmhsZ3d+0Lu8W4WURUZ bBWg== 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:to:subject :message-id:date:from:mime-version:x-gm-message-state:sender:from:to :cc:subject:date:message-id:reply-to; bh=09i6abwrpWAsmQes9CJktSrAD9G8r26tsBK5cbqTOO0=; b=iQsRH+iKFSCIJI9dyWVmgm4LGMcpPX0MVqc20qpltzAZIqaLGP1A6gSqje+dKMB+CH 1VdDyecsITKtJaizUYVNOr4uU1zGNyuoITFBtqBRJWfxf/3SSWbB33tNWkmHCzYIMIy7 ssAw2A/KTsbJ3w3zF1ExpozB+H8oXelrDO3jW/TsQcMQza3mXvnMQby7Xwtclb9IRJKl NHIA1FDFpv5R5sikPr/Vn9/KcSpzXD+Xclfu1Z6XmQ4uYG1n/05SBAA+q0LO85NiCGsw Mq9ABi/2aRkL8Y1qMwHUwckxuKrT/fnKfEJaWmOCUmnCV26qMDFfQd0dj4OGrC7loPU3 Ft0g== Sender: isar-users@googlegroups.com X-Gm-Message-State: AFqh2kqYahCFJt7MV44wIYD4do+pzkq3U9l+svyBYAITeP50+CBrEQkq n+OujEPcTOkjLln/w7lqF1I= X-Google-Smtp-Source: AA0mqf4kyvhULneVHGQRgE82h9Ua2ivqeosN3SeSbhGkxEPFZqYmG/c196xoxYyqG/hw2Bmc/7sjfw== X-Received: by 2002:a05:6870:5ccb:b0:144:5572:4aeb with SMTP id et11-20020a0568705ccb00b0014455724aebmr208293oab.186.1671004358007; Tue, 13 Dec 2022 23:52:38 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:aca:1906:0:b0:345:9a88:c799 with SMTP id l6-20020aca1906000000b003459a88c799ls1056321oii.5.-pod-prod-gmail; Tue, 13 Dec 2022 23:52:37 -0800 (PST) X-Received: by 2002:a05:6808:2d8:b0:35e:5b18:2ad1 with SMTP id a24-20020a05680802d800b0035e5b182ad1mr8717832oid.55.1671004357424; Tue, 13 Dec 2022 23:52:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671004357; cv=none; d=google.com; s=arc-20160816; b=Z/hen8reAqpTuhnfbvhBHhp8xWy9euh8RxEbc86cfY0uji+yNRcMrzxjutQMUda8RH +hYCygkpA+nL+LEofxjv0e8NzEWCfCXZ1T+eFGg1hyn9j0Z7lD2Fi+oLbrKaoZ8uFk8r VsMkQEIdHD8Gwpc9tfUrmMer4TnM8OHJXLNm8/gGhvBjdIZBI3m+4oe/liAo0uyYmgfH fPvhauWs5rn+oAq1IWZ6/CwquqHEEcmVGEpgytHR/Hsnxt+ZZVzIFm0qiSXk1QJ0vg9t qhmV3sWp2+kZOBbzVAw7/D+zVT6aHgjLI62pXmVJjS5AmQbmFwOPH0nqCuyx9y+ZWZ1Y MAAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=GzVCme8a/4P33eNLUEToFzEZdBzvWeHTBabxxMMsNTs=; b=fsU8jPbCeIA1sACpZS7FcSisMls0IDVirX6ebiLFHLJjPFGdcSLtcqiI0S90H7+KDD 7Xlbw3tzulh+Vr0RZPHoe7vZN/KQetBMsjkJuayPkMAQGTx1ja6J5Qx95j7mGZJZZ38u dD41ku8lI4hH+lVI9ub33e7s2dngPtG1QpEamTS5QhGVz7xInOFA+AkOIeIJZbkramdp O0EdlVxcGCgTv92yKwUIbnAZildxvHRzAtmUwmgqUjiTwcehxsZtfs/sYwROu8lc9DsY JkUUzx8//b3iOJ3++6YMM4oqph5Mv/SvjHNNkQUY0xaJ7goWxcZ+O3U6tbBmpa5cFZZ7 CZMw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YYKLFE1h; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::82a as permitted sender) smtp.mailfrom=roberto.foglietta@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com. [2607:f8b0:4864:20::82a]) by gmr-mx.google.com with ESMTPS id p8-20020acad808000000b0035446541a0fsi813559oig.5.2022.12.13.23.52.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Dec 2022 23:52:37 -0800 (PST) Received-SPF: pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::82a as permitted sender) client-ip=2607:f8b0:4864:20::82a; Received: by mail-qt1-x82a.google.com with SMTP id fu10so1962848qtb.0 for ; Tue, 13 Dec 2022 23:52:37 -0800 (PST) X-Received: by 2002:ac8:4e14:0:b0:3a7:648d:23d3 with SMTP id c20-20020ac84e14000000b003a7648d23d3mr17807203qtw.19.1671004356648; Tue, 13 Dec 2022 23:52:36 -0800 (PST) MIME-Version: 1.0 From: "Roberto A. Foglietta" Date: Wed, 14 Dec 2022 08:52:00 +0100 Message-ID: Subject: [PATCH v2] If expand last partition fails, unsupervised systems reboot To: isar-users@googlegroups.com 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=YYKLFE1h; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::82a 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?= Hi all, in the expand last partition script I read this code 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 trap - EXIT exit 1 fi this means that there are no partitions because the boot partition /dev/sda is equal to root partition /dev/sda, which happens only when there is no partition table. roberto$ echo /dev/sda2 | sed 's/p\?[0-9]*$//' /dev/sda (which is different than /dev/sda2) roberto$ echo /dev/sda | sed 's/p\?[0-9]*$//' /dev/sda (there is no partition table) That's ok but not exit 1 because IMHO, it will retry again the next time but nothing will change the next time so it will continue to try and fail at every boot. Because one-time-only in systemd means one-successful-time-only and exit 1 prevents disabling the operation. So, exit 0 would be the correct code to execute and this is the reason because I removed the trap which would make an unsupervised system reboot. The patch v2 has been sent using the elastic mail SMTP and went in moderation, here in attachment. Best regards, R- From 14cff2bc150b1be77d5de4253ac3e92df2b4b0f9 Mon Sep 17 00:00:00 2001 From: "Roberto A. Foglietta" Date: Tue, 13 Dec 2022 07:14:25 +0100 Subject: [PATCH v2] If expand last partition fails, unsupervised systems reboot Improvement for unsupervised embedded devices which need to reboot if expand last partition fails because a under-provided system should not even complete the boot in the field in order to avoid functioning failures at unexpected future time. This patch do not affect the previous behaviour because requirs /etc/unsupervised This patch applies after the following other patches: - In expand last partition script btrfs support added - In expand last partition wait for udev have finished v2: if there is no partition table exit 0 instead of exit 1 Signed-off-by: Roberto A. Foglietta --- .../expand-on-first-boot/files/expand-last-partition.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 f5bcad1..2c52b16 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 @@ -9,6 +9,8 @@ set -e +test -e /etc/unsupervised && trap reboot EXIT + udevadm settle ROOT_DEV="$(findmnt / -o source -n)" @@ -21,7 +23,8 @@ fi 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 + trap - EXIT + exit 0 fi # this value is in blocks. Normally a block has 512 bytes. @@ -37,6 +40,7 @@ done MINIMAL_SIZE=$((ALL_PARTS_SIZE + BUFFER_SIZE)) if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then echo "Disk is practically already full, doing nothing." >&2 + trap - EXIT exit 0 fi @@ -72,3 +76,5 @@ case $(lsblk -fno FSTYPE "${LAST_PART}") in umount $tmpdir && rmdir $tmpdir ;; esac + +trap - EXIT -- 2.34.1