Files
operating-system/buildroot-external/rootfs-overlay/usr/sbin/hassio-expand
Pascal Vizeli 77293f58ca expand working
2018-04-18 00:18:53 +02:00

25 lines
629 B
Bash
Executable File

#!/bin/sh
set -e
DEVICE_CHILD=$(findfs LABEL="hassio-data")
DEVICE_ROOT="/dev/$(lsblk -no pkname ${DEVICE_CHILD})"
# Need resize
if [ $(sgdisk -E ${DEVICE_ROOT}) -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 ${DEVICE_ROOT}
partx -u ${DEVICE_ROOT}
# Resize filesystem
echo "[INFO] Resize hassio-data filesystem"
e2fsck -y ${DEVICE_CHILD}
resize2fs -f ${DEVICE_CHILD}
echo "[INFO] Finish hassio-data resizing"