Android NFS File System

Source: Internet
Author: User

Recently, we have been studying Android transplantation. The target platform is.
I have seen many excellent articles on the Internet and have gained a lot of inspiration.
Here is an article on how to use NFS as the root file system, which is well written and reposted here. After reading this article, based on your own experiences, write down your usage methods for your reference.

[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) '! Strncmp (name, "log _", 4 )'.

4. Modify init. RC config file.

Comment out below statements

Mount 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 shoshould 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

Usage tips:

In the process of using NFS, the second step is different from that of the author. I set the uboot startup parameters and didn't fix the parameters in the Linux kernel as I did, the parameters I set in uboot are as follows:

 
Setenv bootargs "root =/dev/nfs nfsroot = 192.168.0.20.:/forlinux/root IP = 192.168.0.231: 192.168.0.20.: 192.168.0.201: 255.255.255.0: witech.com.cn: eth0: Off init =/linuxrc console = ttysac0, 115200"
Saveenv

 

192.168.0.20.is the Host IP address (the PC running the Ubuntu system), and 192.168.0.231 is the IP address of the android embedded device. Set it here. 192.168.0.201 is the gateway of my network. Of course, these three IP addresses can be set according to your current network conditions, not necessarily the same as mine.

 

:/Forlinux/root is an open NFS directory containing the android file system, which is the same as/nfsroot 192.16 8.1.101 (RW, no_root_squash, sync) in the first step of the author, the/nfsroot directory is open. I open the/forlinux/root directory.

After setting the parameters, you can mount the NFS file system smoothly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.