- netboot-base.nix with SSH key auth - Launch scripts for node01/02/03 - Node configuration.nix and disko.nix - Nix modules for first-boot automation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
83 lines
3 KiB
Bash
Executable file
83 lines
3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# PlasmaCloud VM Cluster - Node 01 (Netboot with SSH Key)
|
|
# Features:
|
|
# - Direct kernel/initrd boot (no ISO required)
|
|
# - SSH key authentication baked in (no password setup needed)
|
|
# - Multicast socket for inter-VM L2 communication (eth0)
|
|
# - SLIRP with SSH port forward for host access (eth1)
|
|
# - Telnet serial console
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
DISK="${SCRIPT_DIR}/node02.qcow2"
|
|
KERNEL="${SCRIPT_DIR}/netboot-kernel/bzImage"
|
|
INITRD="${SCRIPT_DIR}/netboot-initrd/initrd"
|
|
|
|
# Networking
|
|
MAC_MCAST="52:54:00:12:34:02" # eth0: multicast (192.168.100.12)
|
|
MAC_SLIRP="52:54:00:aa:bb:02" # eth1: SLIRP DHCP (10.0.2.15)
|
|
MCAST_ADDR="230.0.0.1:1234"
|
|
SSH_PORT=2202 # Host port -> VM port 22
|
|
|
|
# Console access
|
|
VNC_DISPLAY=":2" # VNC fallback
|
|
SERIAL_PORT=4402 # Telnet serial
|
|
|
|
# Verify netboot artifacts exist
|
|
if [ ! -f "$KERNEL" ]; then
|
|
echo "ERROR: Kernel not found at $KERNEL"
|
|
echo "Build with: nix build .#nixosConfigurations.netboot-base.config.system.build.kernel"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "$INITRD" ]; then
|
|
echo "ERROR: Initrd not found at $INITRD"
|
|
echo "Build with: nix build .#nixosConfigurations.netboot-base.config.system.build.netbootRamdisk"
|
|
exit 1
|
|
fi
|
|
|
|
echo "============================================"
|
|
echo "Launching node02 with netboot (SSH key auth)..."
|
|
echo "============================================"
|
|
echo " Disk: ${DISK}"
|
|
echo " Kernel: ${KERNEL}"
|
|
echo " Initrd: ${INITRD}"
|
|
echo ""
|
|
echo "Network interfaces:"
|
|
echo " eth0 (mcast): MAC ${MAC_MCAST} -> configure 192.168.100.12"
|
|
echo " eth1 (SLIRP): MAC ${MAC_SLIRP} -> DHCP (10.0.2.x), SSH on host:${SSH_PORT}"
|
|
echo ""
|
|
echo "Console access:"
|
|
echo " Serial: telnet localhost ${SERIAL_PORT}"
|
|
echo " VNC: vncviewer localhost${VNC_DISPLAY} (port 5901)"
|
|
echo " SSH: ssh -o StrictHostKeyChecking=no -p ${SSH_PORT} root@localhost"
|
|
echo ""
|
|
echo "SSH key authentication is ENABLED (no password required!)"
|
|
echo "============================================"
|
|
|
|
qemu-system-x86_64 \
|
|
-name node02-netboot \
|
|
-machine type=q35,accel=kvm \
|
|
-cpu host \
|
|
-smp 8 \
|
|
-m 16G \
|
|
-drive file="${DISK}",if=virtio,format=qcow2 \
|
|
-kernel "${KERNEL}" \
|
|
-initrd "${INITRD}" \
|
|
-append "init=/nix/store/qj1ilfdd8fcrmz4pk282p5qdf2q0vkmh-nixos-system-nixos-kexec-26.05.20251205.f61125a/init console=ttyS0,115200 console=tty0 loglevel=4" \
|
|
-netdev socket,mcast="${MCAST_ADDR}",id=mcast0 \
|
|
-device virtio-net-pci,netdev=mcast0,mac="${MAC_MCAST}" \
|
|
-netdev user,id=user0,hostfwd=tcp::${SSH_PORT}-:22 \
|
|
-device virtio-net-pci,netdev=user0,mac="${MAC_SLIRP}" \
|
|
-vnc "${VNC_DISPLAY}" \
|
|
-serial mon:telnet:127.0.0.1:${SERIAL_PORT},server,nowait \
|
|
-daemonize
|
|
|
|
echo ""
|
|
echo "VM started! SSH should be available immediately:"
|
|
echo " ssh -o StrictHostKeyChecking=no -p ${SSH_PORT} root@localhost"
|
|
echo ""
|
|
echo "If needed, serial console:"
|
|
echo " telnet localhost ${SERIAL_PORT}"
|
|
echo ""
|