安装NFS
sudo apt-get install nfs-kernel-server
sudo apt-get install nfs-common
配置NFS共享目录
假设我们要共享的目录是/nfs_share
编辑/etc/exports文件
sudo vim /etc/exports
把/nfs_share目录添加到这个文件的最后一行
/nfs_share *(rw,sync,no_root_squash)
这里的星号 * ,表示任何网段IP都可以访问这个目录
/nfs_share目录权限修改,根据自己的需要来,如果是为了方便开发,可以直接设置成777
sudo chmod -R 777 /nfs_share
启动NFS
sudo /etc/init.d/nfs-kernel-server start #启动服务
sudo /etc/init.d/nfs-kernel-server restart #重启服务
#为了方便,可以直接使用restart
本地测试NFS挂载
我的测试环境Ubuntu主机的IP是192.168.3.125,测试的时候用这个IP作为例子
sudo mount -t nfs 192.168.3.125:/nfs_share /mnt -o nolock
成功后,可以在/mnt目录下看到/nfs_share的内容
如果需要卸载,使用umount即可,注意要保证没有进程在使用/mnt目录
umount /mnt
如果要在开发板上挂载NFS,命令是一样的,只要保证开发板能ping通主机并且存在nfs client即可。