From 9ab1ca3d1f980b3f05759ca2d2f3db6abaae11ea Mon Sep 17 00:00:00 2001 From: "Roberto A. Foglietta" 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 --- .../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