|
发表于 2013-1-28 08:49:01
|
显示全部楼层
0,在Ubuntu新建nfs目录:
#mkdir /home/shuimu/arm_project/rootfs
将FORLINX_6410_yaffs2_v1.0.tgz复制到rootfs中,
解压当前文件夹#tar –zxf FORLINX_6410_yaffs2_v1.0.tgz
1.烧写mmc,uboot,zImage到开发板。
2,在ubuntu上安装nfs-server-kernal。编辑/etc/export文件,设置输出路径。启动nfs服务。
安装:
#sudo apt-get install portmap
#sudo apt-get install nfs-kernel-server
#sudo gedit /etc/exports
在弹出的文本编辑器中编辑exports 文件,在最后一行添加:
/forlinx *(rw,sync,no_root_squash)
启动相关服务:
#sudo /etc/init.d/portmap restart
#sudo /etc/init.d/nfs-kernel-server restart
3,在uboot启动后,输入:
#setenv bootargs "root=/dev/nfs nfsroot=192.168.1.1:/home/shuimu/arm_project/rootfs ip=192.168.1.200:192.168.1.1:192.168.1.1:255.255.255.0:witech.com.cn:eth0:off console=ttySAC0,115200"
#saveenv
#printenv
#reset
NOTE:
192.168.1.1 PC 端Ubuntu 的IP
192.168.1.200 开发板IP
192.168.1.1 网关
255.255.255.0 子网掩码
saveenv(保存)
printenv查看设置是否正确
恢复nand flash启动:setenv bootargs “root=/dev/mtdblock3 consle=/dev/ttySAC0,115200”
#saveenv
#reset
Android 使用NFS喝Linux还是有点不同的,需要我们注意。
这里有一篇如何使用nfs作为根文件系统的文章,写的不错, 转载到这里了,看了这篇文章以后,根据自己的使用心得,把自己的使用方法也写了下来,供大家参考
[First written by Steve Guo, please keep the mark if forwarding.]Usually the Android uses YAFFS as rootfs and uses the mtd device as storage media, the bad blocks in the mtd device seldom cause YAFFS file system to work abnormally. if the Android uses NFS as the rootfs, there will not exist such problem. So here is the solution to use NFS as the rootfs of Android.
1. Setup host machine as NFS server (I will use ubuntu 8.0.4 as an example.).
$ sudo apt-get install nfs-kernel-server portmap
$ sudo mkdir /nfsroot
$ sudo vim /etc/exports
Add one line in /etc/exports,
/nfsroot 192.168.1.101(rw,no_root_squash,sync)
Then restart NFS server.
$ sudo /etc/init.d/nfs-kernel-server restart Here setups an NFS server which exports /nfsroot directory only to 192.168.1.101(Which is the default IP address of Android eth0).
2. Build a Linux kernel image to use NFS as rootfs.
$make menuconfig
Modify the default setup. In "general setup" section, uncheck the "initial RAM filesystem and RAM disk(initramfs/initrd) support". In "file systems" section, check the "Network File Systems" and mark it as kernel built-in. In "boot options" section, add the kernel parameter "root=/dev/nfs nfsroot=192.168.1.100:/nfsroot init=/init". 192.168.1.100 is the IP address of host machine running NFS server.
3. Modify init program.
To make log system work, in the device/system/init modify the device.c by change the statement '!strncmp(uevent->path,"/class/misc/",12) && !strncmp(name, "log_", 4) to '!strncmp(name, "log_", 4)'.
4. Modify init.rc config file.
Comment out below statements
mount rootfs rootfs /ro remount
mount yaffs mtd@system /system
mount yaffs2 mtd@system /system ro remout
mount yaffs2 mtd@userdata /data nosuid nodev
mount yaffs2 mtd@cache /cache nosuid nodev
5. Add the user id and group id used by android on the NFS server.
Android does not use /ect/passwd file to record the user name and user id, it uses a fixed method to map the user name to user id through the head file device/include/private/android_filesystem_config.h, e.g. the user "system" has the user id of 1000.
So to correctly set the file ownership(owner and group), the NFS server should have these users with correct user IDs. Such as system(1000). For ubuntu, you can call like this.
$sudo userdd -u 1000 android_system
This step is not necessary. It only allows you to display a user name in the develop machine.
6. Prepare the rootfs.
Assume the built output of device lies in device/out/target/product/***/, which is called $OUTPUTDIR later. Do the follwings:
$cp -rf $OUTPUTDIR/root/* /nfsroot
$cp -rf $OUTPUTDIR/system /nfsroot
$cp -rf $OUTPUTDIR/data /nfsroot
使用心得:
我在使用NFS过程中第二步骤与作者的不同,我是设置的Uboot的启动参数,没有像作者那样在linux内核 中固定参数,我在Uboot中设置的参数是这样的:
setenv bootargs "root=/dev/nfs nfsroot=192.168.0.232:/forlinux/root ip=192.168.0.231:192.168.0.232:192.168.0.201:255.255.255.0:witech.com.cn:eth0ff init=/linuxrc console=ttySAC0,115200 "
saveenv
其中 192.168.0.232是主机IP(运行Ubuntu系统的PC),192.168.0.231是Android嵌入式设备的IP地址,在这里设定。192.168.0.201是我的网络的网关,当然这三个IP地址可以跟据你的当前网络情况来设置,不一定跟我的相同。
:/forlinux/root 是NFS开放的目录,里面存放着Android的文件系统,跟作者第一步骤中 /nfsroot 192.16 8.1.101(rw,no_root_squash,sync) 雷同,他开放的是 /nfsroot目录,我开放的是 /forlinux/root目录。
设定好参数后就可以顺利的挂载NFS文件系统了。 |
|