当前位置首页 > Ubuntu知识

ubuntu设置NFS文件系统

阅读次数:393 次  来源:admin  发布时间:

首先在PC的linux系统的/opt/EmbedSky/下建立一个文件夹作为共享目录。

#mkdir /opt/EmbedSky/share

然后要在PC上安装NFS服务器:

#apt-get install nfs-kernel-server

安装完毕之后要配置共享目录和访问权限:

#gedit /etc/export

然后添加:

/opt/EmbedSky/share *(rw,sync,no_root_squash)

其中/opt/EmbedSky/share代表要共享的目录。*代表允许所有IP地址访问,rw读写权限,sync同步更新,no_root_squash挂载该目录的的用户在该目录中拥有root权限。

然后配置访问访问权限:

在/etc/hosts.deny文件中添加:

ortmap:ALL

lockd:ALL

mountd:ALL

rquotad:ALL

tatd:ALL

保存退出

在/etc/hosts.allow文件中添加:

ortmap:*

lockd:*

rquotad:*

mountd:*

tatd:*

保存退出

然后改写共享目录的权限(我直接给最大的权限,为了安全可以计算一下)

chmod -R 777 /opt/EmbedSky/share

现在可以启动NFS服务了

/etc/init.d/nfs-kernel-server start

然后可以测试看共享目录是否存在:

#showmount -e

如果配置成功会打印共享的目录。

在这里可以用mount命令将刚才共享的目录mount到本机进行测试:

#mount -t nfs localhost:/opt/EmbedSky/share /mnt/

#ls /mnt/

可以看到share文件夹的内容

然后可以在开发板的终端中输入:

#mount -t nfs 192.168.4.2:/opt/EmbedSky/share /mnt/ -o nolock

这里192.168.4.2是主机的ip地址。

需要注意的是,有可能需要关闭ubuntu的防火墙:

#ufw disable

我是直接把iptables删除了

使用如下命令:

apt-get remove iptable

不出意外可以的话在开发板中输入:

#ls /mnt

就能看到主机PC上/opt/EmbedSky/share文件夹里面的内容了。

上一篇:fedora配置ip
下一篇:Linux设置中文-youruther