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/lib lib目录中存放的主要是系统底层库,如平台运行时库。
system/media 铃声音乐文件夹,除了常规的铃声外还有一些系统提示事件音
system/usr 用户文件夹,包含共享、键盘布局、时间区域文件等。
userdata.img是Android系统中存放用户数据的,它被init进程通过解析init.rc文件mount到/data/目录下,默认里面是没有文件的。
cache.img,mount在/cache目录下。
各个镜像生成配置可以查看\build\core\Makefile文件。
如下为高通平台Android社保分区表详细解析:
Label Purpose of this partition
-----------------------------------------------------
Modem Partition for modem
Fsc Cookie partition to store Modem File System’s cookies.
Ssd Partition for ssd diag module. stores the encrypted RSA keys
sbl1 Partition for secondary boot loader
sbl1bak Back up Partition for secondary boot loader
Rpm Partition for rpm image
Rpmbak Back up Partition for rpm image
Tz Partition for tz image
tzbak Back up Partition for tz image
Hyp Partition for hypervisor image
hypbak Back up Partition for hypervisor image
Dsp Partition for adsp dymanic loaders image
modemst1 Copy of Modem File System (Encrypted)
modemst2 Copy of Modem File System (Encrypted)
DDR Partition for DDR.
Fsg Golden copy or backup of Modem File System (Encrypted). Also used to pre-populate the file system.
Sec Sec.dat contains fuse settings, mainly for secure boot and oem setting
splash The 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’
aboot Partition for apps boot loader
abootbak Back up Partition for apps boot loader
boot This is the boot partition of your android device,It includes the android kernel and the ramdisk.
recovery This is specially designed for backup. The recovery partition can be considered as an alternative boot partition
devinfo Device 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,.
system 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
cache This is the partition where Android stores frequently accessed data and app components
persist Partition 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.
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
keystore Partition for keystore service.
config Partition 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
limits Partition 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
mota Backup partition for M ota upgrade
devcfg Partition needed by TZ for M upgrades.
Dip Partition needed for SafeSwitch, feature (FR26255) designed to allow OEMs and carriers to address new smartphone theft bill issues.
mdtp Partition needed for SafeSwitch, feature (FR26255) designed to allow OEMs and carriers to address new smartphone theft bill issues.
userdata Partition for userdata image
cmnlib Verified boot feature introduced in M needLK to load cmnlib corresponding partitions
keymaster Verified boot feature introduced in M needs LK to load keymaster from corresponding partitions
syscfg Syscfg is internal testing for Vmin and CPR characterization
mcfg All MBNs place holder in flash. Specific MBN would be loaded by mcfg image based on the SIM/Carrier.
msadp used for modem debug policy
apdp used 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
dpo This partition will store a policy override