嵌入式开发,如果使用nfs挂载来启动内核和文件系统,这样便于调试文件系统和驱动,则首先要保证ubuntu开启nfs服务。
执行以下命令安装nfs服务,安装后自动运行
sudo apt-get install nfs-kernel-server
配置其配置文件
sudo vi /etc/exports 在里面增加想要挂载的文件路径
#
11 /work/nfs_root *(rw,sync,no_root_squash)
12 /work/nfs_root/first_fs *(rw,sync,no_root_squash)
13 /work/kernel *(rw,sync,no_root_squash)
14 /work/nfs_root/fs_qtopia *(rw,sync,no_root_squash)
15 /work/system/u-bootbin *(rw,sync,no_root_squash)
16 / *
其中"*"表示所有客户机都可以访问(只要能通过网络访问到你)
rw当然表示有读写权限(不要担心)
no_root_squash表示客户机对此目录有root操作权限
这样就可以通过nfs服务来挂载nfs_root,kernel等目录下的所有文件;
配置完毕,可以重启NFS服务
sudo /etc/init.d/portmap restart //nfs is a RPC service, portmap maps its port
sudo /etc/init.d/nfs-kernel-server restart
查看NFS目录可以使用 ”showmount -e“ 命令
测试NFS服务是否开启成功
在本机ubuntu(10.13.60.120)上挂载nfs目录到/mnt,(挂载未在/etc/exports里面添加的目录是无效的)
sudo mount -t nfs 10.13.60.120:/home
可以看到/mnt下已经有/home的内容了 ,卸载使用 umount /mnt命令即可
通常,为了能够正常使用NFS,还需要一些相关的服务来协同工作:
nfs:启动相应RPC服务进程来服务对于NFS文件系统的请求。
nfslock:一个可选的服务,用于启动相应的RPC进程,允许NFS客户端在服务器上对文件加锁。
portmap:Linux的RPC服务,它响应RPC服务的请求和与请求的RPC服务建立连接。
问题1:当我把u-boot中关于nfs挂载参数设置好后,一直出现如下错误:
TCP cubic registered
NET: Registered protocol family 1
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
IP-Config: Complete:
device=eth0, addr=192.168.0.11, mask=255.255.255.0, gw=192.168.0.1,
host=192.168.0.11, domain=, nis-domain=(none),
bootserver=192.168.0.50, rootserver=192.168.0.50, rootpath=
Looking up port of RPC 100003/2 on 192.168.0.50
rpcbind: server 192.168.0.50 not responding, timed out
Root-NFS: Unable to get nfsd port number from server, using default
Looking up port of RPC 100005/1 on 192.168.0.50
问题是这样解决的:因为我的ubuntu没有开启portmap功能
sudo /etc/init.d/portmap restart
开启后再重新启动nfs系统就可以正常挂载ubuntu中的内核
问题2:服务器端无响应
TCP cubic registered
NET: Registered protocol family 1
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
IP-Config: Complete:
device=eth0, addr=10.37.0.151, mask=255.255.0.0, gw=10.37.0.254,
host=10.37.0.151, domain=, nis-domain=(none),
bootserver=10.37.0.149, rootserver=10.37.0.149, rootpath=
Looking up port of RPC 100003/2 on 10.37.0.149
Looking up port of RPC 100005/1 on 10.37.0.149
VFS: Mounted root (nfs filesystem).
Freeing init memory: 140K
init started: BusyBox v1.7.0 (2008-01-22 10:04:09 EST)
starting pid 765, tty '': '/etc/init.d/rcS'
nfs: server 10.37.0.149 not responding, still trying
问题是这样解决的:利用NFS挂载文件系统时,其实是相当于linux内核从服务器ubuntu上读取文件系统的内容,而内核启动后会立马去加载/etc/init.d/rsC,rcS文件中定义了开发板的IP,所以需要去修改文件系统中的rcS文件中的IP地址,要保证开发板的IP与ubuntu的地址处于同一个网段,就OK了。