LibreELEC v9 RPI3 PXE

  • I have a working PXE boot setup for my X86 Generic boxes but for the life of me I can not get my RPI3 to work. I've followed the following guides/tidbits of information listed below:


    Network Boot Your Raspberry Pi - Raspberry Pi Documentation

    init: mount per-client boot/disk if available & configured by MilhouseVH · Pull Request #621 · LibreELEC/LibreELEC.tv · GitHub


    I never see the PXE request with the SD card removed so I can't even debug that nor do I ever see the BOOTP request on my DHCP server from that MAC. I was going to even try with a simple SD card with bootcode.bin on it but I can't even get the network interface to come up on the RPI3 with that device there to load my cmdline.txt.


    Any thoughts to troubleshoot or help?

  • Hi


    Because I can't find a straight forward documentation about PXE boot with Raspi and LibreELEC, I will post my configuration, where I did today. I won't go in the details like how to install DHCP server, NFS server etc. There are a lot of good documentation... So let's start...


    Prerequirements (can be found on the net):

    - A working DHCP server

    - A working TFTP server

    - A working NFS server

    - A Raspberry who can and is configured for PXE boot

    - Knowledge about TFTP, NFS, DHCP, Linux etc.


    My setup:

    - opnSense firewall who is responsible for DHCP requests (10.243.29.1)

    - Ubuntu 18.04.3 who do the TFTP and NFS stuff with the IP 10.243.29.10

    - Rasperry Pi 3B+ with serial number 3X84XbXf and a via DHCP assigned IP 10.243.29.112

    - LibreELEC 9.2.0



    1. DHCP server configuration

    I use my opnSense as my DHCP server, so maybe you have to adapt the settings to your DHCP server, but here is my configuration with the Raspi PXE special configured fields:

    Code
    1. Services/DHCPv4/[lan]/TFTP server/Set TFTP hostname: 10.243.29.10
    2. Services/DHCPv4/[lan]/TFTP server/Set Bootfile: [let them empty]
    3. Services/DHCPv4/[lan]/Additional Options/Number:43 Type:Text Value:Raspberry Pi Boot
    4. Services/DHCPv4/[lan]/Additional Options/Number:60 Type:Text Value:PXEClient



    2. TFTP server configuration

    I use tftpd-hpa (apt-get install tftpd-hpa) as server and I made these changes:


    Code
    1. # /etc/default/tftpd-hpa
    2. TFTP_USERNAME="tftp"
    3. TFTP_DIRECTORY="/var/lib/tftpboot"
    4. TFTP_ADDRESS=":69"
    5. TFTP_OPTIONS="--secure -vvv"

    Don't forget to systemctl restart tftpd-hpa.service and let the TFTP server automatic start after reboot.



    3. NFS server

    There is nothing special configured on the NFS server, but here is my /etc/exports config to understand also next points:

    Code
    1. /nfs 10.243.29.0/24(rw,sync,no_subtree_check,no_root_squash)


    So, everything related to NFS is in the /nfs directory and don't forget to let the NFS server start after a reboot.



    4. LibreELEC image

    Download the latest LibreELEC Image from https://libreelec.tv/downloads_new/raspberry-pi-3-3 (or whatever you have) to your TFTP server, extract it, mount it temporary and copy the bootcode.bin file to the root directory from the TFTP server:


    Code
    1. [email protected]:/tmp# wget http://releases.libreelec.tv/LibreELEC-RPi2.arm-9.2.0.img.gz
    2. [email protected]:/tmp# losetup -f -P /tmp/LibreELEC-RPi2.arm-9.2.0.img
    3. [email protected]:/tmp# losetup -l
    4. NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
    5. /dev/loop1 0 0 1 1 /var/lib/snapd/snaps/core_8268.snap 0 512
    6. /dev/loop0 0 0 1 1 /var/lib/snapd/snaps/core_8213.snap 0 512
    7. /dev/loop3 0 0 0 0 /tmp/LibreELEC-RPi2.arm-9.2.0.img 0 512
    8. [email protected]:/tmp# mkdir /tmp/1
    9. [email protected]:/tmp# mount /dev/loop3p1 /tmp/1/
    10. [email protected]:/tmp# cp -vax /tmp/1/bootcode.bin /var/lib/tftpboot/


    Don't unmount the loop device, we need it later again...



    5. Get the Raspi serial number

    Now, just let your Raspi boot with PXE and have a look in /var/log/syslog, you can find a lot of sending NAK (1, File not found) to 10.243.29.112, but also the requests to the requested files, like RRQ from 10.243.29.112 filename 3X84XbXf/start.elf


    And here you are, you have your Raspi serial number: 3X84XbXf

    Ah, the filename in the syslog is relative to the tftp configuration where I set in /etc/default/tftpd-hpa:TFTP_DIRECTORY before.

    So you can have for each Raspi in your network your own PXE configuration, cool...



    6. Prepare the files on the TFTP server

    Because we have the LibreELEC image still mounted and also the serial number from our Raspi, we have to bring the things together and I change the cmdline.txt file:


    Code
    1. [email protected]:/tmp# mkdir /var/lib/tftpboot/3X84XbXf
    2. [email protected]:/tmp# cp -vax /tmp/1/* /var/lib/tftpboot/3X84XbXf/
    3. [email protected]:/tmp# echo "boot=NFS=10.243.29.10:/nfs/Raspi/3X84XbXf.boot disk=NFS=10.243.29.10:/nfs/Raspi/3X84XbXf.disk ssh ip=dhcp" >/var/lib/tftpboot/3X84XbXf/cmdline.txt



    7. Prepare the files on the NFS server

    On the NFS server, we have to prepare now the directories. The 3X84XbXf.boot is for the little binary stuff (only the "SYSTEM" file) and the 3X84XbXf.disk for the data from LibreELEC, we let them empty, LibreELEC fill it up after the first start. If you have the TFTP and NFS server on separate machines, you have to copy the file for the 3X84XbXf.boot directory from your TFTP server or download the LibreELEC again and attach it via loop again. For me, it's on the same machine and the image is still mounted to /tmp/1:

    Code
    1. [email protected]:/tmp# mkdir -p /nfs/Raspi/3X84XbXf.boot /nfs/Raspi/3X84XbXf.disk
    2. [email protected]:/tmp# cp -vax /tmp/1/SYSTEM /nfs/Raspi/3X84XbXf.boot


    Now, we don't need the LibreELEC image anymore, so you can unmount it and remove it as a loop device, or just reboot everything... Also the Raspi, because it should now boot from network and you can start to configure it :-)



    8. Something won't work

    Check the DHCP server log, what's going on with the requests (maybe you need to dump the packets with tcpdump).


    Have a look on the TFTP server's syslog file about "not found's".


    If everything is fine there and the problem is on the NFS side, you can start NFS debugging in the NFS server with rpcdebug -m nfsd -s proc, now everything is logged also to the syslog file. Stop it with rpcdebug -m nfsd -c



    I hope this help's you a bit through the jungle...


    gruss ivo

  • Excellent post ivoR. !


    I have a similar setup, but ran into firewall issues on my NFS server. LE would try to mount my NFS shares on random port numbers, which were of course blocked by the firewall. Everything works once I disable the firewall.

    Is your NFS server firewalled? If so, how did you make it work?

    I've not yet found any way to control the expected NFS port from within LE.

  • Is your NFS server firewalled? If so, how did you make it work?

    No, it's in the same subnet, so I don't care about.

    NFS throught FW should be normaly not a big issue...