public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v4 0/1] expand-on-first-boot: Switch from resize2fs to systemd-growfs
@ 2022-06-29 12:01 Tobias Schmidl
  2022-06-29 12:01 ` [PATCH v4 1/1] " Tobias Schmidl
  0 siblings, 1 reply; 5+ messages in thread
From: Tobias Schmidl @ 2022-06-29 12:01 UTC (permalink / raw)
  To: isar-users; +Cc: Joe MacDonald, Tobias Schmidl

Diff to v1:
- Rewording on patch message ("root partition" --> "last partition",
  added note to systemd-dependency and its impact)
- Added systemd-version dependency
- Removed runtime if case that allowed for non-systemd systems

Diff to v2:
- Version bump to v1.2
- Removed e2fsprogs as dependency

Diff to v3:
- Omit the explicit call to systemd-growfs if a fstab option has been
  found
- Be able to deal with both mounted and unmounted mountpoints

Tobias Schmidl (1):
  expand-on-first-boot: Switch from resize2fs to systemd-growfs

 ...oot_1.1.bb => expand-on-first-boot_1.2.bb} |  5 +++--
 .../files/expand-last-partition.sh            | 21 +++++++++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)
 rename meta/recipes-support/expand-on-first-boot/{expand-on-first-boot_1.1.bb => expand-on-first-boot_1.2.bb} (78%)

-- 
2.36.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/1] expand-on-first-boot: Switch from resize2fs to systemd-growfs
  2022-06-29 12:01 [PATCH v4 0/1] expand-on-first-boot: Switch from resize2fs to systemd-growfs Tobias Schmidl
@ 2022-06-29 12:01 ` Tobias Schmidl
  2022-06-29 12:13   ` Jan Kiszka
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tobias Schmidl @ 2022-06-29 12:01 UTC (permalink / raw)
  To: isar-users; +Cc: Joe MacDonald, Tobias Schmidl

We want to be more versatile in our approach of resizing the last
partition. Therefore we switch from resize2fs to systemd-growfs.

This allows for ext4, btrfs, xfs, and dm-crypt partitions to be resized.

Since systemd-growfs landed in v236, this obsoletes expand-on-first-boot
on stretch (v232).

Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com>
---
 ...oot_1.1.bb => expand-on-first-boot_1.2.bb} |  5 +++--
 .../files/expand-last-partition.sh            | 21 +++++++++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)
 rename meta/recipes-support/expand-on-first-boot/{expand-on-first-boot_1.1.bb => expand-on-first-boot_1.2.bb} (78%)

diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
similarity index 78%
rename from meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
rename to meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
index 1703a64..48d30d3 100644
--- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
+++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
@@ -1,15 +1,16 @@
 # Resize last partition to full medium size on fist boot
 #
 # This software is a part of ISAR.
-# Copyright (c) Siemens AG, 2018
+# Copyright (c) Siemens AG, 2018-2022
 #
 # SPDX-License-Identifier: MIT
 
 inherit dpkg-raw
 
 DESCRIPTION = "This service grows the last partition to the full medium during first boot"
+MAINTAINER = "isar-users <isar-users@googlegroups.com>"
 
-DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk, util-linux"
+DEBIAN_DEPENDS = "systemd (>=236), sed, grep, coreutils, mount, fdisk, util-linux"
 
 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 c0edde7..1743890 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,21 @@ partx -u "${LAST_PART}"
 # when using systemd mount units.
 export EXT2FS_NO_MTAB_OK=1
 
-resize2fs "${LAST_PART}"
+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_POINT=$(findmnt -o target -n "${LAST_PART}")
+UNMOUNT_AFTERWORDS=0
+if [ -z "${MOUNT_POINT}" ]; then
+	MOUNT_POINT=$(findmnt -o target -n --fstab "{$LAST_PART}")
+	if [ -z "${MOUNT_POINT}" ]; then
+		echo "Cannot find mount point for ${LAST_PART}" >&2
+		exit 1
+	else
+		UNMOUNT_AFTERWORDS=1
+	fi
+fi
+/lib/systemd/systemd-growfs "${MOUNT_POINT}"
+[ $UNMOUNT_AFTERWORDS -eq 1 ] && umount "${MOUNT_POINT}"
-- 
2.36.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 1/1] expand-on-first-boot: Switch from resize2fs to systemd-growfs
  2022-06-29 12:01 ` [PATCH v4 1/1] " Tobias Schmidl
@ 2022-06-29 12:13   ` Jan Kiszka
  2022-06-29 16:33   ` Henning Schild
  2022-06-29 17:00   ` Henning Schild
  2 siblings, 0 replies; 5+ messages in thread
From: Jan Kiszka @ 2022-06-29 12:13 UTC (permalink / raw)
  To: Tobias Schmidl, isar-users; +Cc: Joe MacDonald

On 29.06.22 14:01, Tobias Schmidl wrote:
> We want to be more versatile in our approach of resizing the last
> partition. Therefore we switch from resize2fs to systemd-growfs.
> 
> This allows for ext4, btrfs, xfs, and dm-crypt partitions to be resized.
> 
> Since systemd-growfs landed in v236, this obsoletes expand-on-first-boot
> on stretch (v232).
> 
> Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com>
> ---
>  ...oot_1.1.bb => expand-on-first-boot_1.2.bb} |  5 +++--
>  .../files/expand-last-partition.sh            | 21 +++++++++++++++++--
>  2 files changed, 22 insertions(+), 4 deletions(-)
>  rename meta/recipes-support/expand-on-first-boot/{expand-on-first-boot_1.1.bb => expand-on-first-boot_1.2.bb} (78%)
> 
> diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
> similarity index 78%
> rename from meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
> rename to meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
> index 1703a64..48d30d3 100644
> --- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
> +++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
> @@ -1,15 +1,16 @@
>  # Resize last partition to full medium size on fist boot
>  #
>  # This software is a part of ISAR.
> -# Copyright (c) Siemens AG, 2018
> +# Copyright (c) Siemens AG, 2018-2022
>  #
>  # SPDX-License-Identifier: MIT
>  
>  inherit dpkg-raw
>  
>  DESCRIPTION = "This service grows the last partition to the full medium during first boot"
> +MAINTAINER = "isar-users <isar-users@googlegroups.com>"
>  
> -DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk, util-linux"
> +DEBIAN_DEPENDS = "systemd (>=236), sed, grep, coreutils, mount, fdisk, util-linux"
>  
>  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 c0edde7..1743890 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,21 @@ partx -u "${LAST_PART}"
>  # when using systemd mount units.
>  export EXT2FS_NO_MTAB_OK=1
>  
> -resize2fs "${LAST_PART}"
> +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_POINT=$(findmnt -o target -n "${LAST_PART}")
> +UNMOUNT_AFTERWORDS=0

afterwards ;)

> +if [ -z "${MOUNT_POINT}" ]; then
> +	MOUNT_POINT=$(findmnt -o target -n --fstab "{$LAST_PART}")
> +	if [ -z "${MOUNT_POINT}" ]; then
> +		echo "Cannot find mount point for ${LAST_PART}" >&2
> +		exit 1
> +	else
> +		UNMOUNT_AFTERWORDS=1
> +	fi
> +fi
> +/lib/systemd/systemd-growfs "${MOUNT_POINT}"
> +[ $UNMOUNT_AFTERWORDS -eq 1 ] && umount "${MOUNT_POINT}"

Explicit exit 0, or "if then"? Otherwise, the script may return with an
error when the condition is false.

Looks good to me otherwise.

Jan

-- 
Siemens AG, Technology
Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 1/1] expand-on-first-boot: Switch from resize2fs to systemd-growfs
  2022-06-29 12:01 ` [PATCH v4 1/1] " Tobias Schmidl
  2022-06-29 12:13   ` Jan Kiszka
@ 2022-06-29 16:33   ` Henning Schild
  2022-06-29 17:00   ` Henning Schild
  2 siblings, 0 replies; 5+ messages in thread
From: Henning Schild @ 2022-06-29 16:33 UTC (permalink / raw)
  To: Tobias Schmidl; +Cc: isar-users, Joe MacDonald

Am Wed, 29 Jun 2022 14:01:44 +0200
schrieb Tobias Schmidl <tobiasschmidl@siemens.com>:

> We want to be more versatile in our approach of resizing the last
> partition. Therefore we switch from resize2fs to systemd-growfs.
> 
> This allows for ext4, btrfs, xfs, and dm-crypt partitions to be
> resized.
> 
> Since systemd-growfs landed in v236, this obsoletes
> expand-on-first-boot on stretch (v232).
> 
> Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com>
> ---
>  ...oot_1.1.bb => expand-on-first-boot_1.2.bb} |  5 +++--
>  .../files/expand-last-partition.sh            | 21
> +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-)
>  rename
> meta/recipes-support/expand-on-first-boot/{expand-on-first-boot_1.1.bb
> => expand-on-first-boot_1.2.bb} (78%)
> 
> diff --git
> a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
> b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
> similarity index 78% rename from
> meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
> rename to
> meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
> index 1703a64..48d30d3 100644 ---
> a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
> +++
> b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
> @@ -1,15 +1,16 @@ # Resize last partition to full medium size on fist
> boot # # This software is a part of ISAR. -# Copyright (c) Siemens
> AG, 2018 +# Copyright (c) Siemens AG, 2018-2022 #
>  # SPDX-License-Identifier: MIT
>  
>  inherit dpkg-raw
>  
>  DESCRIPTION = "This service grows the last partition to the full
> medium during first boot" +MAINTAINER = "isar-users
> <isar-users@googlegroups.com>" 
> -DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs,
> fdisk, util-linux" +DEBIAN_DEPENDS = "systemd (>=236), sed, grep,
> coreutils, mount, fdisk, util-linux" 
>  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 c0edde7..1743890 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,21 @@ partx -u "${LAST_PART}"
>  # when using systemd mount units.
>  export EXT2FS_NO_MTAB_OK=1
>  
> -resize2fs "${LAST_PART}"
> +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_POINT=$(findmnt -o target -n "${LAST_PART}")
> +UNMOUNT_AFTERWORDS=0
> +if [ -z "${MOUNT_POINT}" ]; then
> +	MOUNT_POINT=$(findmnt -o target -n --fstab "{$LAST_PART}")
> +	if [ -z "${MOUNT_POINT}" ]; then
> +		echo "Cannot find mount point for ${LAST_PART}" >&2
> +		exit 1
> +	else
> +		UNMOUNT_AFTERWORDS=1
> +	fi
> +fi
> +/lib/systemd/systemd-growfs "${MOUNT_POINT}"
> +[ $UNMOUNT_AFTERWORDS -eq 1 ] && umount "${MOUNT_POINT}"

where did the mount go? i would assume a mount to be here somewhere
which happens in the context where we remember that we have to umount

Here a "noauto" in the fstab line of that last partition should help to
put that script into the role of the mounter and actually test that
path.

So the problem is that the partition needs to be mounted to get
resized. And now we have the problem to sync up with other mounters and
potentially having to umount ... not as easy as it sounds. We need to
get the order right and know things like "noauto" or other fun
exceptions.
I suggest to try and --bind mount it to /tmp/partition-to-expand ... if
we are lucky we can grow it when mounted twice and unconditionally
mount/umount without ever having to findmnt. But i am kind of afraid of
an EBUSY ...

Henning


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 1/1] expand-on-first-boot: Switch from resize2fs to systemd-growfs
  2022-06-29 12:01 ` [PATCH v4 1/1] " Tobias Schmidl
  2022-06-29 12:13   ` Jan Kiszka
  2022-06-29 16:33   ` Henning Schild
@ 2022-06-29 17:00   ` Henning Schild
  2 siblings, 0 replies; 5+ messages in thread
From: Henning Schild @ 2022-06-29 17:00 UTC (permalink / raw)
  To: Tobias Schmidl; +Cc: isar-users, Joe MacDonald

Am Wed, 29 Jun 2022 14:01:44 +0200
schrieb Tobias Schmidl <tobiasschmidl@siemens.com>:

> We want to be more versatile in our approach of resizing the last
> partition. Therefore we switch from resize2fs to systemd-growfs.
> 
> This allows for ext4, btrfs, xfs, and dm-crypt partitions to be
> resized.
> 
> Since systemd-growfs landed in v236, this obsoletes
> expand-on-first-boot on stretch (v232).
> 
> Signed-off-by: Tobias Schmidl <tobiasschmidl@siemens.com>
> ---
>  ...oot_1.1.bb => expand-on-first-boot_1.2.bb} |  5 +++--
>  .../files/expand-last-partition.sh            | 21
> +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-)
>  rename
> meta/recipes-support/expand-on-first-boot/{expand-on-first-boot_1.1.bb
> => expand-on-first-boot_1.2.bb} (78%)
> 
> diff --git
> a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
> b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
> similarity index 78% rename from
> meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
> rename to
> meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
> index 1703a64..48d30d3 100644 ---
> a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.1.bb
> +++
> b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
> @@ -1,15 +1,16 @@ # Resize last partition to full medium size on fist
> boot # # This software is a part of ISAR. -# Copyright (c) Siemens
> AG, 2018 +# Copyright (c) Siemens AG, 2018-2022 #
>  # SPDX-License-Identifier: MIT
>  
>  inherit dpkg-raw
>  
>  DESCRIPTION = "This service grows the last partition to the full
> medium during first boot" +MAINTAINER = "isar-users
> <isar-users@googlegroups.com>" 
> -DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs,
> fdisk, util-linux" +DEBIAN_DEPENDS = "systemd (>=236), sed, grep,
> coreutils, mount, fdisk, util-linux" 
>  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 c0edde7..1743890 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,21 @@ partx -u "${LAST_PART}"
>  # when using systemd mount units.
>  export EXT2FS_NO_MTAB_OK=1
>  
> -resize2fs "${LAST_PART}"
> +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

I guess we might need some comments here. In the other mail you wrote
that the fstab magic string did not work as expected, but i guess that
was the attempt to smuggle it in without actually having it in fstab.

Does the combination of expand-on-first-boot (in the proposed version)
work together with the fstab string set on the last partition?
I would assume it would not because the service is executed too late,
or it might work on the second boot ... It is probably good to bail
when finding that string in fstab, but for people reading the code they
might think that they could as well write it into fstab to reach a fs
growing that way.

Henning

> +
> +MOUNT_POINT=$(findmnt -o target -n "${LAST_PART}")
> +UNMOUNT_AFTERWORDS=0
> +if [ -z "${MOUNT_POINT}" ]; then
> +	MOUNT_POINT=$(findmnt -o target -n --fstab "{$LAST_PART}")
> +	if [ -z "${MOUNT_POINT}" ]; then
> +		echo "Cannot find mount point for ${LAST_PART}" >&2
> +		exit 1
> +	else
> +		UNMOUNT_AFTERWORDS=1
> +	fi
> +fi
> +/lib/systemd/systemd-growfs "${MOUNT_POINT}"
> +[ $UNMOUNT_AFTERWORDS -eq 1 ] && umount "${MOUNT_POINT}"


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-29 17:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29 12:01 [PATCH v4 0/1] expand-on-first-boot: Switch from resize2fs to systemd-growfs Tobias Schmidl
2022-06-29 12:01 ` [PATCH v4 1/1] " Tobias Schmidl
2022-06-29 12:13   ` Jan Kiszka
2022-06-29 16:33   ` Henning Schild
2022-06-29 17:00   ` Henning Schild

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox