2022/12/02 15:27
1、配置前先确认虚拟机和主机不要共享IP,如果是共享,需要修改
修改步骤如下:
VMware workstation ->Player->管理->虚拟机设置->网络适配器->网络连接->勾选桥接模块式,勾选复制物理网络连接状态
然后保存退出
在虚拟机上确认IP地址:ifconfig
2、开发板eth0连接网络,激活eth0,自动获取IP地址:
ifconfig eth0 up
udhcpc –i eth0
查询开发版IP地址,ping虚拟主机IP地址,确认是否ping通
3、虚拟机安装NFS
在ubuntu虚拟机安装如下组件:
sudo apt-get install nfs-kernel-server
sudo apt-get install nfs-common
第一个是安装NFS服务器端,第二个是安装NFS客户端
4.虚拟机添加NFS共享目录
sudo vim /etc/exports
在文件的最后添加想要共享的文件
/nfsroot *(rw,sync,no_root_squash)
"/nfsroot"是要共享的目录,“ * ”意思是所有人都能挂载
此时还没有/nfsroot目录,新建/nfsroot目录并为其赋予最高权限
sudo mkdir /nfsroot
sudo chmod -R 777 /nfsroot
sudo chown test:test /nfsroot/ -R
"test"为当前用户
5.虚拟机启动NFS服务
sudo /etc/init.d/nfs-kernel-server start
这里的start是启动服务,可以换成restart、stop、status,意思分别为“重新启动、停止、查看状态”
注意,当NFS已启动的时候,如果修改了“/etc/exports”文件,需要重新启动NFS服务才能生效
6,进行共享
在开发板串口命令行输入:
mount -t nfs 192.168.0.112:/nfsroot /mnt -o nolock
这里的“192.168.0.112”是将“/nfsroot”共享的主机的ip(即ubuntu虚拟机IP),“/mnt”(开发板上的)是与“/nfsroot”共享的目录。两个目录都要写出准确的地址