Abstract
在嵌入式開發(fā)中有宿主機(jī)和目標(biāo)機(jī)之分:宿主機(jī)是執(zhí)行編譯、鏈接嵌入式軟件的計(jì)算機(jī);目標(biāo)機(jī)是運(yùn)行嵌入式軟件的硬件平臺。
TFTP服務(wù)器作為工作于宿主機(jī)的軟件,主要提供對目標(biāo)機(jī)的主要映像文件的下載工作。
Solution
一.TFTP服務(wù)器的安裝
利用以下命令就可以看到TFTP服務(wù)器已啟動,則不用安裝
[root@localhost Server]# netstat -a |grep tftp
udp 0 0 *:tftp *:*
若沒有安裝,在Redhat Enterprise Linux 5的安裝光盤中有RPM安裝包,掛在光盤后進(jìn)入到文件夾,找到相應(yīng)的安裝包。
[root@localhost user]# cd /media/
[root@localhost media]# ls
RHEL_5.1 i386 DVD
[root@localhost media]# cd RHEL_5.1\ i386\ DVD/
[root@localhost RHEL_5.1 i386 DVD]# ls
[root@localhost RHEL_5.1 i386 DVD]# cd Server/
[root@localhost Server]# ls tftp*
tftp-0.42-3.1.i386.rpm tftp-server-0.42-3.1.i386.rpm
執(zhí)行安裝命令
[root@localhost Server]# rpm -ivh tftp-server-0.42-3.1.i386.rpm
warning: tftp-server-0.42-3.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
xinetd is needed by tftp-server-0.42-3.1.i386
提示需要安裝xinetd,找到安裝包并安裝
[root@localhost Server]# ls xinet*
xinetd-2.3.14-10.el5.i386.rpm
[root@localhost Server]# rpm -ivh xinetd-2.3.14-10.el5.i386.rpm
warning: xinetd-2.3.14-10.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:xinetd ########################################### [100%]
再執(zhí)行安裝TFTP命令
[root@localhost Server]# rpm -ivh tftp-server-0.42-3.1.i386.rpm
warning: tftp-server-0.42-3.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:tftp-server ########################################### [100%]
建立tftp的主工作目錄
[root@localhost Server]# mkdir /tftpboot
修改配置文件
[root@localhost Server]# vi /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
per_source = 11
cps = 100 2
flags = IPv4
}
重啟服務(wù)
[root@localhost Server]# /etc/init.d/xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]
查看是否啟動
[root@localhost Server]# netstat -a |grep tftp
udp 0 0 *:tftp *:*
二.NFS的安裝
NFS(Network File System,網(wǎng)絡(luò)文件系統(tǒng))是一種將遠(yuǎn)程主機(jī)上的分區(qū)(目錄)經(jīng)網(wǎng)絡(luò)掛在到本地的一種機(jī)制,通過對網(wǎng)絡(luò)文件系統(tǒng)的支持,用戶可以在本地系統(tǒng)上像操作本地分區(qū)一樣來對遠(yuǎn)程主機(jī)的共享分區(qū)(目錄)進(jìn)行操作,類似于windows的共享目錄。
查看安裝版本
[root@localhost Server]# rpm -q nfs-utils-1.0.9-24.el5.i386.rpm
package nfs-utils-1.0.9-24.el5.i386.rpm is not installed
沒有安裝,從光盤中找到相應(yīng)的RPM安裝包并安裝
[root@localhost Server]# rpm -ivh nfs-utils-1.0.9-24.el5.i386.rpm
warning: nfs-utils-1.0.9-24.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
package nfs-utils-1.0.9-24.el5 is already installed
NFS配置,加入允許其他計(jì)算機(jī)訪問的目錄和訪問權(quán)限
[root@localhost Server]# vi /etc/exports
例
/home 192.168.1.*(rw,sync,no_boot_squash)
1、home:允許其它計(jì)算機(jī)訪問的目錄
2、192.168.1.*:被允許訪問該目錄的客戶端IP地址
3、Rw:可讀可寫
4、no_boot_squash:表示客戶端root用戶對該目錄具備寫權(quán)限
啟動NFS服務(wù)器
[root@localhost Server]# /etc/init.d/nfs start
Starting NFS services: exportfs: /etc/exports:1: unknown keyword "no_boot_squash"
[FAILED]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
重啟NFS服務(wù)器
[root@localhost Server]# /etc/init.d/nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [FAILED]
Starting NFS services: exportfs: /etc/exports:1: unknown keyword "no_boot_squash"
[FAILED]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
最后,使用mount命令來掛載NFS服務(wù)器上的共享目錄
#mount -t nfs servername :/shared_dir /localdir
例如:
#mount -t nfs 10.168.1.100 :/home /mnt/nfs