Ubuntu NFS 安装与配置

一、NFS安装
    $ sudo apt-get install nfs-kernel-server nfs-common portmap
二、NFS配置
    2.1 配置/etc/exports文件
    $ sudo vim /etc/exports
在文件最后加入如下内容:
      /rootnfs  *(rw,sync,no_root_squash)

注:nfs允许挂载的目录及权限,在文件/etc/exports中进行定义,各字段含义如下:

/rootnfs:要共享的目录

* :允许所有的网段访问

rw :读写权限

sync:资料同步写入内在和硬盘

no_root_squash:nfs客户端共享目录使用者权限

 

重启服务:
#sudo /etc/init.d/portmap restart                  <---重启portmap,
#sudo /etc/init.d/nfs-kernel-server restart      <---重启nfs服务
#showmount -e                                          <---显示共享出的目录

注:nfs是一个RPC程序,使用它前,需要映射好端口,通过portmap设定

命令执行情况如下:

kevin@ubuntu:~$sudo /etc/init.d/portmap restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service portmap restart

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 474


kevin@ubuntu:~$sudo /etc/init.d/nfs-kernel-server restart
 * 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/xgc".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x
                                                                                 [ OK ]
 * Starting NFS kernel daemon                                       [ OK ]

kevin@ubuntu:~$showmount -e
Export list for xgc-VirtualBox:
/rootnfs *

 

现在可以在本机上试一下:
#sudo mount -t nfs localhost:/rootnfs /mnt

注:localhost为本机linux的IP地址

这样就把共享目录挂到了/mnt目录,取消挂载用:
#sudo umount /mnt

如果用在嵌入式设备上挂载,要加上参数-o nolock

我在开发板上使用的挂载命令:

mount -t nfs -o nolock 192.168.1.12:/rootnfs /mnt/nfs

注:

  1.确保XPlinux虚拟机、ARM开发板三者的IP地址在同一网段,并且不冲突,能够互相ping

  •       2.在ubunt虚拟机中输入命令“route del default”,取消虚拟机的默认路由。
  •       3.
  • ARM开发板上操作如下:

1ifconfig eth0 192.168.1.13 (配置ARM开发板的IP地址)

 

(2)mount -t nfs -o nolock 192.168.1.12:/rootnfs /mnt/nfs(将linux虚拟机 /home/uptech 目录挂载到ARM开发板的/mnt/nfs目录下)

 

3cd  /mnt/nfs (即可访问ubuntu共享的文件夹)

 

posted on 2015-05-24 12:11  HELLO-CP  阅读(437)  评论(0)    收藏  举报

导航