File system architecture for Android

Source: Internet
Author: User

1. Structure of Android file system

The official Android source code is compiled after the following files:

There are system.img,ramdisk.img,userdata.img three image files. Among them, Ramdisk.img is the file system, System.img includes the main package, library and other files, USERDATA.IMG includes some user data, and when emulator loads the 3 image files, system.img and userdata.img are loaded into the system and RAMDisk directories in the UserData filesystem respectively.

2 , separating and assembling the Android file system
The system.img,ramdisk.img,userdata.img image file is cpio packaged, gzip compressed, and can be verified by the file command:
Filer amdisk.img, Output:

[Plain]View PlainCopy 
    1. Ramdisk.img:gzip compressed data, from Unix, last modified:

Where ramdisk.img is a partition image file, which is a filesystem (root file system), when kernel starts, RAMDisk is responsible for INIT, System.img includes the main system, system app, etc., attached to the system folder under the filesystem, Userdata.img includes some user data and is mounted to the Data folder under the file system.

In addition to the Android source code after the root, System, data three folders, in fact, the above three IMG decompression after the content, the root folder inside the content is ramdisk.img extracted content, that is, a file system, including systems, Data, bin, Dev and other directories. The system and data correspond to the contents of system.img and userdata.img after decompression.

Just verify it, copy ramdisk.img to any other directory, change its name to ramdisk.img.gz, and use the command

[Java]View PlainCopy  
    1. Gunzip ramdisk.img.gz

Then create a new folder named RAMDisk, go to the RAMDisk directory, enter the command

[HTML]View PlainCopy 
    1. <pre name="code" class="java">cpio-i-F. /ramdisk.img

This way, you can see that the contents of RAMDisk are the same as the root folder. Then copy the files from the system and UserData generated by the Android source code to Ramdisk/system and Ramdisk/userdata. This gives you a complete file system.

=====================================================================================================

attached: Android file System (ROOTFS)(reproduced below)

Structure of the Android file system root directory

Structure of the Android file system root directory:

[Java]View PlainCopy 
  1. DRWXRWXRWT root root 2009-06- :sqlite_stmt_journals
  2. DRWXRWX---system cache 2008-09- :Wuyi cache
  3. D---rwxrwx system system 1970-01- :xx sdcard
  4. lrwxrwxrwx root root 2009-06- : One,etc,/system/etc
  5. Drwxr-xr-x root root 2008-09- :system
  6. Drwxr-xr-x root root 1970-01- :xx sys
  7. Drwxr-x---root root 1970-01- :xx sbin
  8. -rw-r--r--root root 117 1970-01- :xx runme.sh
  9. Dr-xr-xr-x root root 1970-01- :xx proc
  10. -rwxr-x---root root 1704 1970-01- :xx init.trout.rc
  11. -rwxr-x---root root 9329 1970-01- :xx init.rc
  12. -rwxr-x---root root 1677 1970-01- :xx init.goldfish.rc
  13. -rwxr-x---root root 106636 1970-01- :init
  14. -rw-r--r--root root 118 1970-01- :xx default.prop
  15. Drwxrwx--x System System 2008-09- :wuyi data
  16. drwx------root root 2009-06- :root
  17. Drwxr-xr-x root root 2009-06- :dev


sqlite_stmt_journals: A Tmpfs file system in a root directory that holds temporary file data.

Cache: is the cache temp folder, which is said to be useless except for T-mobile's OTA update.
SDcard: Is the directory mounted on the FAT32 file system in the SD card
etc: Point to/system/etc, well-known configuration file directory

System: It's a very important directory, and most of the stuff is here.

sys : Used to mount the Sysfs file system. In the device model, the Sysfs file system is used to represent the structure of the device. The image of the hierarchy of the device is reflected in the user space. User space can modify the properties of a device by modifying the file properties in the Sysfs sbin: Only one ADBD program for debugging is placed.

proc/procVarious files under the file system provide system information that is not specific to a particular process, but can be used throughout the system-wide context.
Data: Store user-installed software and various data.
Root: Nothing at all.

Dev : Needless to say, the place where the device node files are stored.

The following documents are not directories:

runme.sh script for automatic mount action of EXT2 file system in SD card.
INIT.TROUT.RC,INIT.RC,INIT.GOLDFISH.RC is the initialization file.
Init is the first program that runs when the system boots to the file system.


From the root of the above analysis, the Android root file system is not a standard Linux file system, so you have to carefully analyze the startup process in order to understand the Android system.
Today to analyze the structure of the Android file system's/system directory.

Highlight the/system catalogue

The/system directory is an important location in the Android file system, and basically all the tools and applications are in this directory and I seem to be a real rootfs. He is stored in Nandflash's mtd3 in Android phones and is a YAFFS2 file system that is mounted in Root's/system directory at startup and contains:

The following is an analysis of each of these directories:

[Java]View PlainCopy  
  1. # ls-a-l/system
  2. Drwxr-xr-x Root 208 1970-01- :xx xbin
  3. Drwxr-xr-x root root 1970-01- :xx modules
  4. Drwxr-xr-x root root 2008-08- : Theframework
  5. Drwxr-xr-x root root 2008-08- :fonts
  6. Drwxr-xr-x root root 2008-08- :xx etc
  7. -rw-r--r--root root 2197 2008-08- :xx build.prop
  8. Drwxr-xr-x root root 2008-08- :xx media
  9. Drwxr-xr-x root Shell 2008-08- :xx bin
  10. Drwxr-xr-x root root 2008-08- :usr
  11. Drwxr-xr-x root root 2008-08- :app
  12. Drwxr-xr-x root root 2008-09- :lost+found
  13. Drwxr-xr-x root root 2008-08- :lib
  14. Drwxr-xr-x root root 2008-08- :xx sd
  15. -rw-r--r--root root 145 2008-08- :xx init.rc




XBin: A number of system management tools have been delegated, which are not links to toolbox, each of which is an executable program. If you see these commands you will find that they are not used at all, they are prepared for the system administrator, are some system management and configuration tools. This folder is equivalent to/sbin in the standard Linux file system. My mobile phone This directory has busybox, must be changed, should be added by the cracker.
Modules: The place where the kernel modules (primarily FS and net) and module configuration files are to be stored.
Framework: Some of the core files of the Java platform, which belong to the Java Platform System framework file. The files inside are. jar and. odex files.
Note: What is a Odex file? Odex is an optimized Java program file, usually about 4 times times the size of the. jar. Execution efficiency is higher than. jar.
Fonts: Obviously, this is the directory where the font library files are stored.
etc: This stores almost all of the configuration files in the system, and/etc in the root directory is linked here.
Build.prop: is a property file in the Android system. The. prop file is important, recording the system settings and changes, similar to the files in/etc.
Media: The main inside of the system is the ringtone, divided into notifications (notification), UI (interface), alarms (warning) and ringtones (ringtone), inside are. ogg audio files.
bin: It is well known that the user-used tools are stored, most of which are links to toolbox (similar to BusyBox in embedded Linux). Toolbox should be the BusyBox of Google Lite, and I haven't studied it in depth.
usr: User profiles, such as keyboard layouts, shares, time zone files, and so on. You can take a look at cat.
app: As the name implies, the Java application that comes with the Android system is stored.
Lost+found: Yaffs file system, similar to the Recycle Bin folder, only the Yaffs file system will have.
Lib: Stores almost all shared library (. so) files.
SD: Mount directory for EXT2 partition in SD card
init.rc: An initialization script used to mount/system/modules and/system/xbin as Cramfs to avoid inadvertent damage to the system.

File system architecture for Android

Related Article

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.