feat: add resizefs service
This commit is contained in:
19
recipes-bsp/diya-resizefs/diya-resizefs.bb
Normal file
19
recipes-bsp/diya-resizefs/diya-resizefs.bb
Normal 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
|
||||||
|
}
|
||||||
14
recipes-bsp/diya-resizefs/files/expandfs
Normal file
14
recipes-bsp/diya-resizefs/files/expandfs
Normal 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}
|
||||||
0
recipes-bsp/diya-resizefs/files/firstboot
Normal file
0
recipes-bsp/diya-resizefs/files/firstboot
Normal file
12
recipes-bsp/diya-resizefs/files/resize2fs.service
Normal file
12
recipes-bsp/diya-resizefs/files/resize2fs.service
Normal 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
|
||||||
Reference in New Issue
Block a user