feat: add resizefs service

This commit is contained in:
2026-04-09 01:05:39 +02:00
parent 656e7147dc
commit 8297499157
4 changed files with 45 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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}

View File

@@ -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