|
|
This tutorial explains, how to build openwrrt to have it run on NFS.
|
|
|
|
|
|
# Prerequisite
|
|
|
|
|
|
Follow https://wiki.openwrt.org/doc/howto/build to set up a build environment.
|
|
|
|
|
|
# Configure the system
|
|
|
|
|
|
## Special configuration options to be used
|
|
|
|
|
|
Unless otherwise specified all statements are to be considered relative to your openwrt build root.
|
|
|
|
|
|
Use make menuconfig to configure the system. At least the following items have to be changed. AFAIK this works only for network devices that don't need any special firmware to be loaded.
|
|
|
|
|
|
```
|
|
|
Target System (x86)
|
|
|
Subtarget (x86_64)
|
|
|
Target images --->
|
|
|
[*] tar.gz
|
|
|
Global Build Settings --->
|
|
|
[*] Compile the kernel with rootfs on NFS
|
|
|
[*] Image configuration --->
|
|
|
[*] Preinit configuration options --->
|
|
|
(disabled) Preinit network interface
|
|
|
```
|
|
|
|
|
|
Also make sure that `KERNEL_IP_PNP_DHCP=y` is in your resulting .config.
|
|
|
|
|
|
The target image is extracted on the nfs root. NFS support has to be enabled in the kernel. The preinit network interface has to be set to disabled so the openwrt preinit script does not disable the network device on boot.
|
|
|
|
|
|
## Compile the network devices drivers
|
|
|
|
|
|
The network device drivers have to be compiled in the kernel. This means editing the .config file per hand.
|
|
|
|
|
|
An example would be to use an Intel e1000 or e1000e network card. Kernel drivers to be included in the kernel are to be prepended with `CONFIG_KERNEL_`. This would result in appending the following lines to your `.config`:
|
|
|
|
|
|
```
|
|
|
CONFIG_KERNEL_NET_VENDOR_INTEL=y
|
|
|
CONFIG_KERNEL_E1000=y
|
|
|
CONFIG_KERNEL_E1000E=y
|
|
|
```
|
|
|
|
|
|
This is not possible with `make menuconfig` - you have to edit the `.config` with your text editor of choice.
|
|
|
|
|
|
## Change the network configuration
|
|
|
|
|
|
Create the following file:
|
|
|
|
|
|
```bash
|
|
|
$ mkdir -p files/etc/config
|
|
|
$ vim files/etc/config/network
|
|
|
```
|
|
|
|
|
|
The file should contain the following plus every other network configuration required. It is mandatory _not_ to include the network device used for the NFS root.
|
|
|
|
|
|
```
|
|
|
config interface loopback
|
|
|
option ifname lo
|
|
|
option proto static
|
|
|
option ipaddr 127.0.0.1
|
|
|
option netmask 255.0.0.0
|
|
|
```
|
|
|
|
|
|
## Build openwrt
|
|
|
|
|
|
Now you can build openwrt with `make V=s`. This generates two files we need in `bin/targets/x86/64`:
|
|
|
|
|
|
- the kernel in `lede-x86-64-vmlinuz`
|
|
|
- the nfsroot to be in `lede-x86-64-generic-rootfs.tar.gz`
|
|
|
|
|
|
# Deploy openwrt
|
|
|
|
|
|
## Setup the NFS root
|
|
|
|
|
|
Just extract the afformentioned `.tar.gz` to a folder which is shared via NFS.
|
|
|
|
|
|
## Setup the PXE server
|
|
|
|
|
|
Assuming a PXE server with tftp is already installed and running the aformentioned vmlinuz image has to be copied to the tftp. The `pxelinux.cfg` entry is equivalent to a normal linux PXE NFS root.
|
|
|
```
|
|
|
LABEL openwrt
|
|
|
KERNEL openwrt/vmlinuz
|
|
|
APPEND panic=0 root=/dev/nfs nfsroot=192.168.1.1:/var/nfs/openwrt,nolock,v3,intr,hard,noacl ip=dhcp rw
|
|
|
```
|
|
|
|
|
|
`panic=0` disables the automatic reboots on kernel panics - helpful during debugging. The rest of the parameters are standard kernel command line parameters.
|
|
|
|
|
|
# Done
|
|
|
|
|
|
Now boot the client and enjoy. |