public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Tobias Schmidl <tobiasschmidl@siemens.com>
To: <isar-users@googlegroups.com>
Cc: Joe MacDonald <joe.macdonald@siemens.com>,
	Tobias Schmidl <tobiasschmidl@siemens.com>
Subject: [PATCH] expand-on-first-boot: Switch from resize2fs to systemd-growfs
Date: Wed, 25 May 2022 14:32:46 +0200	[thread overview]
Message-ID: <20220525123246.779227-1-tobiasschmidl@siemens.com> (raw)

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


             reply	other threads:[~2022-05-25 12:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 12:32 Tobias Schmidl [this message]
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

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=20220525123246.779227-1-tobiasschmidl@siemens.com \
    --to=tobiasschmidl@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=joe.macdonald@siemens.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