Configure tftpd-hpa To Startup at Boot Time

I have a device that includes a Raspberry Pi 4 with the latest Raspberry Pi OS (Debian-based.) There is another device being tested that does a TFTP boot from the tftpd-hpa server running on the Pi. As long as I start the tftpd-hpa server manually after the Pi has booted everything works well.

systemd seems to be my nemesis. I have so far in my reading not discovered how to make the tftpd-hpa server start at boot time. I suspect it may be because the network may not be up and running when it tries to start.

I did try starting it in the same fashion as a previous question I had asked related to using a fixed Ethernet speed Howto Run Script At Boot Time To Set Ethernet Speed on Raspberry Pi 4 - Linux - nixCraft Linux/Unix Forum however, that does not work, the tftpd-hpa service never automatically starts.

I would appreciate any help on how to configure tftpd-hpa so that the service starts when the computer boots.

Thank you,

Tim

What does the following command says?

sudo systemctl is-enabled tftpd-hpa

Is it enabled? If not, enable it:

sudo systemctl enable tftpd-hpa

Then start it or check it the status:

systemctl status tftpd-hpa 

To start/stop/restart from the CLI:

sudo systemctl start tftpd-hpa 
sudo systemctl stop tftpd-hpa stop
sudo systemctl restart tftpd-hpa
sudo systemctl status tftpd-hpa 

Please note that tftp needs UDP port 69 open too. Are you using firewall? Reboot the box and see if it works. The following command gives more info if why the service is not loading at boot time:

sudo journalctl -u tftpd-hpa
tftpd-hpa.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install is-enabled tftpd-hpa
enabled

Then, when I enter:

systemctl status tftpd-hpa

It reports:

systemctl status tftpd-hpa

● tftpd-hpa.service - LSB: HPA's tftp server
   Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
   Active: failed (Result: exit-code) since Wed 2021-08-04 08:12:26 CDT; 5min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 708 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=66)

Aug 04 08:12:25 spilnx035 systemd[1]: Starting LSB: HPA's tftp server...
Aug 04 08:12:26 spilnx035 in.tftpd[721]: cannot resolve local IPv4 bind address: 0.0.0.0, Name or service not known
Aug 04 08:12:26 spilnx035 tftpd-hpa[708]: Starting HPA's tftpd: in.tftpd
Aug 04 08:12:26 spilnx035 systemd[1]: tftpd-hpa.service: Control process exited, code=exited, status=66/NOINPUT
Aug 04 08:12:26 spilnx035 systemd[1]: tftpd-hpa.service: Failed with result 'exit-code'.
Aug 04 08:12:26 spilnx035 systemd[1]: Failed to start LSB: HPA's tftp server.

However, if I then manually issue the commands:


sudo systemctl start tftp-hpa
sudo systemctl status tftpd-hpa
● tftpd-hpa.service - LSB: HPA's tftp server
   Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
   Active: active (running) since Wed 2021-08-04 08:22:09 CDT; 12s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 856 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/tftpd-hpa.service
           └─863 /usr/sbin/in.tftpd --listen --user tftp --address 0.0.0.0:69 --secure /tftpboot

Aug 04 08:22:09 spilnx035 systemd[1]: Starting LSB: HPA's tftp server...
Aug 04 08:22:09 spilnx035 tftpd-hpa[856]: Starting HPA's tftpd: in.tftpd.
Aug 04 08:22:09 spilnx035 systemd[1]: Started LSB: HPA's tftp server.

The server starts and the remote device can boot as desired. The tftpd-hpa server just will not start properly at boot time.

I do not understand why it cannot bind the address at boot time but it works properly when I issue the start command manually.

Tim

I have solved my problem and wanted to share what I’ve found.

In the /etc/default/tftpd-hpa configuration file I had been using:

TFTP_ADDRESS="0.0.0.0:69"

which works on several other desktop machines. I found this article which mentions a similar problem:
https://bugs.launchpad.net/ubuntu/+source/tftp-hpa/+bug/1342580

They indicate a failure at boot time can be avoided by using:

TFTP_ADDRESS=":69"

I have made this change and my tftpd-hpa server now starts and runs properly at boot time. Not specifying the catch-all address seems to let the service start even if the network interface is not ready which was one of my suspicions.

I would still like to here comments from someone more knowledgeable in these things.

Regards,

Tim

This kind of bug does exist. I had a similar problem with the Redis server on Debian. It will either listen to localhost or all 0.0.0.0 but not to localhost and 192.168.1.5. After that, I downloaded and installed lasted version from their site, and it worked. Debian is stable and may carry older apps. It works great, but sometimes weird bugs can be fixed using the latest version. Have you tried something like:

TFTP_ADDRESS="YOUR_SERVER_IP:69"

If RPi server IP is 192.168.1.100, then:

TFTP_ADDRESS="192.168.1.100:69"

Check for multiple tftp servers

I hope you don’t have multiple TFTP servers installed. That can cause problems too. A quick search shows various servers from different projects:

apt-cache search tftp | grep server

We can run dpkg to see installed tftp

dpkg --list | grep -i tftp

This might cause problem too.

1 Like

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki