环境
环境 ubuntu 10.4 vm 7.1
终端
ifconfig 得到 ubuntu资料
INET ADDR 192.168.0.4
BCAST 192.168.0.255
MASK 255.255.255.0
操作前先关闭防火墙
关闭防火墙:
命令:sudo ufw disable
打开防火墙
命令:sudo ufw enable
配置过程
一 安装NFS
$ sudo apt-get install nfs-kernel-server
$ sudo apt-get install nfs-common
二 配置NFS
1 $ sudo dpkg-reconfigure portmap
, 对Should portmap be bound to the loopback address? 选N
2 $ sudo gedit /etc/default/portmap
末行清除 “-i 127.0.0.1”
三 配置hosts.deny
$ sudo gedit /etc/hosts.deny
文本末添加
portmap: ALL
lockd: ALL
mountd: ALL
rquotad: ALL
statd: ALL
四 配置hosts.allow
$ sudo gedit /etc/hosts.allow
文本末加入
### NFS DAEMONS
portmap: 192.168.0.
lockd: 192.168.0.
rquotad: 192.168.0.
mountd: 192.168.0.
statd: 192.168.0.
$ sudo /etc/init.d/portmap restart
重启portmap daemon.
显示如下
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the restart(8) utility, e.g. restart portmap
portmap start/running, process XXXX
五 配置/etc/exports
$ sudo gedit /etc/exports
文本末添加
/home/yuanyi/QT_WORK *(rw,sync,no_root_squash)
chmod 777 -R /home/work
$ sudo showmount -e
显示 clnt-create : RPC : Program not registered
$ sudo exportfs -r
更新
$ sudo showmount 192.168.0.4 -e
显示
Export list for 192.168.0.4:
/home/yuanyi/QT_WORK *
六 启用
$ sudo /etc/init.d/nfs-kernel-server restart
重启nfs服务
显示如下
* Stopping NFS kernel daemon [ OK ]
* Unexporting directories for NFS kernel daemon... [ OK ]
* Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/home/work".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x
* Starting NFS kernel daemon
[ OK ]
开发板的操作
进入uboot设置环境变量
nugget# setenv gatewayip 192.168.0.1
nugget# setenv netmask 255.255.255.0
nugget# setenv ipaddr 192.168.0.130
nugget# setenv serverip 192.168.0.136
开发板挂载
mount -t nfs 192.168.0.4:/home/yuanyi/QT_WORK /nfsmnt
如果提示failed: Connection refused
请使用下面的命令
mount -t nfs 192.168.0.100:/home/yuanyi/QT_WORK /mnt -o nolock
卸载
Umonut /mnt
解决
mount.nfs: mount system call failed;
Mount.nfs: access denied by server while mogunting 192.168.2.1:/home ;
Clnt_create: RPC:Program no registered等问题
NFS不能挂接主要问题:
1、ip设置不正确
2 /etc/hosts.allow没有配置好
3、没关闭防火墙