Android File Hierarchy : System Structure Architecture Layout
Most of the Android user are using their Android phone just for calls, SMS, browsing and basic apps,
But form the development prospective, we should know about Android internal structure.
Android uses several partitions (like boot, system, recovery,data etc) to organize files and folders on the device just like Windows OS.
Each of these partitions has it’s own functionality, But most of us don’t know the significance of each partition and its contents.
In this article, we will take you on a tour of Android partitions.
So lets start the android file system tutorial.
There are mainly 6 partitions in Android phones, tablets and other Android devices.
Below is the list of partition for Android File System.
Note that there might be some other partitions available, it differs from Model to Model.
But logically below 6 partitions can be found in any Android devices.
- /boot
 - /system
 - /recovery
 - /data
 - /cache
 - /misc
 

Also Below are the for SD Card Fie System Partitions.
- /sdcard
 - /sd-ext
 
Please Note:
Only /sdcard partition can be found in all Android devices and the rest are present only in select devices.
Know Your Android Device Partition Size using adb Command
You can know which partitions are available along with the partition size for all partition in your android device.
Go through the below image and run the adb command as shown in that image.
For more adb commands, you can read my atricle Useful adb Commands for Android Development.
Also for more details for android architecture, you can read my article Android Architecture.

Note:
boot and recovery partition is not displayed in the above image.
So after adb shell, you need to run mount command. like
cat proc/mounts
/boot
This is the boot partition of your Android device, as the name suggests.
It includes the android kernel and the ramdisk.
The device will not boot without this partition.
Wiping this partition from recovery should only be done if absolutely required and once done, 
the device must NOT be rebooted before installing a new one, 
which can be done by installing a ROM that includes a /boot partition.
/system
As the name suggests, this partition contains the entire Android OS, other than the kernel and the ramdisk.
This includes the Android GUI and all the system applications that come pre-installed on the device.
Wiping this partition will remove Android from the device without rendering it unbootable, 
and you will still be able to put the phone into recovery or bootloader mode to install a new ROM.
/recovery
This is specially designed for backup.
The recovery partition can be considered as an alternative boot partition, 
that lets the device boot into a recovery console for performing advanced recovery and maintenance operations on it.
/data
Again as the name suggest, it is called userdata partition.
This partition contains the user’s data like your contacts, sms, settings and all android applications that you have installed.
While you perform factory reset on your device, this partition will be wiped out, 
Then your device will be in the state, when you used for the first time or the way it was after the last official or custom ROM installation.
/cache
I hope you have some idea about cache, as you are expert on internet browsing.
This is the partition where Android stores frequently accessed data and app components.
Wiping the cache doesn’t effect your personal data but simply gets rid of the existing data there, 
which gets automatically rebuilt as you continue using the device.
/misc
This partition contains miscellaneous system settings in form of on/off switches.
These settings may include CID (Carrier or Region ID), USB configuration and certain hardware settings etc. 
This is an important partition and if it is corrupt or missing, several of the device’s features will will not function normally.
/sdcard
This is not a partition on the internal memory of the device but rather the SD card.
In terms of usage, this is your storage space to use as you see fit, to store your media, documents, ROMs etc. on it.
Wiping it is perfectly safe as long as you backup all the data you require from it, to your computer first.
Though several user-installed apps save their data and settings on the SD card and wiping this partition will make you lose all that data.
On devices with both an internal and an external SD card – devices like the Samsung Galaxy S and several tablets – 
the /sdcard partition is always used to refer to the internal SD card.
For the external SD card – if present – an alternative partition is used, which differs from device to device. 
In case of Samsung Galaxy S series devices, it is /sdcard/sd while in many other devices, it is /sdcard2.
Unlike /sdcard, no system or app data whatsoever is stored automatically on this external SD card 
and everything present on it has been added there by the user.
You can safely wipe it after backing up any data from it that you need to save.
/sd-ext
This is not a standard Android partition, but has become popular in the custom ROM scene.
It is basically an additional partition on your SD card that acts as the /data partition 
when used with certain ROMs that have special features called APP2SD+ or data2ext enabled.
It is especially useful on devices with little internal memory allotted to the /data partition.
Thus, users who want to install more programs than the internal memory allows can make this partition 
and use it with a custom ROM that supports this feature, to get additional storage for installing their apps.
Wiping this partition is essentially the same as wiping the /data partition – you lose your contacts, SMS, market apps and settings.
Now when you install a new binary, you can know what you’re going to loose, make sure to backup your data before flash new binary in your android device.
I hope this small tutorial will help you at it’s best. If you have nay query or comments, please share with us, we will get back to you asap.
Understanding the Android File Hierarchy
A search of the Internet reveals very little about the Android file hierarchy.
For Windows users, it is another world.
For Linux users, it is a variation of the Linux file hierarchy.
In Linux / Android / Unix (for simplicity, referred to a just Linux), the file hierarchy is a single tree,
with the top of the tree being "/" - the root of the tree.
Under "/" are files and directories.
The Linux file hierarchy lacks the concept of drives, as in Windows.
Instead, file systems are mounted on a directory to create a single integrated tree.
For media based file systems. the file system represents a partition of some media.
It makes no difference whether the file system exists on the local device, or on a remote device.
Everything is integrated into a single file hierarchy that begins with root.
The term path refers to the path to a file or directory.
The absolute path to any file or directory begins with "/" - root.
For example, your file application may show the the path to the internal flash drive as /mnt/sdcard, or simply "sdcard."
If your Android device includes an external SD Card, you will also see/mnt/extSdCard.
The actual names may vary, but the concept remains the same.
For example, CyanogenMod mounts the external flash drive appears on/mnt/sdcard, and the internal flash as /mnt/emmc.
The important point to remember is that each of these directories represents a mount point for a file system.
As a normal user, an Android file only displays the file systems to which you have access.
These file systems are just a part of the entire file hierarchy.
To see the complete Android file hierarchy, you need "root" access.
In this case, "root" refers to a special user account that has system administration privileges.
When you "root" a Android device, you are gaining access to the root account.
There is a reason for not automatically granting root access - one tiny mistake can go a long way.
However, for those experienced in Linux commands and Linux system administration, it opens the hood to the underlying structure of Android.
Android File Systems
As mentioned in Android Kernel versus the Linux Kernel, Android uses the Linux kernel.
All file, and directory, operations from an application flow through a kernel abstract layer called the Virtual File System (VFS).
Each file system, and there are a lot of them, are implementations of VFS.
Each file system has a separate kernel module that registers the operations that it supports with VFS.
By separating the implementation from the abstraction, adding a new file system becomes a matter of writing another kernel module.
These modules are either part of the kernel, or are dynamically loaded on demand.
The Android kernel comes with a subset of the vast collection of file systems that range 
from the Journal File System (JFS) for AIX (IBM's flavor of Unix) to the Amiga file system.
All the fancy footwork is hidden from the user, as the kernel handles all the work when it mounts a file system.
The kernel configuration file determines what file system modules are compiled, and whether they are built into the kernel, or dynamically loaded.
Consequently, the Android kernel only contains those file system modules that are relevant to its operation.
In fact, I don't know of a single Linux distribution that compiles every file system module, as some of the file systems are hardware architecture dependent.
While the supported file systems vary on different Android devices, the common flash memory file systems are as follows:
- exFAT - The extended File Allocation Table is a Microsoft proprietary file system for flash memory. 
Due to the licensing requirements, it is not part of the standard Linux kernel.
However, some manufactures provide Android support for the file system. - F2FS - Samsung introduced The Flash-Friendly File System as an open source Linux file system in 2012.
 - JFFS2 - The Journal Flash File System version 2 is the default flash file system for the AOSP (Android Open Source Project) kernels, 
since Ice Cream Sandwich. JFFS2 is a replacement to the original JFFS. - YAFFS2 - Yet Another Flash File System version 2 was the default AOSP flash file system for kernel version 2.6.32. 
YAFFS2 is not supported in the newer kernel versions, and does not appear in the source tree for the latest kernel versions from kernel.org.
However, individual mobile device vendors may continue to support YAFFS2. 
Besides flash memory file systems, Android devices typically support the following media-based file systems:
- EXT2 / EXT3 / EXT4 - The EXTended file system is the standard Linux file system, with EXT4 being the current version. 
Since 2010, EXT4 is often used in place of YAFFS2 or JFFS2 as the file system for internal flash memory on Android devices. - MSDOS - The MSDOS driver supports the FAT12, FAT16 and FAT32 file systems.
 - VFAT - The VFAT is not actually a file system, but an extension to the FAT12, FAT16, and FAT32 file systems. 
Thus, you will always see the VFAT kernel module in conjunction with the MSDOS module.
External SD Cards are commonly formatted using VFAT. 
The above file systems are media-based file systems. 
VFS also supports pseudo file systems, which are not media based. 
The Linux kernel supports a number of pseudo file systems, the ones that are important to Android devices are:
- cgroup - The cgroup (control group) pseudo file system provides a means to access, and define, various kernel parameters. 
While cgroup is the pseudo file system, there are a number of different process control groups.
If your Adroid device supports process control groups, you will find a list of the groups in the file
/proc/cgroups. Android uses cgroups for acct (user accounting), and cpuctl (CPU control). - rootfs - This file system serves as the mount point for the root file system ("/").
 - procfs - The procfs file system is normally mounted on the /proc directory, and reflects a number of kernel data structures. 
The operations on these files actually read live kernel data.
The number directories reflect the process IDs (actually, the thread group leader process ID) for each running task.
The /proc/filesystems file generates a list of the currently registered file systems.
File systems followed by NODEV are pseudo file systems, as there is no related device.
The /proc/sys directory contains kernel parameters, some of which are tunable. - sysfs - The device model for the kernel is an object-oriented structure that reflects the devices known 
by the kernel through the sysfs file system, which is normally mounted on the /sys directory.
When a kernel discovers a new device, it builds an object in the /sys/devices directory.
The kernel uses a network socket to communicate the new device information to the udevd daemon,
which builds an entry in the /dev directory.
The /sys/fs directory contains the kernel object structures for media based file systems.
The /sys/module directory contains objects for each loaded kernel module. - tmpfs - The tmpfs file system is often mounted on the /dev directory. 
Since it is a pseudo file system, any data in the /dev directory is lost when the device is rebooted. 
While there seems like a lot of file systems, they are just the tip of the iceberg.
For those without root access, these file systems and directories are hidden from your view, as you do not have the permission to access them.
My Samsung Galaxy SIII provides a USB debugging option under Developer options in theSettings menu.
When enabled this option allows one to connect to the Samsung Galaxy SIII using adb (Android Debug Bridge).
While it only provides user level privileges, it does provide access to most directories and most of the Linux commands.
This option may be available on other Samsung Android devices.
You can also try the Terminal Emulator app. It works on my Samsung Galaxy SIII, as well as my B&N Nook Color running CyanogenMod 10 (Jelly Bean).
Android File Hierarchy
As mentioned above, the Android file hierarchy is a modified version of the traditional Linux file hierarchy.
There are slight variations in the structure across the different version of Linux, and from different manufacturers.
However, the variations are slight.
The following gives a brief summary of the top levels of the directory structure for the AOSP release of Jelly Bean:
- acct - This directory is the mount point for the acct cgroup (control group), which provides for user accounting.
 - cache - The mount point for the /dev/block/mtdblock2 partition (the partition name may vary). 
The size of the cache is limited to the size of this partition. - d - A symbolic link to /sys/kernel/debug.
 - data - The mount point for the /dev/block/mtdblock1 partition.
 - default.prop - This file defines various default properties.
 - dev - The mount point for a tmpfs file system, which defines the devices available to applications. 
The /dev/cpuctl directory is the mount point for cpuctl control group, using the cgroup pseudo file system. - etc - A symbolic link to /system/etc.
 - init - A binary program that processes the init.rc file. 
The init.rc file imports the other init.*.rc files.
When booting Android, the kernel executes the init program at the end of its boot process.
It is worth reading the init.rc file, as it tells the story of the configuration for the Android device.
Since Android does not support /etc/sysctl.conf, the updates to the /proc/sys/kernel parameters are part of the init.rc file.
Unless you have a good understanding of the internal workings of the Linux kernel, you should not modify these parameters.
The same is true of the /dev/cpuctl parameters. - mnt - Besides the mounts for the internal and external SD cards, these directory serves as a mount point for other file systems. 
The /mnt/asec directory is a mount point for a tmpfs file system, and is part of Android security.
The /mnt/obb directory is a mount point for the tmpfs file system, and stores expansion files for applications whose files exceed 50MB.
The /mnt/secure directory is another component of Android security. You may also see mount points for one, or more, USB devices. - proc - Mount point for the procfs file system, which provides access to kernel data structures. 
Programs, such as ps, lsof, and vmstat, use the /proc as the source for their information. - root - The home directory for the root account.
 - sbin - While much smaller than the /sbin directory in a standard Linux distributions, it does contain the binaries for several important daemons.
 - sdcard - A symbolic link to /mnt/sdcard.
 - sys - The mount point for the sysfs pseudo file system, which is a reflection of the kernel's device object structure. 
There is a lot of information in this directory, but it does require understanding of the kernel device model.
In a nutshell, the directories represent kernel objects, and files are attributes of those objects. - system - This directory is the mount point for the /dev/block/mtdblock0. 
Under this directory are the directories that you normally see under the root directory of a standard Linux distribution.
These directories include bin, etc, lib, usr, and xbin. - ueventd.goldfish.rc ueventd.rc - These files define the configuration rules for the /dev directory.
 - vendor - A symbolic link to /system/vendor.
 
The above is just a thumbnail sketch of the Android file structure.
To understand the workings of Android beneath the desktop, you need a fundamental knowledge of Linux, and the Linux command-line.
For kernel parameters, you need a working knowledge of the Linux kernel. In future articles, I shall explore the Android file hierarchy in more detail.
Android File Hierarchy : System Structure Architecture Layout的更多相关文章
- Android Studio导入System Library步骤
		
转载请注明出处:http://www.cnblogs.com/cnwutianhao/p/6242170.html 请尊重知识产权!!! 同步更新到CSDN:http://blog.csdn.net ...
 - Android权限说明 system权限 root权限
		
原文链接:http://blog.csdn.net/rockwupj/article/details/8618655 Android权限说明 Android系统是运行在Linux内核上的,Androi ...
 - [Android开发学iOS系列] Auto Layout
		
[Android开发学iOS系列] Auto Layout 内容: 介绍什么是Auto Layout. 基本使用方法 在代码中写约束的方法 Auto Layout的原理 尺寸和优先级 Auto Lay ...
 - Android工具 Hierarchy Viewer 分析
		
Hierarchy Viewer是随AndroidSDK发布的工具,位置在tools文件夹下,名为hierarchyviewer.bat.它是Android自带的非常有用而且使用简单的工具,可以帮助我 ...
 - 关于Android file.createNewFile() 方法出现的问题总结(转)
		
原文:http://blog.csdn.net/wjdarwin/article/details/7108606 今天在编写向SDcard中,创建文件夹并向其中保存文件的过程中出现个一系列的问题 在此 ...
 - OS X 禁止Android File Transfer自动启动
		
操作步骤 关闭Android File Manager 在Activity Manager中退出Android File Manager Agent进程 在Applications中,将Android ...
 - 【ZBar】ios错误ignoring file xxx missing required architecture x86_64 in file
		
解决方法: 1.在Project target里"Architectures"设置为:Standard (armv7,armv7s)或者 Standard (armv7,arm6 ...
 - 关于Android file.createNewFile() 失败的问题
		
[关于Android file.createNewFile() 失败的问题] 需要注意的是:要先对设计的文件路径创建文件夹 , 然后在对文件进行创建. 参考:http://blog.csdn.net/ ...
 - Android File Transfer
		
about a question in developing.. When you run app and created a file of db,but Android File Transfer ...
 
随机推荐
- 读书笔记--C陷阱与缺陷(三)
			
第三章 1. 指针与数组 书中强调C中数组注意的两点: 1) C语言只有一维数组,但是数组元素可以是任何类型对象,是另外一个数组时就产生了二维数组.数组大小是常数(但GCC实现了变长数组..) ...
 - 练习题 --- 10种Xpath定位
			
写出10种不同的Xpath定位语法
 - Failed to create the Java Virtual Machine
			
启动Zend Studio时出现Failed to create the Java VIrtual Machine 解决办法如下.打开安装目录下的ZendStudio.ini配置文件,作如下修改: 说 ...
 - Jmeter和LR上传文件和下载
			
Jmeter和LR上传文件和下载 背景: 在某个申请业务中,需要上传附件文件,然后才能提交该申请 遇到的问题: 1, 在使用Jmeter或者LR进行录制时,无法录制到上传文件的请求,只能通过Fidd ...
 - Mysql安装(绿色版安装)
			
一:下载 1.官网 https://dev.mysql.com/ 2.下载 3.下载 二:安装 1.将官网上下载的包进行解压 2.以管理员的身份运行DOS安装 进入mysql的bin目录 运行mysq ...
 - JSP的学习二(请求转发与 重定向)
			
一: 1.介绍知识点 1). 本质区别: 请求的转发只发出了一次请求, 而重定向则发出了两次请求. 具体: ①. 请求的转发: 地址栏是初次发出请求的地址. 请求的重定向: 地址栏不再是初次发出的请 ...
 - thinkphp中导入和使用阿里云OSSsdk
			
照做绝对行,在ThinkPHP中,第三方库都放在ThinkPHP/Library/Vendor/路径下. 1.下载OSS PHP SDK:https://help.aliyun.com/documen ...
 - 传递 hdu 5961 拓扑排序有无环~
			
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5961 题目为中文,这里就不描述题意了. 思路: 从题目陈述来看,他将一个有向图用一个邻接矩阵来表示,并且分 ...
 - MOD 10,11算法(GB/T 17710-1999 数据处理 校验码系统 )的 Python实现
			
以上是算法简要说明,以下代码为Python实现,不过注意代码中的N=15,不是16. # GB/T 17710 双模校验算法 # QQ 3257132998 def GB_Code(str): str ...
 - Xamarin无法调试Android项目
			
Xamarin无法调试Android项目 项目可以正常编译,生成APK,也可以通过右键菜单部署.但是一旦开启调试,就报错.错误信息如下: 没有为此解决方案配置选中要生成的项目 出现这种问题是因 ...