Linux NFS 使用总结




 1.      服务器nfs的配置

2.      客户端nfs的配置

3.      使用nfs

3.1作为共享文件系统mount

3.2作为根文件系统mount

4.

nfsNetwork File System,基于RPC(Remote Procedure Call Protocol远程过程调用协议)实现。

1.服务器nfs的配置

1.1 startàsystem settingànfs添加共享路径、允许访问的客户端IP以及访问方式

添加之后则存到/etc/exports文件中,如:/home/rrhudp0216 128.0.0.*(rw,sync):网络上共享/home/rrhudp0216,允许128.0.0.*网段的所有IP可以读写访问该文件夹。

1.2 services nfs restart重启nfs

1.3 services portmap restart 重启portmap

1.4 services iptables stop 关闭防火墙

1.5 services iptables status 防火墙状态查看(确认防火墙被关闭)

2.客户端nfs的配置

2.1makemenuconfigàFile SystemsàNetwork File Systems中选上

2.2Network Application中选择portmap

   

3.使用nfs

3.1作为共享文件系统mount

系统起来之后:

#mkdir /var/nfs

#chmod 777 nfs

#mount –t nfs –o tcp 128.0.0.7:/home/rrhudp0216 /var/nfs

# ls

Makefile             fmod.c                rrh_init.c~

Makefile_bk          freqnum.h             rrh_init.h

Makefile~            frequency.h           rrh_init.o

3.2作为根文件系统mount

U-boot下设置U-boot环境变量:

U-boot->setenv bootargs ‘root=/dev/nfs rw nfsroot=128.0.0.7:/home/rrhudp0216,proto=tcp,nfsvers=3,nolock ip=128.0.0.28:128.0.0.7:128.0.0.1:255.255.0.0::eth0:off’

系统启动之后

NET: Registered protocol family 1

NET: Registered protocol family 17

IP-Config: Complete:

     device=eth0, addr=128.0.0.28, mask=255.255.0.0, gw=128.0.0.1,

    host=128.0.0.28, domain=, nis-domain=(none),

    bootserver=128.0.0.7, rootserver=128.0.0.7, rootpath=

VFS: Mounted root (nfs filesystem) readonly.

Freeing unused kernel memory: 104k freed

则表明nfs做为根文件系统挂载成功。

 

4. 注:

4.1使用nfs的机器必须在同一网段

4.2必须确保防火墙被关闭

4.3 Uboot环境变量设置:setenv bootargs ‘root=/dev/nfs rw nfsroot=<server-ip>:<root-dir>,proto=tcp,nfsvers=3,nolock ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconfig>’

4.4作为根文件系统的/home/rrhudp0216下必须有已经制作好的根文件系统,否则内核只能挂上文件系统,却不能使用,因为没有init等相关进程存在。

4.5为什么要加proto=tcp?

The NFS client works for small packet size(less than 1400kByte or so)without the option “-o tcp” specified (default is UDP protocol).With UDP protocol,it only breaks when the NFS server segments a larger packet to 2 or more packets to fix in MTU size. Seems like the NFS client code consistantly drops the segmented packets and keeps on requesting the NFS server for retransmission.

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值