当 NFS 服务设置好并启动后,我们就可以把 NFS 作为根文件系统来启动开发板了.使用 NFS 作为根文件系统,开发板的“硬盘”就可以变得很大,因为您使用的是主机的硬盘,这是使用 linux 作为开发经常使用的方法,
路由器一台,宿主机网线连到路由。开发板连到路由,开发板串口连到宿主机。
------------------------------------------
宿主机配置NFS
Ubuntu10.04 上默认是没有安装Ubuntu nfs服务器的,因此我们首先安装Ubuntu nfs服务器端:
$sudo apt-get install nfs-kernel-server
(1)设置共享目录
运行命令
#gedit /etc/exports
编辑 nfs 服务的配置文件(注意:第一次打开时该文件是空的),添加以下内容:
/opt/FriendlyARM/QQ2440V3/root_nfs *(rw,sync,no_root_squash)
其中:
/opt/FriendlyARM/QQ2440/root_nfs 表示 nfs 共享目录,它可以作为开发板的根文件系
统通过 nfs 挂接;
* 表示所有的客户机都可以挂接此目录
rw 表示挂接此目录的客户机对该目录有读写的权力
no_root_squash 表示允许挂接此目录的客户机享有该主机的 root 身份
2) 建立共享目录
拷贝光盘中的 root_nfs.tgz 文件到某一个目录,进入此目录,执行以下命令:
#tar xvzf root_nfs.tgz –C /opt/FriendlyARM/QQ2440/root_nfs
该命令将把 root_nfs 的内容解压安装到/opt/FriendlyARM/QQ2440/root_nfs 目录。
(3) 启动和停止 nfs 服务
三、重启服务
$ sudo /etc/init.d/portmap restart
$ sudo /etc/init.d/nfs-kernel-server restart或#sudo service nfs-kernel-server restart
这将启动 nfs 服务,可以输入以下命令检验 nfs 该服务是否启动。
# mount -t nfs localhost: /opt/FriendlyARM/QQ2440/root_nfs /mnt/
如 果 没 有 出 现 错 误 信 息 , 您 将 可 以 浏 览 到 /mnt 目 录 中 的 内 容 和
/opt/FriendlyARM/QQ2440/root_nfs 是一致的。
[email protected]:/tmp# mount -t nfs localhost:/opt/FriendlyARM/QQ2440V3/root_nfs /mnt/
[email protected]:/tmp# showmount -e
4.1 显示出共享出来的目录
$ showmount -e
4.3 查看挂载情况
$ df
4.4 卸载挂载
$ sudo umount /mnt
关闭NFS:
/etc/init.d/nfs-kernel-server stop
----------------------------
QQ2440开发板配置:
启动按q选项进入vivi模式:
查看 宿主机的IP地址等于多少。
Link encap:以太网 硬件地址 00:16:d4:dd:46:86
inet 地址:192.168.1.108 广播:192.168.1.255 掩码:255.255.255.0
查看 开发板的IP地址等于多少
vi /etc/init.d/rcS
192.168.1.100, mask=255.255.255.0,
拷贝进去:
param set linux_cmd_line "console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.108:/opt/FriendlyARM/QQ2440V3/root_nfs ip=192.168.1.100:192.168.1.108:192.168.1.108:255.255.255.0:QQ2440V3.arm9.net:eth0:off"
ip的第一项是目标板的临时IP(不要与局域网内其它IP冲突)。
第二项是boot server的IP(实际应用中发现好象没什么用)
第三项是目标板上的GW网关设置
第四项是掩码,
第五项是主机名,
第六项是网卡eth0,off的参数不知道是什么意思,但对整个启动应该没什么大的影响。
(3)如果一个命令太长,一行放不下时,要在第一行行尾键入“\”字符和按回车键。这时 shell 会返回一个大于号(>)作为提示符,表示允许命令延续到下一行。然后,可以接着输入命令。
uboot下设置nfs启动,类似supervivi,使用命令setenv bootargs而不是param set linux_cmd_line
检查一下在命令中间不要加换行
把终端拉长就可以了。
这个配置有问题,
NET: Registered protocol family 1
NET: Registered protocol family 17
IP-Config: Complete:
device=eth0, addr=192.168.1.100, mask=255.255.255.0, gw=192.168.1.108,
host=QQ2440V3, domain=, nis-domain=arm9.net,
bootserver=192.168.1.107, rootserver=192.168.1.108, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.108
Looking up port of RPC 100005/1 on 192.168.1.108
VFS: Mounted root (nfs filesystem).
mount_devfs_fs(): unable to mount devfs, err: -2
Freeing init memory: 144K
Warning: unable to open an initial console.
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
答:
1. 首先可以肯定的是,NFS已经mount成功了,至少内核是这么认为的,否则你不会看到
VFS: Mounted root (nfs filesystem)
mount_devfs_fs(): unable to mount devfs, err: -2
解决方法是:
“其实内核本身已经告诉了你出错的原因,你只要稍加分析就可以知道。
根据kernel-2.6.13/include/asm-generic/errno-base.h,
#define ENOENT 2
在PC的/opt/FriendlyARM/QQ2440/root_nfs /mnt目录下建一个dev目录让devfs挂载到那里”
然后从新VIVI:
Mounted devfs on /dev
Freeing init memory: 144K
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
解决方法:
param set linux_cmd_line "console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.108:/opt/FriendlyARM/QQ2440/root_nfs ip=192.168.1.70:192.168.1.108:192.168.1.108:255.255.255.0:fighter:eth0:off"
改为:
param set linux_cmd_line "console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.108:/opt/FriendlyARM/mini2440/root_nfs/root_nfs
ip=192.168.1.70:192.168.1.108:192.168.1.108:255.255.255.0:fighter:eth0:off"
(1。因为是mini2440板,自然要把QQ2440改为mini2440
2。/root_nfs 改为/root_nfs/root_nfs,有类似错误的朋友可看一下你的linux主机上的文件,你会发现路径应该是/opt/FriendlyARM/mini2440/root_nfs/root_nfs)
然后从新VIVI:
Freeing init memory: 144K
[01/Jan/1970:00:00:00 +0000] boa: server version Boa/0.94.13
[01/Jan/1970:00:00:00 +0000] boa: server built Feb 28 2004 at 21:47:23.
[01/Jan/1970:00:00:00 +0000] boa: starting server pid=261, port 80
Please press Enter to activate this console. MPEG Audio Decoder 0.15.0 (beta) - Copyright (C) 2000-2003 Robert Leslie et al.
Title: ��ɺ��̲
Artist: �Ҷ���
Year: 2000
Genre: Goa
[[email protected] /]#
NFS 配置ok
以后启动就用这个把。
param set linux_cmd_line "console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.108:/opt/FriendlyARM/QQ2440V3/root_nfs/root_nfs ip=192.168.1.100:192.168.1.108:192.168.1.108:255.255.255.0:QQ2440V3.arm9.net:eth0:off"
#gedit /etc/exports
编辑 nfs 服务的配置文件(注意:第一次打开时该文件是空的),添加以下内容:
/opt/FriendlyARM/QQ2440V3/root_nfs *(rw,sync,no_root_squash)
改为 /opt/FriendlyARM/QQ2440V3/root_nfs/root_nfs *(rw,sync,no_root_squash)
如何挂接使用网络文件系统NFS:
mount -t nfs -o nolock 192.168.1.108:/opt/FriendlyARM/QQ2440V3/root_nfs /mnt
挂接共享文件夹OK。