android 使用 NFS 根文件系统

android可以通过修改bootenv和kernel的配置,实现rootfs从nfs中启动,这样,每次修改rootfs过后,或者修改package的apk后,可以直接从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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值