Setting Up a TFTP Server

Purpose

The purpose of this page is to contain information on how to setup a TFTP server on Linux. This is useful for downloading Linux kernel images to the target board during development.

Using Ubuntu

There are multiple options for TFTP servers in Ubuntu, below are two possibilities atftp and tftpd-hpa.

Using atftp in Ubuntu 8.04 LTS

To setup atftp on Ubuntu 8.04 LTS, you can follow these steps:

Install atftp Server in Ubuntu

host $ sudo aptitude install atftpd
This will complete the installation

Using atftpd

By default atftpd server starts using inetd so we need to tell atftpd to run as a server directly, not through inetd. Edit /etc/default/atftpd file using the following command
host $ sudo gedit /etc/default/atftpd
Change the following line
USE_INETD=true
to
USE_INETD=false
also change the directory at the end of the file to /tftpboot
save and exit the file
Now you need to run the following command
host $ sudo invoke-rc.d atftpd start

Configuring atftpd

First you need to create a directory where you can place the files
host $ sudo mkdir /tftpboot
host $ sudo chmod -R 777 /tftpboot
host $ sudo chown -R nobody /tftpboot
host $ sudo /etc/init.d/atftpd restart
And  to use again type>> 
      host $ sudo invoke-rc.d atftpd start  and  
       >> start working on ...your tftp files will be in /tftpboot ..
Example : 
sto tftp://(your ip)/your_file 

Using tftpd-hpa in Ubuntu

This was verified in Ubuntu 9.04 but likely applies to other releases as well.

Install tftpd-hpa

Installation is an easy one line command:
host $ sudo apt-get install tftpd-hpa

Configure tftpd-hpa for Daemon Operation

Configure the newly installed TFTP to run as a daemon by editing the /etc/default/tftpd-hpa file and replacing RUN_DAEMON="no" with RUN_DAEMON="yes", note that this file also defines where your TFTP server is serving from, the default location is /var/lib/tftpboot but may be changed in this file if desired:
host $ gksudo gedit /etc/default/tftpd-hpa

Start the TFTP service

Now start the newly configured TFTP service with this command:
host $ sudo /etc/init.d/tftpd-hpa start
[Ubuntu 10.04] use
host $ sudo service tftpd-hpa start


Using RedHat Enterprise Linux v4 (RHEL4)

You can check to see if a TFTP server is set up with the following command:
host $ rpm -q tftp-server
You should expect to see output similar to:
tftp-server-0.39-2
NOTE: Your version may be different than the one listed above. This is OK, the version above is just an example.
If it is not setup, you can follow these steps:
  1. Download a TFTP server for your Linux host. You can search the internet for "tftp-server". You can find the RPM package for download here
  2. Install the TFTP server package
    host $ rpm -ivh <tftp-server package name>

  3. Confirm that TFTP is installed
    host $ /sbin/chkconfig --list | grep tftp

  4. Turn on the TFTP server
    host $ /sbin/chkconfig tftp on

The default root location for TFTP files is /tftpboot.

No comments: