JZ2440开发板网络文件系统搭建nfs

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

JZ2440网络文件系统nfs搭建
问题描述:
在驱动程序开发阶段,会涉及到频繁的编译调试程序,如果每次都把驱动程序编译到内核去,会浪费大量的时间。

所以通常把驱动程序编译成.ko的模块动态加载到内核,这样可以省去编译整个内核的过程,大大提高了驱动开发的效率。

那么虚拟机上编译好的驱动模块怎样传递给目标机(开发板)呢,就是通过本文介绍的网络文件系统,PC机共享出一个网络文件系统给开发板,开发板就相当于多了一个本地文件夹一样。

原料:
1、JZ2440开发板+已经移植好的linux系统;
2、USB转UART连接线一根;
3、网线一根;
4、笔记本电脑安装vmware + Ubuntu;
步骤:
1、设置开发板IP地址,使开发板与虚拟机在同一个局域网。

这里采用的是笔记本无线上网,
有限网络连接到开发板,该部分不清楚的可以参考我之前的笔记《开发板通过笔记本的有线网络上网》。

a)开发板正常启动后,通过Uart中断:
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:60:6E:33:44:55
inet addr:192.168.1.17Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:28 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2776 (2.7 KiB) TX bytes:0 (0.0 B)
Interrupt:51 Base address:0xa000
b)查看虚拟机上的IP地址:
book@book-desktop:~$ ifconfig
eth3 Link encap:Ethernet HWaddr 00:0c:29:e4:a7:e1
inet addr:192.168.2.102Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fee4:a7e1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3015 errors:0 dropped:0 overruns:0 frame:0
TX packets:2173 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:940451 (940.4 KB) TX bytes:241758 (241.7 KB)
Interrupt:18 Base address:0x2024
eth4 Link encap:Ethernet HWaddr 00:0c:29:e4:a7:eb
inet addr:192.168.3.54 Bcast:192.168.3.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fee4:a7eb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4657 errors:0 dropped:0 overruns:0 frame:0
TX packets:1076 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:466534 (466.5 KB) TX bytes:182556 (182.5 KB)
Interrupt:17 Base address:0x20a4
c)将开发板ip改成192.168.2.100
# ifconfig eth0 192.168.2.100
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:60:6E:33:44:55
inet addr:192.168.2.100Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:28 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2776 (2.7 KiB) TX bytes:0 (0.0 B)
Interrupt:51 Base address:0xa000
d)开发板和虚拟机互ping一下:
book@book-desktop:~$ ping 192.168.2.100

64 bytes from 192.168.2.100: icmp_seq=2 ttl=63 time=0.720 ms (DUP!)
64 bytes from 192.168.2.100: icmp_seq=2 ttl=64 time=0.975 ms (DUP!)
64 bytes from 192.168.2.100: icmp_seq=2 ttl=63 time=0.978 ms (DUP!)
^C 记得ctrl + C来终止
--- 192.168.2.100 ping statistics ---
2 packets transmitted, 2 received, +4 duplicates, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.719/1.955/4.201/1.570 ms
# ping 192.168.2.102

64 bytes from 192.168.2.102: seq=2 ttl=64 time=1.446 ms (DUP!)
64 bytes from 192.168.2.102: seq=2 ttl=63 time=1.661 ms (DUP!)
64 bytes from 192.168.2.102: seq=2 ttl=64 time=1.871 ms (DUP!)
--- 192.168.2.102 ping statistics ---
3 packets transmitted, 3 packets received, 7 duplicates, 0% packet loss
round-trip min/avg/max = 1.114/1.598/2.095 ms
以上结果表明虚拟机和开发板的网络已经连上。

2、在虚拟机上安装nfs服务:
book@book-desktop:~$ sudo apt-get install nfs-kernel-server
[sudo] password for book:******
Reading package lists... Done
Building dependency tree
Reading state information... Done
nfs-kernel-server is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 346 not upgraded.
由于已经安装过了,所以不再更新
3、设置共享盘:
book@book-desktop:~$ mkdir /work/nfs_root
a)配置nfs目录:
book@book-desktop:~$ vi /etc/exports
添加:/work/nfs_root *(rw,sync,no_root_squash)
4、重启nfs服务:
book@book-desktop:~$ sudo /etc/init.d/portmap restart
book@book-desktop:~$ sudo /etc/init.d/nfs-kernel-server stop //停止nfs服务
book@book-desktop:~$ sudo /etc/init.d/nfs-kernel-server start //启动nfs服务
book@book-desktop:~$ sudo /etc/init.d/nfs-kernel-server restart //重启nfs服务
* Stopping NFS kernel daemon [ OK ] * Unexporting directories for NFS kernel daemon... [ OK ] * Exporting directories for NFS kernel daemon...
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/work/nfs_root".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x
exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/work/nfs_root/first_fs".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x
[ OK ] * Starting NFS kernel daemon [ OK ] 以上信息说明nfs启动OK。

5、在开发板UI里面先看一下未挂接前的文件夹:
可以看到mnt目录下是空的,没有任何内容。

挂接网络文件系统:
# mount -t nfs -o nolock 192.168.2.102:/work/nfs_root /mnt
对比虚拟机里面的文件夹:
完全一致。

到此,开发板可以与虚拟机通过网络共享文件。

相关文档
最新文档