{"id":20545468,"url":"https://github.com/belchy06/pxebootingrpi4","last_synced_at":"2026-06-28T20:31:37.905Z","repository":{"id":133170360,"uuid":"380071875","full_name":"Belchy06/PXEBootingRPi4","owner":"Belchy06","description":"A guide on how you can pxe boot a Raspberry Pi 4","archived":false,"fork":false,"pushed_at":"2021-06-30T05:44:18.000Z","size":13457,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T23:45:10.926Z","etag":null,"topics":["raspberry-pi","rpi"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Belchy06.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-24T23:15:29.000Z","updated_at":"2022-02-16T23:16:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"12c35ddd-6d3c-48b1-8948-60bb73121193","html_url":"https://github.com/Belchy06/PXEBootingRPi4","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Belchy06/PXEBootingRPi4","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Belchy06%2FPXEBootingRPi4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Belchy06%2FPXEBootingRPi4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Belchy06%2FPXEBootingRPi4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Belchy06%2FPXEBootingRPi4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Belchy06","download_url":"https://codeload.github.com/Belchy06/PXEBootingRPi4/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Belchy06%2FPXEBootingRPi4/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34903523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["raspberry-pi","rpi"],"created_at":"2024-11-16T01:52:18.884Z","updated_at":"2026-06-28T20:31:37.856Z","avatar_url":"https://github.com/Belchy06.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# PXEBootingRPi4\n## Last tested: 25/06/2021\nThis guide is based off of: https://www.reddit.com/r/raspberry_pi/comments/l7bzq8/guide_pxe_booting_to_a_raspberry_pi_4/ written by u/Offbeatalchemy, updated with some extra information obtained from the troubles I had following the guide.\n\nIn this guide, our server will double as both the DHCP and our TFTP server.  \nThis guide also uses Raspbian Lite images to boot the client pi. There's no reason any other ARM based Linux distro won't work, I just haven't personally tried them.\n\n# Assumptions\nThis guide works for networks where only the server and pi are on the network. For larger networks, you may experience interference from other routers with DHCP enabled. Disable the DHCP feature of these routers and you should be good to go! \n\n\n# Server prep\nThis guide uses a Ubuntu 20.04.2LTS virtual machine running on VirtualBox as the server, although you can use the host just fine.\nA virtual disk size of 25GB proves sufficient, I tested 20GB and that was not enough space. Also, ensure that you setup the VM's network adapter to be the `bridged adapter` and choose the name of the adapter you're using in the next dropdown.\nUsing a virtual machine ensures a fresh install. If you run into software conflicts, you're on your own.\n\nFirst, install the needed programs:\n```\nsudo apt update\nsudo apt install nfs-kernel-server kpartx unzip -y\n```\nSecond, we'll ceate a few directories for hosting the boot files. These files need to be created from the very root of the files system. This can be achieved by running `cd ../..`. Double check you are in the correct directory by running `ls`, you should see around 19 results with folders such as `bin`, `dev`, `lib`, etc... \n```\nsudo mkdir /srv/tftpboot\nsudo mkdir /srv/nfs\n```\n\nThirdly, install `dnsmasq`. This package will listen for PXE requests and handle TFTP.\n```\nsudo apt update\nsudo apt install dnsmasq -y\n```\nIt is normal to see an error after installing dnsmasq. Ubuntu 18.04+ comes with `systemd-resolve` which binds to port 53 and therefore conflicts with the `dnsmasq` port. Run the following commands to disable the `systemd-resolve` service:\n```\nsudo systemctl disable systemd-resolved\nsudo systemctl stop systemd-resolved\n```\nalso, remove the symlinked `resolv.conf` file:\n```\nls -lh /etc/resolv.conf\nsudo rm /etc/resolv.conf\n```\nthen, create a new `resolv.conf` file:\n```\necho nameserver 8.8.8.8 | sudo tee /etc/resolv.conf\n```\nand finally restart the `dnsmasq` service:\n```\nsudo systemctl restart dnsmasq\n```\n\nNext, we'll need to edit the `dnsmasq.conf` file. Start by finding your VM's external IP address with `hostname -I`. In this case my server IP is `10.115.11.182`. Any time you see this value make sure to subsitute it with your IP.\nNotice how the first three octets of the `dhcp-range` match that of the server IP:\n```\ncat \u003e /etc/dnsmasq.conf \u003c\u003c EOF\ndhcp-range=10.115.11.0,10.115.11.254,12h\nlog-dhcp\nenable-tftp\ntftp-root=/srv/tftpboot\npxe-service=0,\"Raspberry Pi Boot\"\ndhcp-boot=pxelinux.0,10.115.11.182\nEOF\n```\nand then restart `dnsmasq`:\n```\nsudo systemctl restart dnsmasq\n```\n\n# Client prep - readying the client pi for network boot\nNow, we need to get the client pi ready to pxe boot by enabling network booting fallback. But first, we need to make sure the firmware is up to date:\n```sudo apt update \u0026\u0026 sudo apt upgrade -y```\n\nThen open raspi-config\n\n```sudo raspi-config```\n\nNavigate through to and enable\n```\nAdvanced Options \u003e Boot Order \u003e Network Boot\n```\nBefore you reboot the client pi, you'll need the serial number for this pi. You'll need this for later, note that the serial should be 8 characters\n```\ncat /proc/cpuinfo | grep Serial | awk -F ': ' '{print $2}' | tail -c 9\n```\n\nYou can now reboot the pi without an SD card and will bring you to a boot screen that will loop while looking from a PXE server to boot from\n```\nsudo reboot\n```\n\n# Setting up the image\nBack on the Ubuntu VM now. These next few steps are much easier if you're root:\n```\nsudo -s\n```\nMake a temporary area for the files\n```\nmkdir /tmp/pxestuff\ncd /tmp/pxestuff\n```\nDownload and unzip the latest raspbian lite image\n```\nwget -O raspbian_lite_latest.zip https://downloads.raspberrypi.org/raspbian_lite_latest\nunzip raspbian_lite_latest.zip\n```\n\nMount the partitions from the image\n```\nkpartx -a -v *.img\nmkdir {bootmnt,rootmnt}\n```\nThe output from this will look something like:\n```\nadd map loop5p1 (253:0): 0 523288 linear 7:5 8192\nadd map loop5p2 (253:1): 0 3080192 linear 7:5 532480\n```\nTake note of the value after `map`, you'll need this in the next step. Then:\n```\nmount /dev/mapper/loop5p1 bootmnt/\nmount /dev/mapper/loop5p2 rootmnt/\n```\nUse the serial number we noted from the client pi along with an arbitrary name for the pi and the IP of Ubuntu VM, initialize some vars for use in the following steps:\n```\nPI_SERIAL=12345678\n\nKICKSTART_IP=10.115.11.182\n\nPI_NAME=NameOfPi\n```\n\nCopy the image unique to this pi and updates the bootfiles and firmware\n```\nmkdir -p /srv/nfs/${PI_NAME}\nmkdir -p /srv/tftpboot/${PI_SERIAL}\ncp -a rootmnt/* /srv/nfs/${PI_NAME}\ncp -a bootmnt/* /srv/nfs/${PI_NAME}/boot/\nrm /srv/nfs/${PI_NAME}/boot/start4.elf\nrm /srv/nfs/${PI_NAME}/boot/fixup4.dat\nwget https://github.com/Hexxeh/rpi-firmware/raw/stable/start4.elf -P /srv/nfs/${PI_NAME}/boot/\nwget https://github.com/Hexxeh/rpi-firmware/raw/stable/fixup4.dat -P /srv/nfs/${PI_NAME}/boot/\n```\nUpdate the mounts on the server so the pi can grab the files\n```\necho \"/srv/nfs/${PI_NAME}/boot /srv/tftpboot/${PI_SERIAL} none defaults,bind 0 0\" \u003e\u003e /etc/fstab\necho \"/srv/nfs/${PI_NAME} *(rw,sync,no_subtree_check,no_root_squash)\" \u003e\u003e /etc/exports\nmount /srv/tftpboot/${PI_SERIAL}/\ntouch /srv/nfs/${PI_NAME}/boot/ssh\nsed -i /UUID/d /srv/nfs/${PI_NAME}/etc/fstab\necho \"console=serial0,115200 console=tty root=/dev/nfs nfsroot=${KICKSTART_IP}:/srv/nfs/${PI_NAME},vers=3 rw ip=dhcp rootwait elevator=deadline\" \u003e /srv/nfs/${PI_NAME}/boot/cmdline.txt\n```\n\nClean up\n```\nsystemctl restart rpcbind\nsystemctl restart nfs-server\numount bootmnt/\numount rootmnt/\nrm /tmp/pxestuff -r\n```\n\n# Test the image\nOn the server, run:\n```\njournalctl -xefu dnsmasq\n```\nto view the output of dnsmasq, plug in your pi and it should boot into raspbian lite.\n\nIt may restart more than once, especially between updates, that's normal.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelchy06%2Fpxebootingrpi4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbelchy06%2Fpxebootingrpi4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelchy06%2Fpxebootingrpi4/lists"}