Chinaunix首页 | 论坛 | 博客
  • 博客访问: 420288
  • 博文数量: 117
  • 博客积分: 3003
  • 博客等级: 中校
  • 技术积分: 1221
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-16 14:11
文章分类

全部博文(117)

文章存档

2011年(7)

2010年(110)

我的朋友

分类: LINUX

2010-09-17 17:31:25

简要过程如下:

1. 安装

# apt-get install xinetd tftpd

2. 确保/etc/services中的tftp存在,且没有被注释掉

tftp            69/tcp
tftp            69/udp

3. 在/etc/xinetd.d下创建名为tftp的文件,

内容如下:

# default: off
# description: The tftp server serves files using the Trivial File Transfer \
#    Protocol.  The tftp protocol is often used to boot diskless \
#    workstations, download configuration files to network-aware printers, \
#    and to start the installation process for some operating systems.
service tftp
{
    socket_type     = dgram
    protocol        = udp
    wait            = yes
    user            = root
    server          = /usr/sbin/in.tftpd
    server_args     = -s /tftpboot
    disable         = yes
}

4. 重启xinetd

# /etc/init.d/xinetd restart

5. 测试tftp服务器

# echo "Hello, embedded world" > /tftpboot/hello.txt"
# tftp localhost
tftp> get hello.txt
Received 23 bytes in 0.1 seconds
tftp> quit 

6. 注意事项

如果从tftp服务器下载失败,

要确保服务器的根目录有可执行的权限。

$ chmod -R 777 tftp

 

使用中发现能正常下载文件,

$ tftp 192.168.1.222
tftp> get zImage
Received 1692890 bytes in 0.2 seconds

可是上传文件不成功,

提示错误:

tftp> put dic.txt
Error code 2: Access violation

求助于google, 得下面一段说明,问题解决。

The tftp man page says:

Because there is no user-login or validation within the TFTP
protocol, the remote site will probably have some sort of
file-access restrictions in place. The exact methods are
specific to each site and therefore dif ficult to document here.

So apparently the site you're trying to get the file from has some
kind of access restrictions in place. Take a look at the tftpd man
page on the remote host. The linux tftpd manual says, in part, "Due to
the lack of authentication information, tftpd will allow only publicly
readable files to be accessed. Files may be written only if they
already exist and are publicly writable."

上面主要意思就是: tftp服务器缺少必要的身份验证,

所以默认只允许下载文件,要上传文件,必须是服务器中已存在同名的文件,

且该文件权限允许被覆盖。

 

所以首先在服务中创建一个与要上传的文件同名的文件,并更改权限。

$ touch dic.txt

$ chmod 777 dic.txt

重新上传,成功。

tftp> put dic.txt
Sent 13770 bytes in 0.0 seconds


虽然我是用cramfs,但把tmp 作为了ramfs ,可以用tftp接收文件,这下省的每次得都重新编译文件系统

tftp 在linux下的用法感觉没有 在u-boot下面好用

下面是busybox里面的解释

Usage: tftp [OPTION]... HOST [PORT]

Transfer a file from/to tftp server using "octet" mode

Options:
        -l FILE Local FILE
        -r FILE Remote FILE
        -g      Get file
        -p      Put file
        -b SIZE Transfer blocks of SIZE octets

进入可以读写的tmp目录,执行

/tmp # tftp -g -r uimage 192.168.0.1

就可以收到了uimage文件

说不定还能帮我传yaffs文件哦???


阅读(1420) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~