|  | 
 
| 搭建通过nfs mount rootfs开发环境(原创) tryitle
 
 
 
 新手上路
 
 
 问题分数 : 20
 贴子数量 : 2
 注册日期 : 2003/4/22
 在线情况 : 离线
 
 发表于: 2004/4/8 - 15:20     楼主
 搭建通过nfs mount rootfs开发环境:
 有了这个环境好处就蛮多了,最主要好处就是系统在研发阶段,不用无数次地烧写flash,加快开发速度。
 不过在搭建这个环境前应具备的条件有:
 1. 在板子上应有个可以支持ethernet网络(ftp,tftp)下载的bootload
 2. 下载的是image.ram( RAM版,非ROM版喔)
 server端-redhat 7.3:
 1. Nfs server
 a) /etc/exports
 添加内容-可读写,可行使root权限:
 /work2/uc24/uClinux-dist/romfs *(rw,no_root_squash,no_all_squash)
 2.Host解释相关
 b) /etc/hosts
 由于没使用DNS解释机器名称(动态),这里采取静态映射的方式,名称不能重复
 192.168.8.135 le.com
 
 192.168.8.101 lelinux1
 192.168.8.102 lelinux2
 192.168.8.103 lelinux3
 192.168.8.104 lelinux4
 
 c) /etc/hosts.deny
 先对所有用户封闭nfs相关网络支持
 portmap : ALL
 lockd : ALL
 mountd : ALL
 rquotad : ALL
 statd : ALL
 
 d) /etc/hosts.allow
 再对指定范围用户打开nfs相关网络支持
 portmap : 192.168.8.0/255.255.255.0
 lockd : 192.168.8.0/255.255.255.0
 mountd : 192.168.8.0/255.255.255.0
 rquotad : 192.168.8.0/255.255.255.0
 statd : 192.168.8.0/255.255.255.0
 
 2. Dhcpd server
 配置/etc/dhcpd.conf
 内容如下:
 use-host-decl-names on;
 default-lease-time 259200;
 max-lease-time 518400;
 allow bootp;
 
 subnet 192.168.8.0 netmask 255.255.255.0 {
 # --- default gateway
 option routers 192.168.8.135;
 option subnet-mask 255.255.255.0;
 range 192.168.8.101 192.168.8.105;
 
 group {
 host le.com {
 hardware ethernet 00:03:FF:4E:4F:50;
 fixed-address 192.168.8.135;
 filename "image.ram";
 option root-path "/work2/uc24/uClinux-dist/romfs";
 }
 }
 }
 
 3. Portmap
 开启状态,Nfs需要portmap的支持
 
 4. 制作rootfs
 很简单,在uclinux的image生成之后,在开发环境下会有个romfs目录(笔者环境下为:/work2/uc24/uClinux-dist/romfs),在其dev子目录下需要执行的动作:
 从系统的/dev目录下拷贝设备文件到这个目录中,拷贝的设备文件主要有,满多的,估计我的系统一些是没有用到的:
 crwxrwxrwx 1 root root 5, 1 4月 8 2004 console
 crwxrwxrwx 1 root root 5, 64 3月 15 2002 cua0
 crwxrwxrwx 1 root root 5, 65 3月 15 2002 cua1
 crwxrwxrwx 1 root root 1, 7 4月 8 2004 full
 crwxrwxrwx 1 root root 1, 2 4月 8 2004 kmem
 
 crwxrwxrwx 1 root root 1, 1 4月 8 2004 mem
 crwxrwxrwx 1 root root 1, 3 4月 8 2004 null
 crwxrwxrwx 1 root root 1, 4 4月 8 2004 port
 crwxrwxrwx 1 root root 2, 0 3月 15 2002 ptyp0
 crwxrwxrwx 1 root root 2, 1 3月 15 2002 ptyp1
 crwxrwxrwx 1 root root 2, 2 3月 15 2002 ptyp2
 crwxrwxrwx 1 root root 2, 3 3月 15 2002 ptyp3
 
 lrwxrwxrwx 1 root root 4 4月 7 20:30 ram -> ram1
 brwxrwxrwx 1 root root 1, 0 4月 8 2004 ram0
 brwxrwxrwx 1 root root 1, 1 4月 8 2004 ram1
 brwxrwxrwx 1 root root 1, 10 4月 8 2004 ram10
 brwxrwxrwx 1 root root 1, 11 4月 8 2004 ram11
 
 crwxrwxrwx 1 root root 5, 0 4月 8 2004 tty
 crwxrwxrwx 1 root root 4, 0 4月 8 2004 tty0
 crwxrwxrwx 1 root root 4, 1 4月 8 2004 tty1
 crwxrwxrwx 1 root root 4, 10 4月 8 2004 tty10
 
 crwxrwxrwx 1 root root 3, 0 9月 20 2003 ttyp0
 crwxrwxrwx 1 root root 3, 1 7月 20 2003 ttyp1
 crwxrwxrwx 1 root root 3, 2 3月 15 2002 ttyp2
 crwxrwxrwx 1 root root 3, 3 3月 15 2002 ttyp3
 crwxrwxrwx 1 root root 3, 4 3月 15 2002 ttyp4
 
 5. 相关命令:
 /etc/init.d/nfs restart
 /etc/init.d/dhcpd restart
 /etc/init.d/portmap restart
 cp –Pf dev/console /work2/uc24/uClinux-dist/romfs/dev
 
 client端-uclinux-dist-20030305:
 1.关闭dhcpcd,因为kernel在mount rootfs时已经通过dhcp获得的客户端的ip,所以无需再在客户端启动dhcpcd,否则可能两次获得不同的ip导致: Permission denied
 2.打开portmap,可以放在/etc/rc文件中最后启动
 否则会保出错误:Stale NFS file handle
 3.需要client kernel关闭的功能(冲突)有romfs支持,blkmem支持
 4.需要client kernel开启的功能(支持nfs)有
 a) File systems ->
 Network File Systems
 <*> NFS file system support Provide NFSv3 client support
 b)NetWorking->
 ip autoconfigation
 c)busybox->
 mount support nfs
 
 
 
 
 6. 修改/arch/armnommu/kernel/setup.c
 //#define CONFIG_CMDLINE "root=/dev/rom0"
 #define CONFIG_CMDLINE "root=/dev/nfs
 rw nfsroot=192.168.8.135:/work2/uc24/uClinux-dist/romfs ip=192.168.8.101::::le:eth0:any"
 
 //static char command_line[COMMAND_LINE_SIZE] = "root=/dev/rom0";
 static char command_line[COMMAND_LINE_SIZE] = "root=/dev/nfs rw"
 " nfsroot=192.168.8.135:/work2/uc24/uClinux-dist/romfs"
 " ip=192.168.8.101::::le:eth0:any";
 
 
 备注:
 1. server端ip为192.168.8.135
 2. client端ip范围为192.168.8.101-192.168.8.105
 3. 本人偷懒是在romfs(/work2/uc24/uClinux-dist/romfs)上替换了下dev目录就当成roofs供nfs mount的
 4. 推荐大家在win2k上装个virtualPC,vmWare之类的软件,在上面装革redhat linux,跟win2k之间切换,共享文件都很方便,相关资料网上很多。
 5. 以上环境正在运行,如您发现配置有哪些不妥,遗漏之处,欢迎批评,大家一起长进,谢谢。
 
 tryitle
 2004/04/08
 | 
 |