@@ -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 \
@@ -59,29 +59,17 @@ 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}"
+tmp=${BOOT_DEV_TMPDIR:-/dev/shm}
+case $(lsblk -fno FSTYPE "${LAST_PART}") in
+ ext4) resize2fs "${LAST_PART}"
+ ;;
+ btrfs) mkdir -p $tmp/btrfs
+ mount "${LAST_PART}" $tmp/btrfs
+ btrfs filesystem resize max $tmp/btrfs
+ umount $tmp/btrfs && rmdir $tmp/btrfs
+ ;;
+esac