rewrite based on reference project from github

This commit is contained in:
2026-01-30 22:58:37 +01:00
parent 1e884eec99
commit 4790e69113
4 changed files with 74 additions and 18 deletions

View File

@@ -0,0 +1,16 @@
#!/bin/bash
check() {
return 0
}
depends() {
echo network url-lib
return 0
}
install() {
inst_hook cmdline 90 "$moddir/parse-netboot.sh"
inst_hook pre-mount 90 "$moddir/mount-netboot.sh"
inst_multiple wget curl
}

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# Download and mount squashfs root with overlay
. /tmp/netboot.conf
info "Downloading root filesystem from http://${BOOT_SERVER}/${IMAGE_VERSION}/filesystem.squashfs"
mkdir -p /run/netboot
wget -O /run/netboot/root.squashfs \
"http://${BOOT_SERVER}/${IMAGE_VERSION}/filesystem.squashfs" || \
die "Failed to download root filesystem from $BOOT_SERVER"
info "Download complete, mounting filesystems..."
# Mount squashfs (read-only base)
mkdir -p /run/rootfs/lower
mount -t squashfs /run/netboot/root.squashfs /run/rootfs/lower || \
die "Failed to mount squashfs"
# Create tmpfs for overlay (writable layer)
mkdir -p /run/rootfs/upper /run/rootfs/work
mount -t tmpfs -o size=4G tmpfs /run/rootfs/upper || \
die "Failed to create tmpfs overlay"
mkdir -p /run/rootfs/upper/upper /run/rootfs/upper/work
# Mount overlay (combines read-only base + writable tmpfs)
mount -t overlay overlay \
-o lowerdir=/run/rootfs/lower,upperdir=/run/rootfs/upper/upper,workdir=/run/rootfs/upper/work \
/sysroot || \
die "Failed to mount overlay"
info "Root filesystem mounted successfully"

View File

@@ -0,0 +1,13 @@
#!/bin/sh
# Parse netboot parameters from kernel command line
BOOT_SERVER=$(getarg boot_server=)
IMAGE_VERSION=$(getarg image_version=)
[ -z "$BOOT_SERVER" ] && BOOT_SERVER="192.168.100.1"
[ -z "$IMAGE_VERSION" ] && IMAGE_VERSION="latest"
echo "BOOT_SERVER=$BOOT_SERVER" > /tmp/netboot.conf
echo "IMAGE_VERSION=$IMAGE_VERSION" >> /tmp/netboot.conf
info "Netboot: server=$BOOT_SERVER version=$IMAGE_VERSION"