diff --git a/boot-macOS-headless.sh b/boot-macOS-headless.sh old mode 100755 new mode 100644 index b5ce2e8..d3d938b --- a/boot-macOS-headless.sh +++ b/boot-macOS-headless.sh @@ -67,6 +67,8 @@ args=( -device vmware-svga -display none -vnc 0.0.0.0:1,password=on -k en-us + -netdev user,id=pxenet0,tftp=netboot/tftpboot,bootfile=pxelinux.0 + -device e1000,netdev=pxenet0 ) qemu-system-x86_64 "${args[@]}" diff --git a/netboot/dnsmasq.conf b/netboot/dnsmasq.conf new file mode 100644 index 0000000..86aebff --- /dev/null +++ b/netboot/dnsmasq.conf @@ -0,0 +1,10 @@ +# Configuration for dnsmasq to support PXE boot + +# Set the TFTP root directory +enable-tftp +tftp-root=/tftpboot + +# Configure DHCP options for PXE boot +dhcp-range=192.168.1.100,192.168.1.200,12h +dhcp-boot=pxelinux.0 +pxe-service=x86PC, "Install macOS", pxelinux diff --git a/netboot/get_internal_ip.sh b/netboot/get_internal_ip.sh new file mode 100644 index 0000000..837034d --- /dev/null +++ b/netboot/get_internal_ip.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Script to retrieve the internal IP address of the Codespace + +hostname -I diff --git a/netboot/pxelinux.cfg/default b/netboot/pxelinux.cfg/default new file mode 100644 index 0000000..f28e229 --- /dev/null +++ b/netboot/pxelinux.cfg/default @@ -0,0 +1,4 @@ +DEFAULT macOS +LABEL macOS + KERNEL vmlinuz + APPEND initrd=initrd.img diff --git a/netboot/serve_pxe.sh b/netboot/serve_pxe.sh new file mode 100644 index 0000000..cb42ae6 --- /dev/null +++ b/netboot/serve_pxe.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# Serve pxelinux.0, vmlinuz, and initrd via TFTP using dnsmasq + +# Ensure dnsmasq is installed +if ! command -v dnsmasq &> /dev/null +then + echo "dnsmasq could not be found, please install it." + exit +fi + +# Create tftpboot directory if it doesn't exist +TFTPBOOT_DIR="tftpboot" +if [ ! -d "$TFTPBOOT_DIR" ]; then + mkdir -p "$TFTPBOOT_DIR" +fi + +# Copy necessary files to tftpboot directory +cp pxelinux.0 "$TFTPBOOT_DIR/" +cp vmlinuz "$TFTPBOOT_DIR/" +cp initrd.img "$TFTPBOOT_DIR/" + +# Start dnsmasq to serve PXE boot files +dnsmasq --conf-file=netboot/dnsmasq.conf