public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
To: isar-users@googlegroups.com
Cc: Anton Mikanovich <amikan@ilbers.de>
Subject: [PATCHSET] expand last partition script and its usage
Date: Thu, 15 Dec 2022 19:06:02 +0100	[thread overview]
Message-ID: <CAJGKYO58T1LZLMJ84+oLF3b6CtJcfEwz97=WGDcrWCanX+5HVA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]

Hi all,

 all these patches are just sent by elastic mail SMTP and they are
waiting in moderation.

* 9ab1ca3 - In expand last partition few improvements and a bugfix
* 565e850 - In expand last partition trap exitnlog EXIT logs with simpler code
* b207566 - The expand last partition might support full volumes also, to test
* 0e1748e - In expand last partition checking the size is useless
* 4112390 - If expand last partition fails, unsupervised systems reboot
* f5a72cd - In expand last partition script btrfs support added
* d3aded1 - In expand last partition wait for udev have finished

I am going to attach them for immediate reviewing and they can also be
found in this branch

https://github.com/robang74/isar/tree/rafnext

or they can be found in this branch which has been merged with the
current ISAR next head

https://github.com/robang74/isar/tree/next

Files changed list:

meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service

Best regards, R-

[-- Attachment #2: 0007-In-expand-last-partition-few-improvements-and-a-bugf.patch --]
[-- Type: text/x-patch, Size: 1867 bytes --]

From 9ab1ca3d1f980b3f05759ca2d2f3db6abaae11ea Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Thu, 15 Dec 2022 18:40:28 +0100
Subject: [PATCH 7/7] In expand last partition few improvements and a bugfix

Some improvements and a bugfix in expanding last partition.

Improvements: filesystems ext2 and ext3 also supported, warning in dmesg in
case of unsupported filesystem, the variable tmpdir is used with double
quotes even if unneeded but be consistent with the original script notation.

Bugfix: even if btrfs resize fails, umount the last partition and return error.

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../files/expand-last-partition.sh                | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 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 1c8abf0..5cd6fc3 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
@@ -84,11 +84,16 @@ fi
 export EXT2FS_NO_MTAB_OK=1
 
 case $(lsblk -fno FSTYPE "${LAST_PART}") in
-	ext4) 	resize2fs "${LAST_PART}"
+	ext[234]) resize2fs "${LAST_PART}"
 		;;
-	btrfs) 	tmpdir=$(mktemp -d -p "$TMPDIR" btrfs.XXXX || mktemp -d -p "/dev/shm" btrfs.XXXX)
-		mount "${LAST_PART}" $tmpdir
-		btrfs filesystem resize max $tmpdir
-		umount $tmpdir && rmdir $tmpdir
+	btrfs) 	err=0
+		tmpdir=$(mktemp -d -p "$TMPDIR" btrfs.XXXX || \
+			mktemp -d -p "/dev/shm" btrfs.XXXX)
+		mount "${LAST_PART}" "$tmpdir"
+		btrfs filesystem resize max "$tmpdir" || err=1
+		umount "$tmpdir" && rmdir "$tmpdir"
+		exit $err
+		;;
+	*)	echo "WARNING: $0 unsupported filesystem" >/dev/kmsg || true
 		;;
 esac
-- 
2.34.1


[-- Attachment #3: 0004-In-expand-last-partition-checking-the-size-is-useles.patch --]
[-- Type: text/x-patch, Size: 2477 bytes --]

From 0e1748ebcd8641943b056c10c266a7ca6841271a Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Wed, 14 Dec 2022 12:37:26 +0100
Subject: [PATCH 4/7] In expand last partition checking the size is useless

code maintenance, superflous operations commented, kept for the future

Tests shown that resize in full a ext4 or btrfs partition/filesystem does not
hurt and does not report a failure, so nothing changes without the size check

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../files/expand-last-partition.sh            | 34 +++++++++++--------
 1 file changed, 19 insertions(+), 15 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 2c52b16..4d36733 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
@@ -27,22 +27,26 @@ if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then
 	exit 0
 fi
 
-# this value is in blocks. Normally a block has 512 bytes.
-BUFFER_SIZE=32768
-BOOT_DEV_NAME=${BOOT_DEV##*/}
-DISK_SIZE="$(cat /sys/class/block/"${BOOT_DEV_NAME}"/size)"
-ALL_PARTS_SIZE=0
-for PARTITION in /sys/class/block/"${BOOT_DEV_NAME}"/"${BOOT_DEV_NAME}"*; do
-	PART_SIZE=$(cat "${PARTITION}"/size)
-	ALL_PARTS_SIZE=$((ALL_PARTS_SIZE + PART_SIZE))
-done
+# full resizing of ext4 and btrfs does not fail nor hurt but supporting more
+# filesystems in future might change this condition, so commenting this code
+useless_for_now() {
+	# this value is in blocks. Normally a block has 512 bytes.
+	BUFFER_SIZE=32768
+	BOOT_DEV_NAME=${BOOT_DEV##*/}
+	DISK_SIZE="$(cat /sys/class/block/"${BOOT_DEV_NAME}"/size)"
+	ALL_PARTS_SIZE=0
+	for PARTITION in /sys/class/block/"${BOOT_DEV_NAME}"/"${BOOT_DEV_NAME}"*; do
+		PART_SIZE=$(cat "${PARTITION}"/size)
+		ALL_PARTS_SIZE=$((ALL_PARTS_SIZE + PART_SIZE))
+	done
 
-MINIMAL_SIZE=$((ALL_PARTS_SIZE + BUFFER_SIZE))
-if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
-	echo "Disk is practically already full, doing nothing." >&2
-	trap - EXIT
-	exit 0
-fi
+	MINIMAL_SIZE=$((ALL_PARTS_SIZE + BUFFER_SIZE))
+	if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
+		echo "Disk is practically already full, doing nothing." >&2
+		trap - EXIT
+		exit 0
+	fi
+}
 
 LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
 
-- 
2.34.1


[-- Attachment #4: 0006-In-expand-last-partition-trap-exitnlog-EXIT-logs-wit.patch --]
[-- Type: text/x-patch, Size: 1793 bytes --]

From 565e8505097e490239a91c106695896f3f058f9b Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Thu, 15 Dec 2022 17:51:17 +0100
Subject: [PATCH 6/7] In expand last partition trap exitnlog EXIT logs with
 simpler code

improvement, the script log at exit with the status of completion and its full path
in this way the - in case of failure - the user will find in dmesg the error and
also the script full path to debug. It uses /dev/kmsg to log. Code simplified.

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../files/expand-last-partition.sh            | 20 ++++++++++++++-----
 1 file changed, 15 insertions(+), 5 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 90e8d93..1c8abf0 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
@@ -7,9 +7,22 @@
 #
 # SPDX-License-Identifier: MIT
 
-set -e
+exitnlog() {
+	ec=$?
+	set +e
+	if [ "$ec" != "0" ]; then
+		echo "ERROR: $0 failed"
+	else
+		echo "$0 succeded"
+	fi >/dev/kmsg
+	if [ "$ec" != "0" -a -e /etc/unsupervised ]; then
+		reboot
+	fi
+}
+export -f exitnlog
+trap exitnlog EXIT
 
-test -e /etc/unsupervised && trap reboot EXIT
+set -e
 
 udevadm settle
 
@@ -36,7 +49,6 @@ useless_for_now() {
 	MINIMAL_SIZE=$((ALL_PARTS_SIZE + BUFFER_SIZE))
 	if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
 		echo "Disk is practically already full, doing nothing." >&2
-		trap - EXIT
 		exit 0
 	fi
 } 
@@ -80,5 +92,3 @@ case $(lsblk -fno FSTYPE "${LAST_PART}") in
 		umount $tmpdir && rmdir $tmpdir
 		;;
 esac
-
-trap - EXIT
-- 
2.34.1


[-- Attachment #5: 0005-The-expand-last-partition-might-support-full-volumes.patch --]
[-- Type: text/x-patch, Size: 3552 bytes --]

From b20756675715b02db3515b4564b85cf4b3c95ff4 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Wed, 14 Dec 2022 12:51:48 +0100
Subject: [PATCH 5/7] The expand last partition might support full volumes
 also, to test

Improvement, expansion of unpartitioned volumes supported also but to test

TODO, 14.12.2022: this change should be tested with a single volume system
preliminary tests shown that ext4 and btrfs entire volumes cam be resized

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../files/expand-last-partition.sh            | 48 +++++++++----------
 1 file changed, 24 insertions(+), 24 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 4d36733..90e8d93 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
@@ -20,13 +20,6 @@ if [ -n "${ROOT_DEV_SLAVE}" ]; then
 	ROOT_DEV=/dev/${ROOT_DEV_SLAVE##*/}
 fi
 
-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 0
-fi
-
 # full resizing of ext4 and btrfs does not fail nor hurt but supporting more
 # filesystems in future might change this condition, so commenting this code
 useless_for_now() {
@@ -46,26 +39,33 @@ useless_for_now() {
 		trap - EXIT
 		exit 0
 	fi
-}
+} 
 
-LAST_PART="$(sfdisk -d "${BOOT_DEV}" 2>/dev/null | tail -1 | cut -d ' ' -f 1)"
+# TODO, 14.12.2022: this change should be tested with a single volume system
+# preliminary tests shown that ext4 and btrfs entire volumes cam be resized 
+BOOT_DEV="$(echo "${ROOT_DEV}" | sed 's/p\?[0-9]*$//')"
+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)"
 
-# Transform the partition table as follows:
-#
-# - Remove any 'last-lba' header so sfdisk uses the entire available space.
-# - If this partition table is MBR and an extended partition container (EBR)
-#   exists, we assume this needs to be expanded as well; remove its size
-#   field so sfdisk expands it.
-# - For the previously fetched last partition, also remove the size field so
-#   sfdisk expands it.
-sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
-	grep -v last-lba | \
-	sed 's|^\(.*, \)size=[^,]*, \(type=[f5]\)$|\1\2|' | \
-	sed 's|^\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \
-	sfdisk --force "${BOOT_DEV}"
+	# Transform the partition table as follows:
+	#
+	# - Remove any 'last-lba' header so sfdisk uses the entire available space.
+	# - If this partition table is MBR and an extended partition container (EBR)
+	#   exists, we assume this needs to be expanded as well; remove its size
+	#   field so sfdisk expands it.
+	# - For the previously fetched last partition, also remove the size field so
+	#   sfdisk expands it.
+	sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
+		grep -v last-lba | \
+		sed 's|^\(.*, \)size=[^,]*, \(type=[f5]\)$|\1\2|' | \
+		sed 's|^\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \
+		sfdisk --force "${BOOT_DEV}"
 
-# Inform the kernel about the partitioning change
-partx -u "${LAST_PART}"
+	# Inform the kernel about the partitioning change
+	partx -u "${LAST_PART}"
+fi
 
 # Do not fail resize2fs if no mtab entry is found, e.g.,
 # when using systemd mount units.
-- 
2.34.1


[-- Attachment #6: 0003-If-expand-last-partition-fails-unsupervised-systems-.patch --]
[-- Type: text/x-patch, Size: 2111 bytes --]

From 4112390519d01a7fb28d2a326002dff876786190 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Tue, 13 Dec 2022 07:14:25 +0100
Subject: [PATCH 3/7] If expand last partition fails, unsupervised systems
 reboot

Improvement for unsupervised embedded devices which need to reboot if expand last
partition fails because a under-provided system should not even complete the boot
in the field in order to avoid functioning failures at unexpected future time.
This patch do not affect the previous behaviour because requirs /etc/unsupervised

This patch applies after the following other patches:

 - In expand last partition script btrfs support added
 - In expand last partition wait for udev have finished

v2: if there is no partition table exit 0 instead of exit 1

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../expand-on-first-boot/files/expand-last-partition.sh   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

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 f5bcad1..2c52b16 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
@@ -9,6 +9,8 @@
 
 set -e
 
+test -e /etc/unsupervised && trap reboot EXIT
+
 udevadm settle
 
 ROOT_DEV="$(findmnt / -o source -n)"
@@ -21,7 +23,8 @@ fi
 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
-	exit 1
+	trap - EXIT
+	exit 0
 fi
 
 # this value is in blocks. Normally a block has 512 bytes.
@@ -37,6 +40,7 @@ done
 MINIMAL_SIZE=$((ALL_PARTS_SIZE + BUFFER_SIZE))
 if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
 	echo "Disk is practically already full, doing nothing." >&2
+	trap - EXIT
 	exit 0
 fi
 
@@ -72,3 +76,5 @@ case $(lsblk -fno FSTYPE "${LAST_PART}") in
 		umount $tmpdir && rmdir $tmpdir
 		;;
 esac
+
+trap - EXIT
-- 
2.34.1


[-- Attachment #7: 0001-In-expand-last-partition-wait-for-udev-have-finished.patch --]
[-- Type: text/x-patch, Size: 2292 bytes --]

From d3aded1198e598b2c0612f2c0528c6aab26d98c2 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Mon, 12 Dec 2022 21:14:26 +0100
Subject: [PATCH 1/7] In expand last partition wait for udev have finished

bugfix, expand last partition, wait for udev completion

On some hardware the udev did not created the links to the disk partitions
while this script is working thus it fails. This patch fixes that cases.

v2: as underlined by Tobias this script requires systemd-udevd.service and
it can safely runs only after that service has been started otherwise might
fail. This dependency will reorder the boot procedure but not slow down it
unless the hardware is slow to get mapped by udev but in that case resize
the last partition would have failed. Thus, no regression are expected.

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../expand-on-first-boot/files/expand-last-partition.sh         | 2 ++
 .../expand-on-first-boot/files/expand-on-first-boot.service     | 2 ++
 2 files changed, 4 insertions(+)

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 57055cc..4d55645 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
@@ -9,6 +9,8 @@
 
 set -e
 
+udevadm settle
+
 ROOT_DEV="$(findmnt / -o source -n)"
 ROOT_DEV_NAME=${ROOT_DEV##*/}
 ROOT_DEV_SLAVE=$(find /sys/block/"${ROOT_DEV_NAME}"/slaves -mindepth 1 -print -quit 2>/dev/null || true)
diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
index fda5001..2c120c4 100644
--- a/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
+++ b/meta/recipes-support/expand-on-first-boot/files/expand-on-first-boot.service
@@ -7,7 +7,9 @@
 Description=Expand last partition
 DefaultDependencies=no
 Conflicts=shutdown.target
+Requires=systemd-udevd.service
 After=systemd-remount-fs.service
+After=systemd-udevd.service
 Before=local-fs-pre.target shutdown.target
 ConditionPathIsReadWrite=/etc
 
-- 
2.34.1


[-- Attachment #8: 0002-In-expand-last-partition-script-btrfs-support-added.patch --]
[-- Type: text/x-patch, Size: 3998 bytes --]

From f5a72cdfd3f429895893412b0c835edba223c608 Mon Sep 17 00:00:00 2001
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
Date: Sat, 10 Dec 2022 04:13:42 +0100
Subject: [PATCH 2/7] In expand last partition script btrfs support added

Improvement, expand-on-first-boot: support for btrfs added

v2: the mount point for btrfs filesystem to resize is under /dev/shm
by default but a variable defined in the running environment can
change the temporary directory path. The /dev/shm has been chosen
because in some systems /tmp can be on a RO root filesystem and
/tmp not yet mounted with tmpfs. This requires the system to have
/dev/shm configured into the kernel.

v3: the previous version was using a bashism but the shebang is /bin/sh
this means that the script will fail in a customized system in which /bin/sh
do not link to bash or bash is not available.

v4: Felix suggested using mktemp for the temporary directory in which to
mount the btrfs filesystem to resize. The default path /tmp could be changed
using the variable TMPDIR to set in the running environment.

v5: typo fixes into the patch description

v6: mktemp does a reasonable second try with -p /dev/shm before failing

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../expand-on-first-boot_1.2.bb               |  2 +-
 .../files/expand-last-partition.sh            | 37 ++++++-------------
 2 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
index 0996000..fe7b72b 100644
--- a/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
+++ b/meta/recipes-support/expand-on-first-boot/expand-on-first-boot_1.2.bb
@@ -10,7 +10,7 @@ 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 (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux"
+DEBIAN_DEPENDS = "systemd, sed, grep, coreutils, mount, e2fsprogs, fdisk (>=2.29.2-3) | util-linux (<2.29.2-3), util-linux, btrfs-progs"
 
 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 4d55645..f5bcad1 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
@@ -59,29 +59,16 @@ sfdisk -d "${BOOT_DEV}" 2>/dev/null | \
 # Inform the kernel about the partitioning change
 partx -u "${LAST_PART}"
 
-# this is for debian stretch or systemd < 236
-if [ ! -x /lib/systemd/systemd-growfs ]; then
-	# Do not fail resize2fs if no mtab entry is found, e.g.,
-	# when using systemd mount units.
-	export EXT2FS_NO_MTAB_OK=1
+# Do not fail resize2fs if no mtab entry is found, e.g.,
+# when using systemd mount units.
+export EXT2FS_NO_MTAB_OK=1
 
-	resize2fs "${LAST_PART}"
-	exit 0
-fi
-
-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 $LAST_PART out of tree, so we won't conflict with other mounts
-MOUNT_POINT=$(mktemp -d -p /mnt "$(basename "$0").XXXXXXXXXX")
-if [ ! -d "${MOUNT_POINT}" ]; then
-	echo "Cannot create temporary mount point ${MOUNT_POINT}." >&2
-	exit 1
-fi
-
-mount "${LAST_PART}" "${MOUNT_POINT}"
-/lib/systemd/systemd-growfs "${MOUNT_POINT}"
-umount "${MOUNT_POINT}"
-rmdir "${MOUNT_POINT}"
+case $(lsblk -fno FSTYPE "${LAST_PART}") in
+	ext4) 	resize2fs "${LAST_PART}"
+		;;
+	btrfs) 	tmpdir=$(mktemp -d -p "$TMPDIR" btrfs.XXXX || mktemp -d -p "/dev/shm" btrfs.XXXX)
+		mount "${LAST_PART}" $tmpdir
+		btrfs filesystem resize max $tmpdir
+		umount $tmpdir && rmdir $tmpdir
+		;;
+esac
-- 
2.34.1


             reply	other threads:[~2022-12-15 18:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15 18:06 Roberto A. Foglietta [this message]
2022-12-15 18:27 ` Roberto A. Foglietta
2022-12-15 23:00   ` Roberto A. Foglietta
2022-12-16  8:14     ` Roberto A. Foglietta
2022-12-16 11:38       ` Roberto A. Foglietta
2022-12-18 13:50         ` Roberto A. Foglietta

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='CAJGKYO58T1LZLMJ84+oLF3b6CtJcfEwz97=WGDcrWCanX+5HVA@mail.gmail.com' \
    --to=roberto.foglietta@gmail.com \
    --cc=amikan@ilbers.de \
    --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