1、安装 Ubuntu NFS 服务
sudo apt-get install nfs-kernel-server
2、添加“服务器允许被挂载的目录”
sudo vi /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/work/rootfs *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)
3、重启NFS服务
sudo /etc/init.d/nfs-kernel-server restart
4、使用情景1:uboot的nfs下载命令
nfs [loadAddress] [[hostIPaddr:]bootfilename]
如:nfs 80000000 服务器IP:/home/book/zImage
5、使用情景2:开发板去挂载
mount -t nfs -o nolock vers=2 服务器IP:/work/rootfs /mnt
6、使用情景3:开发板启动时直接挂载网络文件系统
uboot设置环境变量bootargs,格式可参考kernel/Documentation/filesystems/nfs/nfsroot.txt:
如:
console=ttymxc0,115200 root=/dev/nfs rw nfsroot=服务器IP:/work/rootfs ip=开发板IP:服务器IP:网关:子网掩码::eth0:off