Ubuntu安装配置NFS服务

来源:互联网 发布:杭州公司网络安防招聘 编辑:程序博客网 时间:2024/04/29 04:44
   首先确定系统是否安装了nfs服务,默认的好像没有。那么就要安装咯,不过很简单的。

一:测试 dpkg -l nfs* 回车,如果有:

caoyi@ubuntu:~$ dpkg -l nfs*

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
un  nfs-client     <none>         (no description available)
ii  nfs-common     1:1.2.2-1ubunt NFS support files common to client and serve
ii  nfs-kernel-ser 1:1.2.2-1ubunt support for NFS kernel server
un  nfs-server     <none>         (no description available)
则表示已经安装!否则进行下一步:

 

1、安装NFS
caoyi@ubuntu:~$ sudo apt-get install nfs-kernel-server nfs-common portmap

2.修改NFS配置文件
caoyi@ubuntu:~$ sudo vim /etc/exports
内容为:
     /home/drivers     *(rw,sync,no_root_squash,no_subtree_check)


     /home/lingd/arm---要共享的目录
      *---允许访问的网段,也可以是ip地址、主机名(能够被服务器解析)、*(所有人都能访问)
     (rw,sync,no_root_squash,no_subtree_check)---rw:读/写权限
                                 sync:数据同步写入内存和硬盘
                                 no_root_squash:服务器允许远程系统以root特权存取该目录
no_subtree_check:关闭子树检查
其他选项可以通过man exports查阅man文档

3、启动服务
重启portmapper(端口映射)服务
caoyi@ubuntu:~$ sudo service portmap restart
portmap start/running, process 550
重启NFS服务
caoyi@ubuntu:~$  sudo service nfs-kernel-server restart
 * Stopping NFS kernel daemon                                               [ OK ]
 * Unexporting directories for NFS kernel daemon...                      [ OK ]
 * Exporting directories for NFS kernel daemon...                        [ OK ]
 * Starting NFS kernel daemon                                               [ OK ]

三、测试
1、本机挂载
caoyi@ubuntu:~$  ls /mnt/nfs/
caoyi@ubuntu:~$  sudo mount -t nfs -o nolock localhost:/home/drivers /mnt/nfs/
caoyi@ubuntu:~$  ls /mnt/nfs/

1day  2day  Makefile_arm

caoyi@ubuntu:~$  sudo umount /mnt/nfs
caoyi@ubuntu:~$  ls /mnt/nfs/


2、开发板挂载
# ls /mnt                                                 
 # mount -t nfs 192.168.7.99:/home/drivers /mnt

192.168.7.99 为宿主机的IP地址

/home/drivers 为在宿主机上   /home/drivers 设置的共享目录
# cd mnt
# ls
1day          2day          Makefile_arm
#
# umount /mnt
# ls /mnt
#

原创粉丝点击