Android 使用 NFS 根文件系统


最近在研究Android的移植,目标平台是marvell的pxa310。
在网上看到很多高手的文章,得到很多启发。
转载一篇Android如何使用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,

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

 

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.

相关内容