android可以通过修改bootenv和kernel的配置,实现rootfs从nfs中启动,这样,每次修改rootfs过后,或者修改package的apk后,可以直接从nfs启动,而不需要重新烧录,调试时速度更快。
从网上找了些文章,后面有空再研究一下:
First written by Steve Guo, please keep the mark if forwarding.]
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