nfs与tftp配置

nfs服务器安装过程
#apt-get install nfs-kernel-server
#apt-get install nfs-common
#sudo vim /etc/exports
在后面加上你的共享目录即可。我的配置文件如下:
这个名字叫出口它确实nfs的配置文件(表示本系统向外输出的文件这样翻译有意思吧)
lmz@lmz-desktop:~/arm9$ cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync) hostname2(ro,sync)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt)
# /srv/nfs4/homes gss/krb5i(rw,sync)
#
/home/dw/workdir/filesys *(rw,sync,no_root_squash)
# * : 表示所有主机  
# rw :设置输出的共享目录可读写
# sync:设置NFS服务器同步写磁盘,这样不会轻易丢失数据,建议所有的NFS共享目录都使用该选项
# no_root_squash :登入 NFS 主机使用分享目录的使用者,如果是 root 的话,那么对于这个分享的目录来说,他就具有 root 的权限!这个项目『极不安全』,不建议使用!
也可以使用这样的权限 root_squash:在登入 NFS 主机使用分享之目录的使用者如果是 root 时,那么这个使用者的权限将被压缩成为匿名使用者。  
 
#sudo exportfs -r  
然后重启nfs服务,执行下面命令
#很可惜这些脚本在运行后并没有得到的相应服务名称与他们不一致 rpc.mountd 就是他们其中的一个名字
#不过可以看的出来nfs系统比tftp在系统中占用的资源要多(就是说不看程序的运行,就看配置,哈哈)
#sudo /etc/init.d/portmap restart
#sudo /etc/init.d/nfs-kernel-server restart
 
对它的使用如下
mount -t nfs 192.168.1.130:/home/dw/workdir/filesys /mnt/flash/net -o nolock
-t 指定文件类型。#将后面的设备(192.168.1.130:/home/dw/workdir/filesys)以nfs的方式挂接到(/mnt/flash/net)处
-o 设备的挂接方式 ro:采用只读方式挂接设备 rw:采用读写方式挂接设备 iocharset:指定访问文件系统所用字符集  
nolock : 禁用文件锁(有人说nfs是默认带锁的,会使文件操作不了,因此要把它禁掉)

 

TFTP 是简单文件传输协议是ftp的精简板,不提供目录浏览功能。
xinetd 是用来管理不经常使用的服务例tftp 当然你也可以不让他管理自己写点东西让他启动就可以了。

$ dpkg -l tftpd-hpa
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  tftpd-hpa      0.42-1ubuntu2  HPA's tftp server

安裝 tftpd-hpa 與 xinetd

在Ubuntu下,tftp是不能單獨運作的,需要xinetd這個網路管理的背景程式之支援。於是我們同時安裝這兩個套件。

$ sudo apt-get install tftpd-hpa xinetd

xinetd.conf 設定

安裝完tftp與xinetd後,需要在xinetd的設定檔/etc/xinetd.conf中寫入相關設定。

$cat /etc/xinetd.conf
# Simple configuration file for xinetd
# Some defaults, and include /etc/xinetd.d/
defaults
{
# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
}
includedir /etc/xinetd.d

雖然我們可以將設定內容寫入此處,但還有更好的設定檔設定方法。xinetd.conf引入專門存放設定檔的資料夾includedir /etc/xinetd.d。因此更結構化的設定檔配置就是自己建立一個tftp設定檔於此資料夾內。

$sudo vim /etc/xinetd.d/tftp

存入

service tftp
{
       socket_type     = dgram    #表示数据包
       protocol        = udp   
       wait            = yes
       user            = root
       server          = /usr/sbin/in.tftpd
       server_args     = -s /var/lib/tftpboot
       disable         = no
       per_source      = 11
       cps             = 100 2    #链接超过100的时候 等待2秒 这个情况其实是不会发生的
       flags           = IPv4
}

由於背景網路程式已經由inetd更換成xinetd,可將/etc/inetd.conf中關於tftp的部份註解以避免混淆。

#:BOOT: TFTP service is provided primarily for booting.  Most sites
#       run this only on machines acting as "boot servers."
#tftp           dgram   udp     wait    nobody  /usr/sbin/tcpd  /usr/sbin/in.tftpd /srv/tftp

完成以上設定後,還需要讓xinetd讀入新參數並重新啟動。

/etc/init.d/xinetd reload
/etc/init.d/xinetd restart

如下命令可以查看服务 当然包括查看tftp了
chkconfig -list

#这个命令是管理软件包的 类是于上层的apt-get
dpkg -l tftpd-hpa

检查一下tftp是否真的在运作

#查看运行的服务,很可惜他被xinetd.d服务管理,有可能没有这些数据也有可能是可以用的(我是指开发板的启动过程)
$netstat -anp | grep tftp    
udp        0      0 0.0.0.0:69              0.0.0.0:*                          5249/in.tftpd       
unix  2      [ ]         DGRAM                    17654    5249/in.tftpd

#也可以在进程中查看
ps -aux | grep tftp

测试可用性

 

tftp 192.168.1.*

get filename

q

在本文件夹下得到filename

转载于:https://www.cnblogs.com/shang-qd/archive/2012/06/11/2544572.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值