Close

Step 5: Configure NFS server and finish TFTP config

A project log for Orange Pi Zero native network boot

Tutorial describing steps to make Orange Pi Zero boot natively from network

andriymalyshenkoandriy.malyshenko 08/13/2021 at 08:140 Comments

Now we need to prepare Pi specific files. There are number of ways doing this. Simplest one is to take files from SD card that we have prepared earlier. But first let's prepare last server in the setup - NFS server. This will provide root filesystem fro our Pi over network and preferably should have fast storage and wide connection to PI. But of course that is only optional.

In my case it is ubuntu machine under 192.168.1.3 IP, but it can be combined with TFTP and/or DHCP server as well.

$ sudo apt install nfs-kernel-server -y
$ sudo mkdir -p /srv/exports/01-02-42-94-b4-99-28
$ sudo nano /etc/exports

Contents of  exports config:

/srv/exports 192.168.1.0/24(rw,no_root_squash,async,insecure,no_subtree_check,crossmnt)

You can play around with settings, above those working best for me. Key issue you might address is that all machines in the network are allowed to connect to that NFS export without authorisation. This is okay for me, but you might want to have different setup, perhaps not as much trusted.

Now lets update service

$ sudo exportfs -rv

Now we're back at dev machine, where we can take snapshot from SD card

$ mkdir -p ~/pi-boot/mnt/{sdc,nfs} && cd ~/pi-boot
$ sudo mount /dev/sdc1 mnt/sdc
$ sudo mount 192.168.1.3:/srv/exports mnt/nfs
$ ls -la mnt/nfs/
total 12
drwxr-xr-x 3 root      root      4096 sie 13 08:49 .
drwxrwxr-x 4 dronische dronische 4096 sie 13 08:52 ..
drwxr-xr-x 2 root      root      4096 sie 13 08:49 01-02-42-94-b4-99-28

$ sudo rsync -va mnt/sdc/ mnt/nfs/01-02-42-94-b4-99-28

sent 987,891,328 bytes  received 708,418 bytes  6,009,724.90 bytes/sec
total size is 985,196,807  speedup is 1.00

Few small fixes that we need to apply on the root filesystem

# we no longer need this, it is stored on TFTP now
$ sudo rm -rf mnt/nfs/01-02-42-94-b4-99-28/boot

# edit fstab
$ sudo nano mnt/nfs/01-02-42-94-b4-99-28/etc/fstab

Need to comment first line, since we no longer have SD-card

# UUID=3dbf7aef-312c-456c-a992-e6bde7857d3f / ext4 defaults,noatime,commit=600,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults,nosuid 0 0

  Next we need to prepare boot artifacts on TFTP server

$ cd ~/pi-boot/mnt/sdc/boot
$ scp -r uInitrd-5.10.43-sunxi vmlinuz-5.10.43-sunxi dtb-5.10.43-sunxi 192.168.1.2:/srv/tftp

Note that names above are those specified in boot config file  created at previous step.


Last thing is to restore permissions on the TFTP share

$ sudo chown root:root /srv/tftp -R

New let's try to boot Pi

Autoboot in 1 seconds
MMC: no card present

Device 0: unknown device
ethernet@1c30000 Waiting for PHY auto negotiation to complete. done
BOOTP broadcast 1
DHCP client bound to address 192.168.1.49 (9 ms)
Using ethernet@1c30000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.49
Filename '/pxelinux.0'.
Load address: 0x42000000
Loading: *
TFTP error: 'File not found' (1)
Not retrying...
missing environment variable: pxeuuid
Retrieving file: /pxelinux.cfg/01-02-42-94-b4-99-28
Using ethernet@1c30000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.49
Filename '/pxelinux.cfg/01-02-42-94-b4-99-28'.
Load address: 0x43200000
Loading: #
         63.5 KiB/s
done
Bytes transferred = 195 (c3 hex)
Config file found
1:      linux
Retrieving file: /uInitrd-5.10.43-sunxi
Using ethernet@1c30000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.49
Filename '/uInitrd-5.10.43-sunxi'.
Load address: 0x43300000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ######
         961.9 KiB/s
done
Bytes transferred = 11527719 (afe627 hex)
Retrieving file: /vmlinuz-5.10.43-sunxi
Using ethernet@1c30000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.49
Filename '/vmlinuz-5.10.43-sunxi'.
Load address: 0x42000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ########################
         1.6 MiB/s
done
Bytes transferred = 7975912 (79b3e8 hex)
append: root=/dev/nfs initrd=uInitrd-5.10.43-sunxi nfsroot=192.168.1.3:/srv/exports/01-02-42-94-b4-99-28 ip=dhcp rw
Retrieving file: /dtb-5.10.43-sunxi/sun8i-h2-plus-orangepi-zero.dtb
Using ethernet@1c30000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.49
Filename '/dtb-5.10.43-sunxi/sun8i-h2-plus-orangepi-zero.dtb'.
Load address: 0x43000000
Loading: ###
         1.4 MiB/s
done
Bytes transferred = 7975912 (79b3e8 hex)
append: root=/dev/nfs initrd=uInitrd-5.10.43-sunxi nfsroot=192.168.1.3:/srv/exports/01-02-42-94-b4-99-28 ip=dhcp rw
Retrieving file: /dtb-5.10.43-sunxi/sun8i-h2-plus-orangepi-zero.dtb
Using ethernet@1c30000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.49
Filename '/dtb-5.10.43-sunxi/sun8i-h2-plus-orangepi-zero.dtb'.
Load address: 0x43000000
Loading: ###
     done
Bytes transferred = 32623 (7f6f hex)
## Loading init Ramdisk from Legacy Image at 43300000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    11527655 Bytes = 11 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
EHCI failed to shut down host controller.
   Loading Ramdisk to 49501000, end 49fff5e7 ... OK
   Loading Device Tree to 494f6000, end 49500f6e ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0

[...]

Welcome to Armbian 21.05.8 Focal!

[   12.117995] systemd[1]: Set hostname to <orangepizero>.
[   14.946538] random: systemd: uninitialized urandom read (16 bytes read)
[   14.963400] systemd[1]: Created slice system-modprobe.slice.
[  OK  ] Created slice system-modprobe.slice.
[   14.985435] random: systemd: uninitialized urandom read (16 bytes read)
[   14.995698] systemd[1]: Created slice system-serial\x2dgetty.slice.
[  OK  ] Created slice system-serial\x2dgetty.slice.
[   15.017352] random: systemd: uninitialized urandom read (16 bytes read)
[   15.026947] systemd[1]: Created slice User and Session Slice.
[  OK  ] Created slice User and Session Slice.
[   15.049462] systemd[1]: Condition check resulted in Dispatch Password Requests to Console Directory Watch when bootsplash is active being skipped.
[   15.063627] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Started Forward Password R…uests to Wall Directory Watch.
[   15.091474] systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point.
[  OK  ] Set up automount Arbitrary…s File System Automount Point.
[   15.117752] systemd[1]: Reached target Local Encrypted Volumes.
[  OK  ] Reached target Local Encrypted Volumes.
[   15.142265] systemd[1]: Reached target Slices.
[  OK  ] Reached target Slices.
[   15.161495] systemd[1]: Reached target Swap.
[  OK  ] Reached target Swap.
[   15.181396] systemd[1]: Reached target System Time Set.
[  OK  ] Reached target System Time Set.
[   15.250879] systemd[1]: Listening on RPCbind Server Activation Socket.
[  OK  ] Listening on RPCbind Server Activation Socket.
[   15.277568] systemd[1]: Listening on Syslog Socket.
[  OK  ] Listening on Syslog Socket.
[   15.298325] systemd[1]: Listening on initctl Compatibility Named Pipe.
[  OK  ] Listening on initctl Compatibility Named Pipe.
[   15.325530] systemd[1]: Listening on Journal Audit Socket.
[  OK  ] Listening on Journal Audit Socket.
[   15.350716] systemd[1]: Listening on Journal Socket (/dev/log).
[  OK  ] Listening on Journal Socket (/dev/log).
[   15.374799] systemd[1]: Listening on Journal Socket.
[  OK  ] Listening on Journal Socket.
[   15.396215] systemd[1]: Listening on udev Control Socket.
[  OK  ] Listening on udev Control Socket.
[   15.418365] systemd[1]: Listening on udev Kernel Socket.
[  OK  ] Listening on udev Kernel Socket.
[   15.442714] systemd[1]: Condition check resulted in Huge Pages File System being skipped.
[   15.462566] systemd[1]: Mounting POSIX Message Queue File System...
         Mounting POSIX Message Queue File System...
[   15.497497] systemd[1]: Mounting RPC Pipe File System...
         Mounting RPC Pipe File System...
[   15.532004] systemd[1]: Mounting Kernel Debug File System...
         Mounting Kernel Debug File System...
[   15.566765] systemd[1]: Mounting Kernel Trace File System...
         Mounting Kernel Trace File System...
[   15.609371] systemd[1]: Starting Restore / save the current clock...
         Starting Restore / save the current clock...
[   15.648788] systemd[1]: Starting Set the console keyboard layout...
         Starting Set the console keyboard layout...
[   15.689001] systemd[1]: Starting Create list of static device nodes for the current kernel...
         Starting Create list of st…odes for the current kernel...
[   15.717760] systemd[1]: Condition check resulted in Load Kernel Module drm being skipped.
[   15.740482] systemd[1]: Started Nameserver information manager.
[  OK  ] Started Nameserver information manager.
[   15.764910] systemd[1]: Reached target Network (Pre).
[  OK  ] Reached target Network (Pre).
[   15.802048] systemd[1]: Condition check resulted in Set Up Additional Binary Formats being skipped.
[   15.841493] systemd[1]: Starting Load Kernel Modules...
         Starting Load Kernel Modules...
[   15.876037] systemd[1]: Starting Remount Root and Kernel File Systems...
         Starting Remount Root and Kernel File Systems...
[   15.916208] systemd[1]: Starting udev Coldplug all Devices...
         Starting udev Coldplug all Devices...
[   15.955215] systemd[1]: Mounted POSIX Message Queue File System.
[  OK  ] Mounted POSIX Message Queue File System.
[   15.979677] systemd[1]: Mounted RPC Pipe File System.
[  OK  ] Mounted RPC Pipe File System.
[   16.003642] systemd[1]: Mounted Kernel Debug File System.
[  OK  ] Mounted Kernel Debug File System.
[   16.027692] systemd[1]: Mounted Kernel Trace File System.
[  OK  ] Mounted Kernel Trace File System.
[   16.057958] systemd[1]: Finished Restore / save the current clock.
[  OK  ] Finished Restore / save the current clock.
[   16.092434] systemd[1]: Finished Create list of static device nodes for the current kernel.
[  OK  ] Finished Create list of st… nodes for the current kernel.
[   16.136849] systemd[1]: Finished Remount Root and Kernel File Systems.
[  OK  ] Finished Remount Root and Kernel File Systems.
[   16.191826] systemd[1]: Condition check resulted in Rebuild Hardware Database being skipped.
[   16.201833] systemd[1]: Condition check resulted in Platform Persistent Storage Archival being skipped.
[   16.226127] systemd[1]: Starting Load/Save Random Seed...
         Starting Load/Save Random Seed...
[   16.275198] systemd[1]: Starting Create System Users...
         Starting Create System Users...
[   16.421991] g_serial gadget: Gadget Serial v2.4
[   16.426683] g_serial gadget: g_serial ready
[   16.445720] systemd[1]: Finished Load Kernel Modules.
[  OK  ] Finished Load Kernel Modules.
[   16.480504] systemd[1]: Mounting FUSE Control File System...
         Mounting FUSE Control File System...
[   16.517396] systemd[1]: Mounting Kernel Configuration File System...
         Mounting Kernel Configuration File System...
[   16.557111] systemd[1]: Starting Apply Kernel Variables...
         Starting Apply Kernel Variables...
[   16.591086] systemd[1]: Finished Create System Users.
[  OK  ] Finished Create System Users.
[   16.616939] systemd[1]: Mounted FUSE Control File System.
[  OK  ] Mounted FUSE Control File System.
[   16.639662] systemd[1]: Mounted Kernel Configuration File System.
[  OK  ] Mounted Kernel Configuration File System.
[   16.675480] systemd[1]: Starting Create Static Device Nodes in /dev...
         Starting Create Static Device Nodes in /dev...
[  OK  ] Finished Set the console keyboard layout.
[  OK  ] Finished Apply Kernel Variables.
[  OK  ] Finished udev Coldplug all Devices.
         Starting Helper to synchronize boot up for ifupdown...
[  OK  ] Finished Create Static Device Nodes in /dev.
[  OK  ] Reached target Local File Systems (Pre).
         Mounting /tmp...
         Starting udev Kernel Device Manager...
[  OK  ] Finished Helper to synchronize boot up for ifupdown.
[  OK  ] Mounted /tmp.
[  OK  ] Reached target Local File Systems.
         Starting Armbian ZRAM config...
         Starting Set console font and keymap...
         Starting Raise network interfaces...
         Starting Preprocess NFS configuration...
[  OK  ] Finished Set console font and keymap.
[  OK  ] Finished Preprocess NFS configuration.
[  OK  ] Reached target NFS client services.
[  OK  ] Finished Load/Save Random Seed.
[  OK  ] Started udev Kernel Device Manager.
[  OK  ] Found device /dev/ttyGS0.
[   18.873471] thermal thermal_zone0: binding zone cpu_thermal with cdev thermal-cpufreq-0 failed:-22
[  OK  ] Found device /dev/ttyS0.
[  OK  ] Finished Raise network interfaces.
[  OK  ] Finished Armbian ZRAM config.
         Starting Armbian memory supported logging...
[  OK  ] Finished Armbian memory supported logging.
         Starting Journal Service...
[  OK  ] Started Journal Service.
         Starting Flush Journal to Persistent Storage...
[  OK  ] Finished Flush Journal to Persistent Storage.
         Starting Create Volatile Files and Directories...
[  OK  ] Finished Create Volatile Files and Directories.
[  OK  ] Started Entropy daemon using the HAVEGE algorithm.
         Starting RPC bind portmap service...
         Starting Network Name Resolution...
         Starting Update UTMP about System Boot/Shutdown...
[  OK  ] Finished Update UTMP about System Boot/Shutdown.
[  OK  ] Reached target System Initialization.
[  OK  ] Started resolvconf-pull-resolved.path.
[  OK  ] Started Daily Cleanup of Temporary Directories.
[  OK  ] Reached target Paths.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Sockets.
         Starting Armbian hardware monitoring...
         Starting Armbian hardware optimization...
[  OK  ] Started RPC bind portmap service.
[  OK  ] Reached target Remote File Systems (Pre).
[  OK  ] Reached target Remote File Systems.
[  OK  ] Reached target RPC Port Mapper.
[  OK  ] Finished Armbian hardware monitoring.
[  OK  ] Finished Armbian hardware optimization.
[  OK  ] Reached target Basic System.
[  OK  ] Started Regular background program processing daemon.
[  OK  ] Started D-Bus System Message Bus.
         Starting Network Manager...
[  OK  ] Started Save initial kernel messages after boot.
         Starting Remove Stale Onli…t4 Metadata Check Snapshots...
         Starting LSB: Load kernel …d to enable cpufreq scaling...
         Starting Dispatcher daemon for systemd-networkd...
[  OK  ] Started Add entropy to /de…random 's pool a hardware RNG.
         Starting System Logging Service...
         Starting Self Monitoring a…g Technology (SMART) Daemon...
         Starting Resets System Activity Data Collector...
         Starting Login Service...
         Starting WPA supplicant...
[  OK  ] Finished Resets System Activity Data Collector.
[  OK  ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots.
[  OK  ] Started Network Name Resolution.
[  OK  ] Reached target Host and Network Name Lookups.
         Starting resolvconf-pull-resolved.service...
[  OK  ] Started System Logging Service.
[  OK  ] Started Self Monitoring an…ing Technology (SMART) Daemon.
[  OK  ] Started Login Service.
[  OK  ] Started WPA supplicant.
[  OK  ] Started LSB: Load kernel m…ded to enable cpufreq scaling.
         Starting LSB: set CPUFreq kernel parameters...
[  OK  ] Finished resolvconf-pull-resolved.service.
[  OK  ] Started LSB: set CPUFreq kernel parameters.
         Starting LSB: Set sysfs va i
orangepizero login:

Armbian 21.05.8 Focal ttyS0 

  ___  ____  _   _____              
 / _ \|  _ \(_) |__  /___ _ __ ___  
| | | | |_) | |   / // _ \ '__/ _ \ 
| |_| |  __/| |  / /|  __/ | | (_) |
 \___/|_|   |_| /____\___|_|  \___/ 
                                    
Welcome to Armbian 21.05.8 Focal with Linux 5.10.43-sunxi

System load:   2%               Up time:       4 min
Memory usage:  29% of 238M      IP:            192.168.1.49
CPU temp:      51°C             Usage of /:    60% of 8.8G      

[ General system configuration (beta): armbian-config ]

Last login: Wed Aug 11 22:19:50 UTC 2021 from 192.168.1.110 on pts/0

 
Logon successful!

Discussions