Network Boot - NFS

This guide shows how to boot LibreELEC using PXE boot with system and storage mounted via nfs.

General setup

Download the image for your device.

  • Create a readonly nfs export and place the “KERNEL” and “SYSTEM” files in to it.
  • Create a read-write nfs export for storage.
  • Create a file in pxelinux.cfg with the mac-address of your device (eg. 90-91-92-93-94-95).
  • Edit this file and add:
 DEFAULT LibreELEC.tv
 PROMPT 0

 LABEL LibreELEC.tv
   KERNEL libreelec/KERNEL
     APPEND ip=dhcp boot=NFS=192.168.0.1:/mnt/store/libreelec disk=NFS=192.168.0.1:/mnt/store/libreelec/storage overlay

…replacing IP address with the IP of NFS server and mountpoints on the server of course. Also, you don't need the overlay parameter if you only intend to use one system.

Now LibreELEC should boot using tftp and nfs!

Ubuntu 18.04

Basically you can use the above mentioned steps when configuring this in Ubuntu. This part will elaborate on the information above in more detail. First, we need to install the software that is required to make everything work. Considering you are a normal user, we will be using sudo throughout the process.

To enable your clients to boot from the network, install DHCP, TFTP and NFS:

sudo apt install isc-dhcp-server tftpd-hpa nfs-kernel-server

After installing the software, you have to configure DHCP.

Edit the file in /etc/dhcp/dhcpd.conf. Here's a common configuration:

authoritative;
allow booting;
allow bootp;

ddns-update-style none;

default-lease-time 86400;
max-lease-time 86400;

subnet 192.168.0.0 netmask 255.255.255.0
{
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.0.255;
  option domain-name-servers 192.168.0.2, 192.168.0.1;
  option routers 192.168.0.1;

  range 192.168.0.10 192.168.0.200;
  next-server 192.168.0.2;
  filename "/pxelinux.0";

  host <name>
  {
      hardware ethernet 00:0a:0b:0c:0d:0e;
      fixed-address 192.168.0.5;
  }
}

If you want another range for clients using DHCP, modify your own configuration accordingly. If you want to assign a specific IP address to a client, modify the host section.

Next, edit the file /etc/default/isc-dhcp-server. This file contains the reference to the interface card that will be handling the DHCP requests:

INTERFACES="eth0"

Save your changes. Your DHCP server is now ready to go.

First, create the directories in which you want to locate your storage (userdata) and boot files for tftp. e.g.

sudo mkdir /mnt/media/storage
sudo mkdir -m777 /mnt/tftpboot

Copy the KERNEL and SYSTEM files into the /mnt/tftpboot directory using

sudo cp KERNEL /mnt/tftpboot
sudo cp SYSTEM /mnt/tftpboot

Then add the following lines to your /etc/exports:

/mnt/media/storage      192.168.0.2/255.255.255.0(no_root_squash,rw,async,no_subtree_check)
/mnt/tftpboot           192.168.0.2/255.255.255.0(no_root_squash,rw,async,no_subtree_check)

That's it for your exports.

First, you need to create some directories. I chose to serve my tftp from a different disk. In the end, tftp will retrieve its bootfiles from this location.

sudo mkdir /mnt/tftpboot/pxelinux.cfg/
sudo cp -p /usr/lib/syslinux/pxelinux.0 /mnt/tftpboot/

At this time, you may also want to copy the KERNEL and SYSTEM files to /mnt/tftpboot/.

Now, insert the following lines into the tftpd-hpa file in /etc/default and save the file:

RUN_DAEMON="yes"
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/mnt/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"

Next, create a file /mnt/tftpboot/pxelinux.cfg/default, insert the following lines and save the changes:

DEFAULT LibreELEC.tv
PROMPT 0

LABEL LibreELEC.tv
kernel /KERNEL
append ip=dhcp boot=NFS=192.168.0.2:/mnt/tftpboot disk=NFS=192.168.0.2:/mnt/media/storage

And that's it. There's nothing more to it to get it to work. Finally, start all services and you're ready to go.

sudo service isc-dhcp-server start
sudo service nfs-kernel-server start
sudo service tftpd-hpa start

Make sure you enter the following rules into your firewall (e.g. ufw):

sudo ufw allow proto udp from 192.168.0.0/24 to any port 69  (for tftp)
sudo ufw allow proto tcp from 192.168.0.0/24 to any port 111 (for LibreELEC)

Normally, LibreELEC will connect to Kodi through a different (random if you will) port every time you boot the system. With ufw active, everytime you do this, LibreELEC will “hang” because there is no firewall rule. So in case you want LibreELEC to connect through a specific port, you need to modify the mountd options.

vi /etc/default/nfs-kernel-server

Then comment out RPCMOUNTDPOTS and insert the following line:

RPCMOUNTDOPTS="-p <port>" # <port> is a random port, e.g. 13025.

Finally, add a rule for this port to your firewall configuration:

sudo ufw allow proto tcp from 192.168.0.0/24 to any port 13025