做嵌入式开发经常需要调试设备,为了方便调试,在Ubuntu上安装一个NFS服务器,以便在设备上远程挂载使用。
1、打开终端,安装下载NFS:sudo apt install nfs-kernel-server
2、在家目录下创建一个共享目录nfs,给远程挂载使用,名称可以自行任意定义;
3、命令行打开exports文件:sudo gedit /etc/exports
在最后一行输入:/home/zboss/nfs *(rw,sync,no_root_squash)
保存退出
4、重启rpcbind 服务,命令行输入:sudo /etc/init.d/rpcbind restart
5、重启nfs服务,命令行输入:sudo /etc/init.d/nfs-kernel-server restart
6、这样nfs服务搭建完成,下面进行测试。
在nfs目录下创建hello.txt文件,并输入“hello world”,同时在家目录下创建test目录,将test挂载到nfs目录,查看test目录是否可以成功读取hello.txt文件;
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/a77411397c314fc0aeb5c02c2342c96f.png#pic_center
7、测试挂载:sudo mount localhost:/home/zboss/nfs test -o nolock
打印 hello world! 成功挂载
8、命令行输入:sudo umount test
可卸载刚刚挂载的test目录
NFS服务搭建完成。
9、如果客户端没有安装nfs的话,需要安装一下:
sudo apt-get install nfs-common