Files
operating-system/buildroot-external/rootfs-overlay/usr/sbin/hassio-expand
2018-04-17 18:53:45 +02:00

26 lines
660 B
Bash
Executable File

#!/bin/sh
set -e
DEVICE_CHILD=$(findfs LABEL="hassio-data")
DEVICE_ROOT="/dev/$(lsblk -no pkname ${DEVICE_CHILD})"
LAST_FREE_SECTOR=$(sgdisk -E ${DEVICE_ROOT})
# Need resize
if [ $LAST_FREE_SECTOR -le 2048 ]; then
echo "[INFO] No resize of data partition needed"
exit
fi
# Resize & Reload partition
echo "[INFO] Update hassio-data partition"
sgdisk -d 6 -n 6:0:0 -c 6:"hassio-data" -t 6:"0FC63DAF-8483-4772-8E79-3D69D8477DE4" ${DEVICE_ROOT}
sgdisk -v
blockdev --rereadpt ${DEVICE_ROOT}
# Resize filesystem
echo "[INFO] Resize hassio-data filesystem"
e2fsck -y ${DEVICE_CHILD}
resize2fs -f ${DEVICE_CHILD}
echo "[INFO] Finish hassio-data resizing"