服务端:ubuntu 客户端:ARM开发板
安装失败过程:
先是参考了 Linux——Linux系统编程之基于TFTP实现服务器与开发板间的文件传输实战总结 先后安装了xinetd tftp tftpd ,也新建了/etc/xinetd.d/tftp
重启服务后,在本机使用tffp测试传输文件,一直显示超时,关闭防火墙等措施也没用。
尝试卸载 sudo apt-get remove xinetd tftp tftpd , 再重新安装时报错:
... Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] y Setting up tftpd-hpa (5.2+20150808-1ubuntu4) ... tftpd user (tftp) already exists, doing nothing. tftpd-hpa directory (/srv/tftp) already exists, doing nothing. Job for tftpd-hpa.service failed because the control process exited with error code. See "systemctl status tftpd-hpa.service" and "journalctl -xe" for details. invoke-rc.d: initscript tftpd-hpa, action "start" failed. * tftpd-hpa.service - LSB: HPA's tftp server Loaded: loaded (/etc/init.d/tftpd-hpa; generated) Active: failed (Result: exit-code) since Tue 2021-11-23 18:08:20 CST; 3ms ago Docs: man:systemd-sysv-generator(8) Process: 28678 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=71) Nov 23 18:08:20 tianyu systemd[1]: Starting LSB: HPA's tftp server... Nov 23 18:08:20 tianyu tftpd-hpa[28678]: * Starting HPA's tftpd in.tftpd Nov 23 18:08:20 tianyu systemd[1]: tftpd-hpa.service: Control process exited, code=exited, status=71/OSERR Nov 23 18:08:20 tianyu systemd[1]: tftpd-hpa.service: Failed with result 'exit-code'. Nov 23 18:08:20 tianyu systemd[1]: Failed to start LSB: HPA's tftp server. dpkg: error processing package tftpd-hpa (--configure): installed tftpd-hpa package post-installation script subprocess returned error exit status 1 Errors were encountered while processing: tftpd-hpa E: Sub-process /usr/bin/dpkg returned an error code (1)
参考该博客:E: Sub-process /usr/bin/dpkg returned an error code (1)解决办法 解决问题
可知,要么安装tftp-hpa 和tftpd-hpa(tftp的增强版), 或者安装xinetd , tftp ,tftpd
如果同时安装了并启动了tftp-hpa 和xinetd,会导致tftp-hpa的端口被占用,导致超时。如何解决:修改xinetd的配置文件,关闭服务。