Recently I decide to jump into the pool of using diskless Ubuntu. Basically the client computer downloads the necessary files from the Ubuntu server every time during the boot. To keep things simple and easy, Ubuntu does that by using TFTP. So the first step is to set up a TFTP server on the server. For those who haven’t heard of TFTP, it is similar to FTP, except that it has no security feature, and the function is extremely limited. Anyway, here is how to set up a TFTP server on Ubuntu 11.10:
Installing TFTP sounds easy. However, I’ve heard that many people experienced many issues during the installation, such as Error code 2: Access violation issue. That’s why I create this tutorial. If you follow exact the same steps, you will not experience any problem.
First, let’s install all the necessary packages:
sudo apt-get install xinetd tftpd tftp -y
Next, we need to create a configuration file:
sudo nano /etc/xinetd.d/tftp
Put the following content into the file.
service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = var/lib/tftpboot -s
disable = no
}
In the server_args, I have var/lib/tftpboot, which represents the location of the tftp root, i.e., /var/lib/tftpboot. Notice that I skip the root /.
Now let’s change the ownership of the directory:
sudo mkdir /var/lib/tftpboot
sudo chown -R nobody:nobody /var/lib/tftpboot
sudo chmod -R 777 /var/lib/tftpboot
and start the TFTP service:
sudo service xinetd stop
sudo service xinetd start
Verify the TFTP is running correctly or not:
netstat -na | grep LIST | grep 69
You should see something like this:
tcp 0 0 0.0.0.0:69 0.0.0.0:* LISTEN
Test: Upload a file to TFTP Server
Now let’s test the TFTP server by logging into the server first:
tftp localhost
and upload a file:
tftp> put myfile.jpg
Sent 56733279 bytes in 5.7 seconds
Quit:
q
Make sure that file has been uploaded:
ls -l /var/lib/tftpboot
Test: Download a file from TFTP Server
Now, let’s go to a different directory and download the file we just upload.
cd some_other_directory
and log in to the tftp server again:
tftp localhost
and get the file:
tftp> get myfile.jpg
Received 56733279 bytes in 5.7 seconds
You are done.
Troubleshooting (e.g., Error code 2: Access violation)
If you see a message like: Error code 2: Access violation
Make sure that you:
– Follow the exact procedure in this tutorial
– Make sure that the tftp is started with -s flag.
– Check the permission of the directory, i.e., 777
– After you’ve made any changes to the TFTP configuration, make sure that you stop and start the inet service again.
– Don’t forget to quit tftp before retrying the command.
That’s it!
Enjoy TFTP.
–Derrick
Our sponsors: