#!/bin/bash
# Grows the root partition and filesystem to fill the disk.
# Runs once on first boot, then disables itself.
set -e

ROOT_DEV=$(findmnt -no SOURCE /)
DISK=$(lsblk -ndo PKNAME "$ROOT_DEV")
PART_NUM=$(cat /sys/class/block/$(basename "$ROOT_DEV")/partition)

growpart "/dev/$DISK" "$PART_NUM" || true
resize2fs "$ROOT_DEV" || true

systemctl disable grow-rootfs.service
