JeffReeves / substruct-server

Network boot server for substruct

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

substruct-server

Network boot server for substruct

Install - Ubuntu 20.04

SYSLINUX and PXELINUX

Install SYSLINUX and PXELINUX:

sudo apt-get install syslinux pxelinux

iPXE

Create a directory to store iPXE files and download them from the web:

mkdir ~/ipxe
curl http://boot.ipxe.org/undionly.kpxe --output ~/ipxe/undionly.kpxe
curl http://boot.ipxe.org/ipxe.efi      --output ~/ipxe/ipxe.efi

Or build iPXE from source for any additional features (such as graphical backgrounds):

TFTP

Install the TFTP server:

sudo apt-get install tftpd-hpa

Configure TFTPD via /etc/default/tftpd-hpa:

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"

Make a /tftpboot directory with full permissions:

sudo mkdir      /tftpboot
sudo chmod 777  /tftpboot

Copy SYSLINUX, PXELINUX, and iPXE files into it:

sudo cp /usr/lib/syslinux/modules/bios/ldlinux.c32  /tftpboot
sudo cp /usr/lib/syslinux/modules/efi64/ldlinux.e64 /tftpboot
sudo cp /usr/lib/syslinux/modules/efi64/libutil.c32 /tftpboot
sudo cp /usr/lib/syslinux/modules/efi64/menu.c32    /tftpboot
sudo cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi    /tftpboot
sudo cp /usr/lib/PXELINUX/pxelinux.0                /tftpboot
sudo cp /usr/lib/PXELINUX/lpxelinux.0               /tftpboot
cp      ~/ipxe/ipxe.efi                             /tftpboot
cp      ~/ipxe/undionly.kpxe                        /tftpboot

Make the /tftpboot/pxelinux.cfg directory to store boot menus:

sudo mkdir /tftpboot/pxelinux.cfg
sudo touch /tftpboot/pxelinux.cfg/default

Start and enable TFTPD:

sudo systemctl enable  tftpd-hpa
sudo systemctl restart tftpd-hpa

DHCP

Install the DHCP server:

sudo apt-get install isc-dhcp-server

Edit the /etc/dhcp/dhcpd.conf file to include PXE booting options:

NOTE: Replace the IP address 192.168.1.3 with your server's IP address

# PXE BOOTING
option client-arch code 93 = unsigned integer 16;
# if iPXE is loaded, access main bootstrap iPXE script
if exists user-class and option user-class = "iPXE" {
    filename "http://192.168.1.3/tftpboot/ipxe/scripts/bootstrap.ipxe";
} else {

    if exists client-arch {
        if option client-arch = 00:00 {      # prevent bootloop on chain loading
            filename "ipxe/undionly.kpxe";
        } elsif option client-arch = 00:06 { # i386
            filename "ipxe/bin-i386-efi/ipxe.efi";
        } elsif option client-arch = 00:07 { # x86_64
            filename "ipxe/bin-x86_64-efi/ipxe.efi";
        } elsif option client-arch = 00:09 { # x86_64
            filename "ipxe/bin-x86_64-efi/ipxe.efi";
        } elsif option client-arch = 00:0a { # arm32
            filename "ipxe/bin-arm32-efi/ipxe.efi";
        } elsif option client-arch = 00:0b { # arm64 / aarch64
            filename "ipxe/bin-arm64-efi/ipxe.efi";     #<-- custom compiled iPXE arm64
            #filename "ipxe/netboot.xyz-rpi4-snp.efi";   #<-- works to load netboot with working iPXE
            #filename "efi/boot/bootaa64.efi";           #<-- also works, same issues as above
            #filename  "ipxe/tests/arm64/ipxe.efi";      #<-- custom compiled arm64 iPXE
            #filename "ipxe/arm64-efi/ipxe.efi";         #<-- boots but fails after iPXE init devices
        }
    }
}
next-server 192.168.1.3;

Start and enable the DHCP server:

sudo systemctl enable  isc-dhcp-server
sudo systemctl restart isc-dhcp-server

Nginx

Install the web server:

sudo apt-get install nginx

Delete the default website:

sudo rm /etc/nginx/sites-available/default

Create a new website file:

sudo vim /etc/nginx/sites-available/substruct

Place this content inside of the file to define an HTTP server:

# HTTP - PORT 80
server {
    listen         80;
    listen         [::]:80;
    server_name    substruct;
    server_tokens  off;
    root           /var/www/substruct;
    index          index.html;

    # redirect to HTTPS
    #return 301 https://$server_name$request_uri;

    location / {
        autoindex    on;
        try_files    $uri $uri/ =404;
    }

    access_log     /var/log/nginx/substruct.log;
    error_log      /var/log/nginx/substruct.error.log;
}

Create the root web directory:

sudo mkdir -p /var/www/substruct

Start and enable the HTTP server:

sudo systemctl enable  nginx
sudo systemctl restart nginx

Mount and Copy Operating Systems for Network Booting

RHEL 8 DVD ISO

sudo mkdir /mnt/rhel8-install/
sudo mount -o loop,ro -t iso9660 ~/Downloads/rhel8/rhel-8.4-x86_64-dvd.iso /mnt/rhel8-install/

Configure Raspberry Pi 4 (RPi4)

The Raspberry Pi 4 uses eeprom to network boot.

To enable network booting:

  1. Copy the official Raspberry Pi OS (formerly "Raspbian") to an SD card.
  2. Boot the RPi4 and open a terminal.
  3. Update all packages: sudo apt-get update && sudo apt-get dist-upgrade -y.
  4. Install the eeprom updater: sudo apt-get install rpi-eeprom.
  5. Update eeprom: sudo rpi-eeprom-update.
  6. Reboot: sudo sync && sudo reboot.
  7. Set BOOT_ORDER=0xf421 and TFTP_PREFIX=2 with: sudo -E rpi-eeprom-config --edit.

NOTE: The TFTP_PREFIX=2 option makes it so that the /tftpboot directory uses RPi MAC address values instead of serial numbers.

See the official documentation located here for further details:

To network boot an entire Raspberry Pi OS, see the official tutorial here:

About

Network boot server for substruct

License:GNU General Public License v3.0