diff --git a/recipes-bsp/diya-resizefs/diya-resizefs.bb b/recipes-bsp/diya-resizefs/diya-resizefs.bb new file mode 100644 index 0000000..ed40be7 --- /dev/null +++ b/recipes-bsp/diya-resizefs/diya-resizefs.bb @@ -0,0 +1,19 @@ + +DESCRIPTION = "Auto resize file system on first boot" +DEPENDS = "" +RDEPENDS:${PN} = "bash" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +SRC_URI += " file://resize2fs.service file://firstboot file://expandfs \ + " +inherit systemd +SYSTEMD_PACKAGES = "${PN}" +SYSTEMD_SERVICE:${PN} = "resize2fs.service" + +do_install() { + install -m 0644 ${UNPACKDIR}/firstboot ${D}${sysconfdir}/firstboot + install -m 0755 ${UNPACKDIR}/expandfs ${D}/usr/sbin/expandfs + install -D -p -m0644 ${UNPACKDIR}/resize2fs.service \ + ${D}${systemd_unitdir}/system/resize2fs.service +} \ No newline at end of file diff --git a/recipes-bsp/diya-resizefs/files/expandfs b/recipes-bsp/diya-resizefs/files/expandfs new file mode 100644 index 0000000..351c523 --- /dev/null +++ b/recipes-bsp/diya-resizefs/files/expandfs @@ -0,0 +1,14 @@ +#! /bin/sh +. /etc/profile +PATH=/sbin:/bin:/usr/sbin:/usr/bin +PARTNO=4 +if [ -z "$DISK" ]; then + DISK="mmcblk0" +fi + +if [ "$(/usr/bin/id -u)" -ne 0 ]; then + echo "$0 shall be run as root" + exit 1 +fi +yes | parted ---pretend-input-tty /dev/mmcblk0 resizepart ${PARTNO} 100% +resize2fs /dev/${DISK}p${PARTNO} \ No newline at end of file diff --git a/recipes-bsp/diya-resizefs/files/firstboot b/recipes-bsp/diya-resizefs/files/firstboot new file mode 100644 index 0000000..e69de29 diff --git a/recipes-bsp/diya-resizefs/files/resize2fs.service b/recipes-bsp/diya-resizefs/files/resize2fs.service new file mode 100644 index 0000000..40f0a9a --- /dev/null +++ b/recipes-bsp/diya-resizefs/files/resize2fs.service @@ -0,0 +1,12 @@ +[Unit] +Description=Resize home partition +ConditionPathExists=/etc/firstboot + +[Service] +Type=oneshot +ExecStart=/sbin/expandfs +ExecStartPost=rm /etc/firstboot +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target \ No newline at end of file