在做嵌入式开发调试的时候,NFS常用来向嵌入式开发板挂载根文件系统。
我的主机linux版本:ubuntu20.04
1主机端启动NFS服务
1安装服务
sudo apt-get install nfs-kernel-server rpcbind
2等待安装完成,然后创建一个用于传输文件的专用文件夹。
mkdir /home/用户/linux/nfs
3配置NFS
sudo vi /etc/exports
在行尾加入:
/home/用户/linux/nfs *(rw,sync,no_root_squash)
4重启NFS服务
sudo /etc/init.d/nfs-kernel-server restart
nfs 80800000 192.168.1.250:/home/zuozhongkai/linux/nfs/zImage
2兼容问题
在uboot命令行中输入:nfs 80800000 192.168.1.100:/home/windoo/linux/nfs/zImage
将zImage(测试文件)烧录到DRAM的80800000地址
结果报出错误:ERROR: File lookup fail␊
错误原因:uboot中使用得NFS版本为V2版本,而ubuntu中的NFS版本为V3,V4及以上版本,从而导致uboot不能再NFS服务器中找到文件。造成了兼容性问题。
解决方法:修改/etc/default/nfs-kernel-server 文件
sudo vim /etc/default/nfs-kernel-server
修改为下面的样子:
:::
# Number of servers to start up
#RPCNFSDCOUNT=8
RPCNFSDCOUNT="-V 2 8"
# Runtime priority of server (see nice(1))
RPCNFSDPRIORITY=0
# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information,
# see rpc.mountd(8) or http://wiki.debian.org/SecuringNFS
# To disable NFSv4 on the server, specify '--no-nfs-version 4' here
#RPCMOUNTDOPTS="--manage-gids"
RPCMOUNTDOPTS="-V 2 --manage-gids"
# Do you want to start the svcgssd daemon? It is only required for Kerberos
# exports. Valid alternatives are "yes" and "no"; the default is "no".
NEED_SVCGSSD=""
# Options for rpc.svcgssd.
RPCSVCGSSDOPTS="--nfs-version2,3,4 --debug --syslog"