public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [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

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