From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7176514492887465984 X-Received: by 2002:a6b:8d4b:0:b0:6e2:fb39:a5d4 with SMTP id p72-20020a6b8d4b000000b006e2fb39a5d4mr1310190iod.45.1671010035368; Wed, 14 Dec 2022 01:27:15 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a6b:7f46:0:b0:6de:5786:c84c with SMTP id m6-20020a6b7f46000000b006de5786c84cls2892066ioq.5.-pod-prod-gmail; Wed, 14 Dec 2022 01:27:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BYLaeD9yD9HO0TK68qGBJ8hzqmvVNHi3HFXG4IX6v789OlXwdhApaBvOABX7Iy3u8ofF+ X-Received: by 2002:a6b:fc13:0:b0:6bc:d70f:8b38 with SMTP id r19-20020a6bfc13000000b006bcd70f8b38mr11721857ioh.18.1671010034730; Wed, 14 Dec 2022 01:27:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671010034; cv=none; d=google.com; s=arc-20160816; b=xvwfursx21Px/z9BWgpvJak+NNaHMqbHQErqd4JB/pSxeePnOojB7kiDzNssY8XydJ JHU8SzWys4QEujLGusBBMYWqY/MJXiGRP72FjDRjVpiKPs2EPSlMzHnDN7yfP0oj/jia qkFQols6moNVvGYEOsZxtj94u/DgY8JsmbLF22LonXw65Co51x6gkvEV4AbRPnqdjeHH JWGk+KI8a9s9EkH8OS6f81Yd0ZOZPjk3mKJMwKhsFOMDtyaatzuHaEZ5Rd4f23agieQm Wb2jo/yUv0EObUw5OmSKCkB/QdynNPSQ7sulC4kFrGeRGuOgSoXKoRiAUO0qig6bucVM IRdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=P8tBsV2sH/EoeAxvPKmfm814DcE0s3847vGOjP2K1AE=; b=rlxwtakekPgSl7B26sUzSRg2nOIyiMTheUTM+nM8nw3gI8PDKmhYKo7gWNZzVVUh5C +2TSiDA0JNjzFtwH4SGYZv9QrbYOH1NpI8iGpbgOn/JEcU74iYXw90aRZY2HmxhgFgRq tBsZp9t94a6UurOxIgqfdRPkyqpZTbhKZyswvG5k1f0FcEK3MQMmQGz3dPPpNIdzXujs Donxx+AugqWGhCZ1jEZd44QhAMv2pVzqikD36EhnEOCSM54DkcXN7KGM2H8f7HEbWx6q HoSMfOc2WyxiLNbO4D2oK6Qqltq63Fw2vctk6DN9Fu5OHZJfJV2i+/BZ/noODBYlKGoe 4z/A== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GEKUTIfj; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::f2f as permitted sender) smtp.mailfrom=roberto.foglietta@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com. [2607:f8b0:4864:20::f2f]) by gmr-mx.google.com with ESMTPS id z20-20020a029f14000000b0038a5b827993si281635jal.2.2022.12.14.01.27.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Dec 2022 01:27:14 -0800 (PST) Received-SPF: pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::f2f as permitted sender) client-ip=2607:f8b0:4864:20::f2f; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GEKUTIfj; spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::f2f as permitted sender) smtp.mailfrom=roberto.foglietta@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: by mail-qv1-xf2f.google.com with SMTP id mn15so12142282qvb.13 for ; Wed, 14 Dec 2022 01:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=P8tBsV2sH/EoeAxvPKmfm814DcE0s3847vGOjP2K1AE=; b=GEKUTIfjxFUouNQzypR7Hp6QCHHYsYbb3XDFvGFfNKwXS8cNFdYUeeSiHW1jLvcFs2 04w3ZxV3+wsrz79/vsEUoG07eprWI2+YEnuGGoOgwVgH3JSLV4NG3wd8xkByUPlb0xGz 1vbwEeTkA9KZpYCirJLIpgcslV5b20rDoN7P1dhm762Lpqjk5nxhr8s3UtYMpMCrNAwa bw7Fn8EY5E8rB5TttGQAxlXICBQpnIlSqYbzl90wLU594SU+IALM2koj+fwy51T6Wn72 /SqeDL/1z2Tu7hxGTFLGNK7t6ca9jsINzojE00GNxQIie4SjhfaldjOQJd/3HhxtScoF xZ/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P8tBsV2sH/EoeAxvPKmfm814DcE0s3847vGOjP2K1AE=; b=7rBawZbu8FefCLFRxnUhOSx4OMQa7fcRvl3ou9hWMs4VFBaoQAlnwUoluqx9ygLJqr Vqa5jMI9Cw46hlDi2v24yPEiY0cjGbcHbCdE1IUt4dWNm6/pcrbtlD9lKYsKKjOpy5Qg aOSpl5wsiEM9DegzgmrGAhvnk8vZvzNddFWgcQkxavVg7N+AEjgvhWV2PJ7Q+4GUVEq9 9Ub8P+C+AFV7Qs7jyZYBZElMqv71/dH7rq/aobaSn7K7dSsRrvwORSGlU1iA5812/zQr 4wyMP9dOQ6iM6HLcaat1SEAd2u9ym7QqyxULU08v20cr1ssV3ELQxFKi0LpD4w9Y6QE8 uzvg== X-Gm-Message-State: ANoB5plKHdj7miR6k7jdZJJz7i9hLMHN8lyrG7u5QItn9X7JN7QwsFhK QlcU72zIfo2Y4Q/4y16dtA6ZmWuaDGl9IJW6B78mG4ZegBuk X-Received: by 2002:a05:6214:4d:b0:4c7:272b:274c with SMTP id c13-20020a056214004d00b004c7272b274cmr30851028qvr.32.1671010033897; Wed, 14 Dec 2022 01:27:13 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "Roberto A. Foglietta" Date: Wed, 14 Dec 2022 10:26:38 +0100 Message-ID: Subject: Re: [PATCH v2] If expand last partition fails, unsupervised systems reboot To: isar-users@googlegroups.com Content-Type: text/plain; charset="UTF-8" X-TUID: ZeCZCL6eVmYw On Wed, 14 Dec 2022 at 08:52, Roberto A. Foglietta wrote: > > 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. Hi all, Moreover, I tried to resize a volume without a partition table and I did successfully in both cases ext4 and btrfs. So, if we are able to resize the last partition when that partition is the rootfs on which the system is running, why are we not able to do the same with the entire volume? ##### BTRFS ##### losetup -P $(losetup -f) image.wic losetup -l | grep image.wic | cut -f1 -d' ' dd if=/dev/loop3p2 bs=1M of=/dev/sdb status=progress mkdir /mnt/sdb mount /dev/sdb /mnt/sdb df -h | grep sdb btrfs filesystem resize max /mnt/sdb df -h | grep sdb umount /mnt/sdb losetup -d /dev/loop3 ##### EXT4 ##### losetup -P $(losetup -f) image.wic losetup -l | grep image.wic | cut -f1 -d' ' dd if=/dev/loop3p2 bs=1M of=/dev/sdb status=progress resize2fs /dev/sdb mount /dev/sdb /mnt/sdb df -h | grep sdb umount /mnt/sdb losetup -d /dev/loop3 IMHO, that code above should be just set properly the LAST_PART variable and then skip a lot of code useful only for a partitioned disk if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then LAST_PART="${BOOT_DEV}" else LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)" [ and everything else until the export of EXT2FS_NO_MTAB_OK ] fi This because trying to resize a volume full does not hurt nor fails: root# resize2fs /dev/sdb resize2fs 1.46.5 (30-Dec-2021) The filesystem is already 30041088 (4k) blocks long. Nothing to do! root# echo $? 0 root# btrfs filesystem resize max /mnt/sdb Resize device id 1 (/dev/sdb) from 2.04GiB to max root# btrfs filesystem resize max /mnt/sdb; echo $? Resize device id 1 (/dev/sdb) from 114.60GiB to max 0 However, to check these changes we need a system template with a single volume to test the code. I left this task to you. Best regards, R-