Network Boot - NFS

From OpenELEC
Jump to: navigation, search

Contents

Introduction

This guide shows how to boot openelec using pxe boot with system and storage mounted via nfs.

General setup

Download the image for your device.

  1. Create a readonly nfs export and place the "KERNEL" and "SYSTEM" files in to it. (Sancho: This step was unnecessary for me, the simple copy to the tftpboot directory was enough, no readonly NFS export is required)
  2. Create a read-write nfs export for storage.
  3. Create a file in pxelinux.cfg with the mac-address of your device (eg. 90-91-92-93-94-95).
  4. Edit this file and add:
DEFAULT OpenElec.tv
PROMPT 0

LABEL OpenElec.tv
       KERNEL openelec/KERNEL
       APPEND ip=dhcp boot=NFS=192.168.0.1:/mnt/store/openelec disk=NFS=192.168.0.1:/mnt/store/openelec/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 openelec should boot using tftp and nfs!

Ubuntu 12.04 LTS

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.

Installing the software

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

# sudo aptitude install isc-dhcp-server tftpd-hpa nfs-kernel-server

Note that, in Ubuntu 12.04, ISC DHCP server is a transitional package for dhcp3-server.

Configure DHCP

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.

Configure NFS

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.

Configure TFTP

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 OpenElec.tv
PROMPT 0

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

Starting services

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

Additional configuration: firewall

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 openelec)

Additional configuration: mountd

Normally, OpenElec will connect to XBMC through a different (random if you will) port every time you boot the system. With ufw active, everytime you do this, OpenElec will "hang" because there is no firewall rule. So in case you want Openelec 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
Personal tools
Namespaces
Variants
Actions
Donate
Navigation
Wiki help
Toolbox