rewrite based on reference project from github
This commit is contained in:
16
dracut-module/90netboot/module-setup.sh
Executable file
16
dracut-module/90netboot/module-setup.sh
Executable 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
|
||||
}
|
||||
32
dracut-module/90netboot/mount-netboot.sh
Executable file
32
dracut-module/90netboot/mount-netboot.sh
Executable 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"
|
||||
13
dracut-module/90netboot/parse-netboot.sh
Executable file
13
dracut-module/90netboot/parse-netboot.sh
Executable 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"
|
||||
Reference in New Issue
Block a user