From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
To: isar-users@googlegroups.com
Subject: Re: [PATCH v2] If expand last partition fails, unsupervised systems reboot
Date: Wed, 14 Dec 2022 10:26:38 +0100 [thread overview]
Message-ID: <CAJGKYO6krGyEnF-g_XL23GRiDK+0w-UGzmdon9HUtg0rX_BW_A@mail.gmail.com> (raw)
In-Reply-To: <CAJGKYO4jQ=b43n+qASC0U8bAzON6R0WSgJhzWhR3Or9ZXyZBKA@mail.gmail.com>
On Wed, 14 Dec 2022 at 08:52, Roberto A. Foglietta
<roberto.foglietta@gmail.com> 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-
prev parent reply other threads:[~2022-12-14 9:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 7:52 Roberto A. Foglietta
2022-12-14 8:47 ` Henning Schild
2022-12-14 9:05 ` Henning Schild
2022-12-14 9:24 ` Roberto A. Foglietta
2022-12-14 9:26 ` Roberto A. Foglietta [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJGKYO6krGyEnF-g_XL23GRiDK+0w-UGzmdon9HUtg0rX_BW_A@mail.gmail.com \
--to=roberto.foglietta@gmail.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox