* [PATCH] expand-on-first-boot: Switch from resize2fs to systemd-growfs
@ 2022-05-25 12:32 Tobias Schmidl
2022-05-25 12:47 ` Jan Kiszka
0 siblings, 1 reply; 6+ messages in thread
From: Tobias Schmidl @ 2022-05-25 12:32 UTC (permalink / raw)
To: isar-users; +Cc: Joe MacDonald, Tobias Schmidl
We want to be more versatile in our approach of resizing the root
partition. Therefore we switch from resize2fs to systemd-growfs (on
systems with systemd-growfs).
This allows for ext4, btrfs, xfs, and dm-crypt partitions to be resized.
Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com>
---
.../files/expand-last-partition.sh | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
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 bb371e9..f0dc66d 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
@@ -3,7 +3,7 @@
# Resize last partition to full medium size
#
# This software is a part of ISAR.
-# Copyright (c) Siemens AG, 2018
+# Copyright (c) Siemens AG, 2018-2022
#
# SPDX-License-Identifier: MIT
@@ -45,4 +45,15 @@ partx -u "${LAST_PART}"
# when using systemd mount units.
export EXT2FS_NO_MTAB_OK=1
-resize2fs "${LAST_PART}"
+# If we are on a systemd system, we call systemd-growfs, otherwise resize2fs
+if [ -x /lib/systemd/systemd-growfs ]; then
+ MOUNT_POINT=$(findmnt "${LAST_PART}" -o target -n)
+ if [ -z "$MOUNT_POINT" ]; then
+ echo "Cannot find mount point for ${LAST_PART}"
+ exit 1
+ fi
+ mount "${MOUNT_POINT}" || true
+ /lib/systemd/systemd-growfs "${MOUNT_POINT}"
+else
+ resize2fs "${LAST_PART}"
+fi
--
2.36.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] expand-on-first-boot: Switch from resize2fs to systemd-growfs
2022-05-25 12:32 [PATCH] expand-on-first-boot: Switch from resize2fs to systemd-growfs Tobias Schmidl
@ 2022-05-25 12:47 ` Jan Kiszka
2022-05-25 12:57 ` Bezdeka, Florian
2022-05-25 13:04 ` Schmidl, Tobias
0 siblings, 2 replies; 6+ messages in thread
From: Jan Kiszka @ 2022-05-25 12:47 UTC (permalink / raw)
To: Tobias Schmidl, isar-users; +Cc: Joe MacDonald
On 25.05.22 14:32, Tobias Schmidl wrote:
> We want to be more versatile in our approach of resizing the root
> partition. Therefore we switch from resize2fs to systemd-growfs (on
> systems with systemd-growfs).
Just for the sake of completeness: Since which Debian version is this
the case? I assume buster is fine, right? But stretch was not.
>
> This allows for ext4, btrfs, xfs, and dm-crypt partitions to be resized.
>
> Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com>
> ---
> .../files/expand-last-partition.sh | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> 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 bb371e9..f0dc66d 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
> @@ -3,7 +3,7 @@
> # Resize last partition to full medium size
> #
> # This software is a part of ISAR.
> -# Copyright (c) Siemens AG, 2018
> +# Copyright (c) Siemens AG, 2018-2022
> #
> # SPDX-License-Identifier: MIT
>
> @@ -45,4 +45,15 @@ partx -u "${LAST_PART}"
> # when using systemd mount units.
> export EXT2FS_NO_MTAB_OK=1
>
> -resize2fs "${LAST_PART}"
> +# If we are on a systemd system, we call systemd-growfs, otherwise resize2fs
> +if [ -x /lib/systemd/systemd-growfs ]; then
> + MOUNT_POINT=$(findmnt "${LAST_PART}" -o target -n)
> + if [ -z "$MOUNT_POINT" ]; then
> + echo "Cannot find mount point for ${LAST_PART}"
> + exit 1
> + fi
> + mount "${MOUNT_POINT}" || true
> + /lib/systemd/systemd-growfs "${MOUNT_POINT}"
> +else
> + resize2fs "${LAST_PART}"
> +fi
I wonder if / how long we should keep the two paths...
Jan
--
Siemens AG, Technology
Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] expand-on-first-boot: Switch from resize2fs to systemd-growfs
2022-05-25 12:47 ` Jan Kiszka
@ 2022-05-25 12:57 ` Bezdeka, Florian
2022-05-25 13:03 ` Bezdeka, Florian
2022-05-25 13:04 ` Schmidl, Tobias
1 sibling, 1 reply; 6+ messages in thread
From: Bezdeka, Florian @ 2022-05-25 12:57 UTC (permalink / raw)
To: isar-users, jan.kiszka, Schmidl, Tobias; +Cc: joe.macdonald
Hi all,
On Wed, 2022-05-25 at 14:47 +0200, Jan Kiszka wrote:
> On 25.05.22 14:32, Tobias Schmidl wrote:
> > We want to be more versatile in our approach of resizing the root
Here your talking about the root partition, but when looking at the
lines below I feel we're talking about the "last" partition which might
be the root partition (in your case) but there is no guarantee for
that.
> > partition. Therefore we switch from resize2fs to systemd-growfs (on
> > systems with systemd-growfs).
>
> Just for the sake of completeness: Since which Debian version is this
> the case? I assume buster is fine, right? But stretch was not.
>
> >
> > This allows for ext4, btrfs, xfs, and dm-crypt partitions to be resized.
> >
> > Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com>
> > ---
> > .../files/expand-last-partition.sh | 15 +++++++++++++--
> > 1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > 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 bb371e9..f0dc66d 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
> > @@ -3,7 +3,7 @@
> > # Resize last partition to full medium size
> > #
> > # This software is a part of ISAR.
> > -# Copyright (c) Siemens AG, 2018
> > +# Copyright (c) Siemens AG, 2018-2022
> > #
> > # SPDX-License-Identifier: MIT
> >
> > @@ -45,4 +45,15 @@ partx -u "${LAST_PART}"
> > # when using systemd mount units.
> > export EXT2FS_NO_MTAB_OK=1
> >
> > -resize2fs "${LAST_PART}"
> > +# If we are on a systemd system, we call systemd-growfs, otherwise resize2fs
> > +if [ -x /lib/systemd/systemd-growfs ]; then
> > + MOUNT_POINT=$(findmnt "${LAST_PART}" -o target -n)
> > + if [ -z "$MOUNT_POINT" ]; then
> > + echo "Cannot find mount point for ${LAST_PART}"
> > + exit 1
> > + fi
> > + mount "${MOUNT_POINT}" || true
> > + /lib/systemd/systemd-growfs "${MOUNT_POINT}"
> > +else
> > + resize2fs "${LAST_PART}"
> > +fi
>
> I wonder if / how long we should keep the two paths...
Same here. Quite sure that stretch would not be OK, but it's unclear to
me if we (should) still care...
Florian
>
> Jan
>
> --
> Siemens AG, Technology
> Competence Center Embedded Linux
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] expand-on-first-boot: Switch from resize2fs to systemd-growfs
2022-05-25 12:57 ` Bezdeka, Florian
@ 2022-05-25 13:03 ` Bezdeka, Florian
0 siblings, 0 replies; 6+ messages in thread
From: Bezdeka, Florian @ 2022-05-25 13:03 UTC (permalink / raw)
To: isar-users, jan.kiszka, Schmidl, Tobias; +Cc: joe.macdonald
On Wed, 2022-05-25 at 14:57 +0200, Florian Bezdeka wrote:
> Hi all,
>
> On Wed, 2022-05-25 at 14:47 +0200, Jan Kiszka wrote:
> > On 25.05.22 14:32, Tobias Schmidl wrote:
> > > We want to be more versatile in our approach of resizing the root
>
> Here your talking about the root partition, but when looking at the
> lines below I feel we're talking about the "last" partition which might
> be the root partition (in your case) but there is no guarantee for
> that.
>
> > > partition. Therefore we switch from resize2fs to systemd-growfs (on
> > > systems with systemd-growfs).
> >
> > Just for the sake of completeness: Since which Debian version is this
> > the case? I assume buster is fine, right? But stretch was not.
> >
> > >
> > > This allows for ext4, btrfs, xfs, and dm-crypt partitions to be resized.
> > >
> > > Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com>
> > > ---
> > > .../files/expand-last-partition.sh | 15 +++++++++++++--
> > > 1 file changed, 13 insertions(+), 2 deletions(-)
> > >
> > > 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 bb371e9..f0dc66d 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
> > > @@ -3,7 +3,7 @@
> > > # Resize last partition to full medium size
> > > #
> > > # This software is a part of ISAR.
> > > -# Copyright (c) Siemens AG, 2018
> > > +# Copyright (c) Siemens AG, 2018-2022
> > > #
> > > # SPDX-License-Identifier: MIT
> > >
> > > @@ -45,4 +45,15 @@ partx -u "${LAST_PART}"
> > > # when using systemd mount units.
> > > export EXT2FS_NO_MTAB_OK=1
> > >
> > > -resize2fs "${LAST_PART}"
> > > +# If we are on a systemd system, we call systemd-growfs, otherwise resize2fs
> > > +if [ -x /lib/systemd/systemd-growfs ]; then
> > > + MOUNT_POINT=$(findmnt "${LAST_PART}" -o target -n)
> > > + if [ -z "$MOUNT_POINT" ]; then
> > > + echo "Cannot find mount point for ${LAST_PART}"
> > > + exit 1
> > > + fi
> > > + mount "${MOUNT_POINT}" || true
> > > + /lib/systemd/systemd-growfs "${MOUNT_POINT}"
> > > +else
> > > + resize2fs "${LAST_PART}"
> > > +fi
> >
> > I wonder if / how long we should keep the two paths...
>
> Same here. Quite sure that stretch would not be OK, but it's unclear to
> me if we (should) still care...
Sorry, forgot something:
Is systemd-growfs able to handle the typical "resize boundary
problems"? While looking at the y2038 stuff last time we figured out
that inode size is calculated at file system creation time. So it is
quite dangerous to enlarge a quite small file system to a huge one. The
inode size can not be changed again during resize operation. So they
might "run out of space" / curious things can happen.
That was at least a problem for ext3/4 in the past. Don't know about
the others...
There should be an internal issue for that topic, but I was unable to
find it within a few seconds.
>
> Florian
>
> >
> > Jan
> >
> > --
> > Siemens AG, Technology
> > Competence Center Embedded Linux
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] expand-on-first-boot: Switch from resize2fs to systemd-growfs
2022-05-25 12:47 ` Jan Kiszka
2022-05-25 12:57 ` Bezdeka, Florian
@ 2022-05-25 13:04 ` Schmidl, Tobias
2022-05-25 13:08 ` Jan Kiszka
1 sibling, 1 reply; 6+ messages in thread
From: Schmidl, Tobias @ 2022-05-25 13:04 UTC (permalink / raw)
To: isar-users, jan.kiszka; +Cc: joe.macdonald
Hi all,
Am Mittwoch, dem 25.05.2022 um 14:47 +0200 schrieb Jan Kiszka:
>
> Just for the sake of completeness: Since which Debian version is this
> the case? I assume buster is fine, right? But stretch was not.
>
>
That's correct, it was introduced with v236 [1], so halfway between
stretch (v232) and buster (v241).
[1]:
https://github.com/systemd/systemd/blob/ec5e113f099a3078194ae5fe43f72f52f41fe76b/NEWS#L6515-L6524
> >
> > +if [ -x /lib/systemd/systemd-growfs ]; then
> > + MOUNT_POINT=$(findmnt "${LAST_PART}" -o target -n)
> > + if [ -z "$MOUNT_POINT" ]; then
> > + echo "Cannot find mount point for ${LAST_PART}"
> > + exit 1
> > + fi
> > + mount "${MOUNT_POINT}" || true
> > + /lib/systemd/systemd-growfs "${MOUNT_POINT}"
> > +else
> > + resize2fs "${LAST_PART}"
> > +fi
>
> I wonder if / how long we should keep the two paths...
>
That's a strategic decision - do we want to keep the possibility of non-
systemd systems open? Otherwise this script should IMHO add a runtime
dependency to systemd (>=236).
Kind regards,
Tobias
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] expand-on-first-boot: Switch from resize2fs to systemd-growfs
2022-05-25 13:04 ` Schmidl, Tobias
@ 2022-05-25 13:08 ` Jan Kiszka
0 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2022-05-25 13:08 UTC (permalink / raw)
To: Schmidl, Tobias (T CED SES-DE), isar-users; +Cc: MacDonald, Joe
On 25.05.22 15:04, Schmidl, Tobias (T CED SES-DE) wrote:
> Hi all,
>
> Am Mittwoch, dem 25.05.2022 um 14:47 +0200 schrieb Jan Kiszka:
>>
>> Just for the sake of completeness: Since which Debian version is this
>> the case? I assume buster is fine, right? But stretch was not.
>>
>>
>
> That's correct, it was introduced with v236 [1], so halfway between
> stretch (v232) and buster (v241).
>
>
> [1]:
> https://github.com/systemd/systemd/blob/ec5e113f099a3078194ae5fe43f72f52f41fe76b/NEWS#L6515-L6524
>
>>>
>>> +if [ -x /lib/systemd/systemd-growfs ]; then
>>> + MOUNT_POINT=$(findmnt "${LAST_PART}" -o target -n)
>>> + if [ -z "$MOUNT_POINT" ]; then
>>> + echo "Cannot find mount point for ${LAST_PART}"
>>> + exit 1
>>> + fi
>>> + mount "${MOUNT_POINT}" || true
>>> + /lib/systemd/systemd-growfs "${MOUNT_POINT}"
>>> +else
>>> + resize2fs "${LAST_PART}"
>>> +fi
>>
>> I wonder if / how long we should keep the two paths...
>>
>
> That's a strategic decision - do we want to keep the possibility of non-
> systemd systems open? Otherwise this script should IMHO add a runtime
> dependency to systemd (>=236).
>
Well, we already depend on systemd today and provide only systemd unit
files here. In that light, adding a version dependency to systemd would
be fine IMHO.
Jan
--
Siemens AG, Technology
Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-25 13:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25 12:32 [PATCH] expand-on-first-boot: Switch from resize2fs to systemd-growfs Tobias Schmidl
2022-05-25 12:47 ` Jan Kiszka
2022-05-25 12:57 ` Bezdeka, Florian
2022-05-25 13:03 ` Bezdeka, Florian
2022-05-25 13:04 ` Schmidl, Tobias
2022-05-25 13:08 ` Jan Kiszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox