#!/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"