Network Booting LibreElec to Raspberry Pi’s from a Synology NAS

Work Environment

NAS: Synology DS216+II with DSM 6.1.7-15284

Netgear WNDR3700v2 Router Running Gargoyle Firmware version 1.10.0

Raspberry Pi’s

Before you begin

Enable SSH on the NAS.

If you have a battery backup unit then enable UPS.

Download LibreElec image files for all architectures of Raspberry Pi’s on the network (i.e. RPi1, RPI3)

If your router acts as the DHCP server in your network then it will need to support network booting (most do not) if you want to continue to use it as the DHCP server, otherwise you will need to disable DHCP on your router and setup a DHCP server on your NAS. An alternative is to install a Linux firmware to your router if it’s possible (i.e. OpenWRT, DD-WRT, etc.) which is the scenario used for this guide.

Synology Setup

Enable TFTP service on your NAS. (Control Panel -> File Services -> TFTP) and select a root folder to use for network boot files. (i.e. shared folder called “public” with a folder inside called “pxeboot”.)

Enable NFS service on your NAS. (Control Panel -> File Services -> SMB/AFP/NFS). Now click on “Shared Folder” and select the network share that you chose for network booting (i.e. “public”) and click the “Edit” button. Choose the NFS Permissions tab and click on the “Create” button. Use the following rules:

Hostname or IP: *
Privilage: Read/Write
Squash: Map all users to admin
Security: sys

Make sure the box is ticked for “Enable asynchronous”, “Allow connections from non-privilaged ports (ports higher than 1024)”, and “Allow users to access mounted subfolders” and click on the “OK” button. Click on the “OK” button to enable NFS on the selected share. From a Linux computer, test that the NFS share is now working (i.e. Try to access “nfs://synology/volume1/public”). If you are unable to access the NFS share from another computer on your network, then this issue will need to be resolved first before continuing.

Inside the root folder that you chose for the network boot files (i.e. “pxeboot”), you will want to create a folder for all of the LibreElec files (i.e. “libreelec”) and then create two folders under that called “System” and “Storage”. Under the “System” folder you will want to create folders for each type of Raspberry Pi architecture that you will be using (i.e. “RPi1”, “RPi3”) and copy all the files from the “LIBREELEC” partition of the downloaded LibreElec image file to the corresponding RPi folder (i.e. “RPi3”). Copy the “bootcode.bin” file to the root folder (i.e. “pxeboot”). Edit the cmdline.txt file and change it to the following while substituting [synology] with the IP address of your NAS:

boot=NFS=[synology]:/volume1/public/pxeboot/libreelec/System/RPi3 disk=NFS=[synology]:/volume1/public/pxeboot/libreelec/Storage/@UID@ quiet ssh ip=dhcp

Do the same for any other Raspberry Pi architectures on the network.

Router Setup

SSH into your router running Linux firmware and add the following to the /etc/config/dhcp file substituting [synology] with the IP address of your NAS:

config mac 'rasperrypi'
   option mac 'b8:27:eb:*:*:*'
   option networkid 'rasperrypi'
   list dhcp_option '66,[synology]'
   list dhcp_option '43,Raspberry Pi Boot'

Reboot your router.

Raspberry Pi Setup

For Raspberry Pi 2’s  and older: Before a Raspberry Pi will network boot, an SD card with only the “bootcode.bin” file needs to be inserted in the Pi at all times.

For Raspberry Pi 3’s only: Before a Raspberry Pi will network boot, it needs to be booted from an SD card with a config option to enable USB boot mode. This will set a bit in the OTP (One Time Programmable) memory in the Raspberry Pi SoC that enables network booting. Once this is done, the SD card is no longer required.

Install Raspbian Lite (or Raspbian with Raspberry Pi Desktop) on the SD card in the usual way. Once booted up, log in and get the serial number of the Pi using the following command:

$ cat /proc/cpuinfo

Look for where it says “Serial” and write down the last 8 characters of this number because you will need it for later.

Program USB boot mode (for Raspberry Pi 3 Only)

First, prepare the /boot directory with the latest boot files:

sudo apt-get update && sudo apt-get upgrade

Now, enable USB boot mode with the following command:

echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt

This adds program_usb_boot_mode=1 to the end of /boot/config.txt. Reboot the Raspberry Pi with sudo reboot. Once the client Raspberry Pi has rebooted, check that the OTP has been programmed with:

$ vcgencmd otp_dump | grep 17:

Ensure the output 0x3020000a is correct.

The client configuration is almost done. The final thing to do is to remove the program_usb_boot_mode line from config.txt (make sure there is no blank line at the end). You can do this with sudo nano /boot/config.txt, for example. Finally, shut the client Raspberry Pi down with sudo poweroff.

Finishing Up

SSH into your Synology NAS and create a symlink for each Raspberry Pi that will be network booted substituting [arch] with the corresponding architecture (i.e. “RPi3”) and [serial] with the serial number of the Pi that you wrote down earlier:

sudo ln -s /volume1/public/pxeboot/libreelec/System/[arch] /volume1/public/pxeboot/[serial]

Also, create a folder under “Storage” for this Pi substituting [serial] with the serial number of the Pi that you wrote down earlier:

mkdir /volume1/public/pxeboot/libreelec/Storage/[serial]

Connect this Pi to the network and power it up. It should now network boot to LibreElec.