Android 源碼編譯後,在out目錄下生成的三個鏡像文件:ramdisk.img,system.img,userdata.img以及它們對應的目錄樹root,system,data。linux
ramdisk.img是根文件系統,system.img包括了主要的包、庫等文件,userdata.img包括了一些用戶數據,android加載這3個映像文件後,會把 system和 userdata分別加載到 ramdisk文件系統中的system和 data目錄下。android
Ramdisk鏡像是採用cpio打包,gzip壓縮的。它是對root目錄的打包和壓縮,ramdisk根文件系統中包含一些對於啓動android的很重要的文件,好比內核啓動完後加載的第一個進程init、一些重要的配置文件等,總之它控制着整個android的啓動。根據 init.rc,init.goldfish.rc來初始化並裝載系統庫、程序等直到開機完成。sql
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文件格式。cookie
system.img文件是system目錄的一個映像,相似於linux的根文件系統的映像,放着android的應用程序,配置文件,字體等。app
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 用戶文件夾,包含共享、鍵盤佈局、時間區域文件等。 ide
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