I want to be a complete engineer - technical genius and sensitive humanist all in one!

Monday, September 8, 2008

ubuntu搭建tftp和nfs

安装配置tftp:

1. 首先安装tftp和tftpd,前者是客户端,后者是服务器。因为tftp是要inetd来控制的,而ubuntu类的系统,默认是没有安装inetd的,安装一下。(我第一次失败了就是因为没有安装正确的inetd)
#apt-get install tftp tftpd
#apt-get install netkit-inetd

2、在/目录下建一个tftpboot, 把属性改成777。

#cd /
#mkdir tftpboot
#chmod 777 tftpboot

3、修改/etc/inetd.conf
#emacs /etc/inetd.conf
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot
#:INTERNAL: Internal services
#echo stream tcp nowait root internal
#echo dgram udp wait root internal
#chargen stream tcp nowait root internal
#chargen dgram udp wait root internal
#discard stream tcp nowait root internal
#discard dgram udp wait root internal
#daytime stream tcp nowait root internal
#daytime dgram udp wait root internal
#time stream tcp nowait root internal
#time dgram udp wait root internal
#tftp dgram udp wait nobody /usr/sbin/tcpd/usr/sbin/in.tftpd/tftpboot

4、重新加载inetd进程
#/etc/init.d/inetd reload

5、测试tftpd服务是否成功
tftp localhost
tftp> put mydoc.tar.gz
tftp> put test.log
tftp> get test.log
tftp> get mydoc.tar.gz
tftp>

上述表明在主机上测试tftp成功,在DM6446板子上,以root登录,使用busybox附带的tftp客户端上传/下载文件:
root@DVS6446:/tftp -r thttpd.conf -g 192.168.1.19

当然,安装tftp也可以这样:

首先介要安装的三个软件包:

1.xinetd:xinetd是一个守护进程,用于处理对各种服务的请求,当xinetd监控的服务请求出现时,xinetd会使用/etc /xinetd.conf文件 读取/etc/xinetd.d目录中的配置文件,然后,根据所请求服务的xinetd.conf文件内容,启动相应的程序.

2.tftpd :服务端

3.tftp:客户端

第一步:安装相关软件包

sudo apt-get install tftpd (服务端)
sudo apt-get install tftp (客户端)
sudo apt-get install xinetd

第二步:建立配置文件

#cd /etc/xinetd.d/

#emacs tftp

输入下列配置信息:

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

存盘退出

3、建立tftp服务文件目录
mkdir /tftpboot
4、重新启动服务
/etc/init.d/xinetd restart


安装配置nfs:
主机host:
OS:ubuntu 8.04 kernel 2.6.24-17
IP:192.168.1.19
netmask:255.255.255.0

板子:
OS:MV4.0 kernel2.6.10
IP:192.168.1.24
netmask:255.255.255.0

busybox v1.1.0

以下为搭建NFS全过程:

1. Install NFS software
$ sudo apt-get install nfs-common
$ sudo apt-get install nfs-kernel-server

2.在/建立共享项目nfsboot
#mkdir nfsboot
#chmod 777 -R nfsboot/
保证使用者都能够读、写、执行

3.编辑/etc/exports
#emacs /etc/exports
/nfsboot 192.168.1.*(rw,sync,no_root_squash)
其中/nfsboot表示主机要共享的目录,192.168.1.*为主机所允许访问的机器名,即处于192.168.1.*IP段的机器都可以访问共享目录。

4.#exportfs -r
更新exportfs

5.然后重启nfs服务,执行下面命令
#/etc/init.d/portmap restart
#/etc/init.d/nfs-kernel-server restart

成功启动后,执行
#showmount -e
显示如下:
/nfsboot 192.168.1.*

6.本机测试
在主机上测试一下nfs服务,具体过程如下:
#mount -t nfs 192.168.1.19:/nfsboot /mnt
即把主机上/nfsboot目录mount到主机/mnt目录,正常,可以顺利mount成功。

7.在板子(客户端)进入shell,以root登录,设置板子的IP地址和子网掩码跟主机在一个地址段
#ifconfig eth0 address 192.168.1.24 netmask 255.255.255.0

8.然后相互ping,均能够ping通。
在板子上mount共享目录,将共享目录mount到/root
#mount -t nfs 192.168.1.19:/nfsboot /root
等待一段时间之后,报错如下:
root@DVS6446:/# mount -t nfs 192.168.1.19:/nfsboot /mnt
mount: RPC: Timed out
mount: nfsmount failed: Bad file descriptor
mount: Mounting 192.168.1.19:/nfsboot on /mnt failed: No such file or directory

以上描述的就是开发环境的设置和出错信息,搞了大半天,也参阅了一些帖子,问题始终没有能够解决.最后查阅网络上有关文章,说有可能是防火墙搞的鬼,仔细 检查了下,发现我的unbutu8.04 已经安装了Firestarter 1.0.3,而且处于运行状态,马上关闭之,然后重启网络,再mount即可。

No comments:

Labels

Followers