上下观古今,起伏千万途。这篇文章主要讲述Android镜像文件ramdisk.img,system.img,userdata.img介绍相关的知识,希望能为你提供帮助。
android 源码编译后,在out目录下生成的三个镜像文件:ramdisk.img,system.img,userdata.img以及它们对应的目录树root,system,data。
ramdisk.img是根文件系统,system.img包括了主要的包、库等文件,userdata.img包括了一些用户数据,android加载这3个映像文件后,会把 system和 userdata分别加载到 ramdisk文件系统中的system和 data目录下。
Ramdisk镜像是采用cpio打包,gzip压缩的。它是对root目录的打包和压缩,ramdisk根文件系统中包含一些对于启动android的很重要的文件,比如内核启动完后加载的第一个进程init、一些重要的配置文件等,总之它控制着整个android的启动。根据 init.rc,init.goldfish.rc来初始化并装载系统库、程序等直到开机完成。
init.rc脚本包括了文件系统初始化、装载的许多过程。init.rc的工作主要是:
1)设置一些环境变量
2)创建system、sdcard、data、cache等目录
3)把一些文件系统mount到一些目录去,如,mount tmpfs tmpfs /sqlite_stmt_journals
4)设置一些文件的用户群组、权限
5)设置一些线程参数
6)设置TCP缓存大
system.img userdata.img这两个镜像都属于yaffs2文件格式。
system.img文件是system目录的一个映像,类似于linux的根文件系统的映像,放着android的应用程序,配置文件,字体等。
android启动时首先加载ramdisk.img镜像,并挂载到/目录下,并进行了一系列的初始化动作,包括创建各种需要的目录,初始化console,开启服务等。System.img是在init.rc中指定一些脚本命令,通过init.c进行解析并挂载到根目录下的/system目录下的。
system/app这个里面主要存放的是常规下载的应用程序,可以看到都是以APK格式结尾的文件。在这个文件夹下的程序为系统默认的组件,自己安装的软件将不会出现在这里,而是/data/文件夹中。
system/bin这个目录下的文件都是系统的本地程序,从bin文件夹名称可以看出是binary二进制的程序,里面主要是Linux系统自带的组件。 system/etc从文件夹名称来看保存的都是系统的配置文件,比如APN接入点设置等核心配置。
system/fonts字体文件夹,除了标准字体和粗体、斜体外可以看到文件体积最大的可能是中文字库,或一些unicode字库。
system/framework主要是一些核心的文件,从后缀名为jar可以看出是是系统平台框架。
system/liblib目录中存放的主要是系统底层库,如平台运行时库。
system/media铃声音乐文件夹,除了常规的铃声外还有一些系统提示事件音
system/usr用户文件夹,包含共享、键盘布局、时间区域文件等。
userdata.img是Android系统中存放用户数据的,它被init进程通过解析init.rc文件mount到/data/目录下,默认里面是没有文件的。
cache.img,mount在/cache目录下。
各个镜像生成配置可以查看\build\core\Makefile文件。
如下为高通平台Android社保分区表详细解析:
【Android镜像文件ramdisk.img,system.img,userdata.img介绍】
Label
Purpose of this partition
-----------------------------------------------------
ModemPartition for modem
FscCookie partition to store Modem File System’s cookies.
SsdPartition for ssd diag module. stores the encrypted RSA keys
sbl1Partition for secondary boot loader
sbl1bakBack up Partition for secondary boot loader
RpmPartition for rpm image
RpmbakBack upPartition for rpm image
TzPartition for tz image
tzbakBack upPartition for tz image
HypPartition for hypervisor image
hypbakBack upPartition for hypervisor image
DspPartition for adsp dymanic loaders image
modemst1Copy of Modem File System (Encrypted)
modemst2Copy of Modem File System (Encrypted)
DDRPartition for DDR.
FsgGolden copy or backup of Modem File System (Encrypted). Also used to pre-populate the file system.
SecSec.dat contains fuse settings, mainly for secure boot and oem setting
splashThe splash screen is displayed during the apps bootloader (also called the LK). The display driver in LK will read the splash image data from a separate eMMC partition named as ’splash’
abootPartition for apps boot loader
abootbakBack up Partition for apps boot loader
bootThis is the boot partition of your android device,It includes the android kernel and the ramdisk.
recoveryThis is specially designed for backup. The recovery partition can be considered as an alternative boot partition
devinfoDevice information including:iis_unlocked, is_tampered, is_verified, charger_screen_enabled, display_panel, bootloader_version, radio_version
All these attirbutes are set based on some specific conditions and written on devinfo partition,.
systemThis 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
cacheThis is the partition where Android stores frequently accessed data and app components
persistPartition entry for persist image. which contains data which shouldn’t be changed after the device shipped, for example: calibration data of chips(wifi, bt, camera, etc.), certificates and other security related files.
miscThis 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
keystorePartition for keystore service.
configPartition needed during display panel initialization. More info at Display_panel_configuration_in_Device_Tree
oem"It is meant for storing OEM specific info. Customer in this case can decide whether he wants to keep this partition or not typically reserved partitions are kept for future use
limitsPartition to store LMh params on 8976 target. LMh (Limits management) driver in SBL writes the LMh HW trimmed data into separate partition
and uses the same data for later reboots
motaBackup partition for M ota upgrade
devcfgPartition needed by TZ for M upgrades.
DipPartition needed forSafeSwitch, feature (FR26255) designed to allow OEMs and carriers to address new smartphone theft bill issues.
mdtpPartition needed forSafeSwitch, feature (FR26255) designed to allow OEMs and carriers to address new smartphone theft bill issues.
userdataPartition for userdata image
cmnlibVerified boot feature introduced in M needLK to load cmnlib corresponding partitions
keymasterVerified boot feature introduced in M needs LK to load keymaster from corresponding partitions
syscfgSyscfg is internal testing for Vmin and CPRcharacterization
mcfgAll MBNs place holder in flash. Specific MBN would be loaded by mcfg image based on the SIM/Carrier.
msadpused for modem debug policy
apdpused for persisting the debug policy. "Debug policy" is used to better support development and debug on secure/fuse-blown devices One instance of the debug policy will be signed for the AP
dpoThis partition will store a policy override
推荐阅读
- 源码分析篇 - Android绘制流程requestLayout()与invalidate()流程分析
- Android SDK eclipse开发工具全套离线下载
- Android进程保活-自“裁”或者耍流氓
- AndroidStudio 入门——001android基本细节
- Android 调用系统功能实现图片选择器,你可能会遇到的问题汇总
- Android图片加载框架最全解析,Glide的基本用法
- Android 教你打造独一无二的刷新加载框架
- 使用Tkinter创建多重选择
- 算法(创建一个具有左-子-右-兄弟表示的树)