eMMC is mainly used for embedded memory for products such as mobile phones and tablets. Because it integrates a controller in the package, provides standard interfaces and manages flash memory, it is becoming increasingly popular among Android mobile phone manufacturers. Android phones with eMMC as storage devices have file systems (system, data partitions) generally use ext4 format. For example, the cable brush bag of Xiaomi mobile phone:
1.img unpacking
I have previously introduced using the rom assistant to unpack when modifying Xiaomi desktop.
Here is another more convenient and practical tool: ext4_unpacker for Windows platform.
Directly select the img image file that needs to be decompressed, and then extract all files. Similarly, after decompression, rom can be simplified and some unwanted apps can be deleted.
Two.img package
Here, make_ext4fs is used to package the decompressed file.
Instructions for use: Copy the downloaded make_ext4fs.exe to the C:\WINDOWS directory, and copy the other dll files to the C:\Windows\System32 directory.
Main parameters description:
-l <limit size>: Indicates the maximum file size, limited by the size of the system or data partition.
-a <system/data>: represents the mount point of Android, hang the img file system under the system/data folder of the Android phone.
-S file_contexts: indicates that sepolicy's file_contexts. The file_contexts file exists in the Android system 5.0 and above. This file is an explanation of the selinux file system and can be found in the root directory of the mobile phone.
-s: means to compress the img file, remove the blank part of the img file system, and obtain the real size of the data file space occupied.
-T: represents the Unix timestamp, set the modification time for the img file, and can be converted at the webmaster's home.
<filename>: indicates the output file name.
<directory>: represents the file directory entered.
Additional Notes:
1) - The limit size unit in l <limit size> is M. The size of this value is limited by the partition size. If the mirror size produced is greater than this value, it will prompt that it will fail. The size of the partition can be obtained by the df command.
2) Use the pull command to extract the file_contexts file in the phone
First check whether there is a file_contexts file in the system, and then pull out the file.
OK, now we can package the file.
make_ext4fs -S file_contexts -s -l 3072M -a system ./system
3. Batch scripts to quickly customize rom packages
Maybe those who have done rom know:
1. For mobile phones in 4.4 system, if you want to enter the apk to the system area, you just need to copy the apk to the system/app, and copy the lib file (.so file) of the corresponding apk to the system/lib; if you want to enter the apk to the userdata area, you just need to copy the apk to the userdata/app.
2. For mobile phones with 5.0 and above, if you want to enter the apk to the system area, you need to build the apk and the corresponding lib files in the same directory, and then copy it to system/app (see the directory formats of other apks under system/app for details). Moreover, in practice, some mobile phones need to enter the apk in system/framework to run normally, otherwise it will crash; if you need to enter the apk to the userdata area, you only need to copy the apk to the userdata/app.
A few explanations:
1. Since you need to decompress the lib file under apk, and the rar and unrar with winrar do not support the apk format, you use the good decompression function. Just configure the installation directory of the best button to the system path environment. In this way, you can call the HaozipC command on the command line, and there are also command line instructions in the installation directory. You can install it yourself to view it.
2. Since some mobile phones need to enter the system/framework to start normally, add manual selection when batch processing.
3. For the system partition limit size, you can first df and save it in the txt list, so that the script can be read automatically. like:
4. In practice, for systems 5.0 or above, the apk entered into the system area may not contain Chinese names. To avoid frequent changes, you can also create a txt file to allow the script to automatically change. like:
5. For systems 5.0 and above, please first pull the file_contexts file to the current directory.
The batch script is as follows: (Download)
@echo off title custom maderomBag by Little monkeyjerry echo ------------------------------------------------------------------------- echo Notice:请务必输入正确的Android system和底Bag编号,否则做Bag无效 echo Android system(4.4/5.0)、底Bag编号(01wait) echo Android system5.0Please enter it above5.0 echo ------------------------------------------------------------------------- pause set /p version=请输入Android system版本号(4.4/5.0): set /p var=请输入底Bag编号: if exist .\sysApk set /p is_framework=Do you need to enterapkarriveframeworkmiddle(y/n): echo ----------------Please check carefully,If there is any error in input, please close the program and re-enter.----------------- pause if %version%==4.4 ( %打Bagsystem% if exist .\system ( echo 正在制作middle... if exist .\sysApk ( echo Unzipping what is needed.sodocument... for /f "delims=" %%a in ('dir /b/a-d/oN .\sysApk\*.*') do ( HaoZipC x .\sysApk\%%a -o.\syslib lib\armeabi\*.* -y -sn) copy sysApk\*.* system\app move syslib\lib\armeabi\*.* system\lib rd/s/q syslib) for /f "skip=1 tokens=1,2,3" %%i in () do ( if %%i==%var% make_ext4fs -s -l %%j -a system ./ ./system ) echo Production completed) %打Baguserdata% if exist .\userdata ( echo 正在制作middle... if exist .\userApk ( if not exist userdata\app ( md userdata\app ) copy userApk\*.* userdata\app) for /f "skip=1 tokens=1,2,3" %%i in () do ( if %%i==%var% make_ext4fs -s -l %%k -a data ./ ./userdata ) echo Production completed) if not exist .\system ( if not exist .\userdata ( echo 找不arrivesystem or userdatadocument夹,Please copysystemoruserdataarrive当前目录)) %deal withupdatedocument% if not exist .\ ( echo 找不arriveupdatedocument,Please copyarrive当前目录) if exist .\ ( ren HaoZipC d -tzip -ri!images\system images\userdata -sn if not exist .\images ( md .\images ) if exist .\ ( move .\images) if exist .\ ( move .\images) HaoZipC a -tzip .\images\ -sn) ren rd/s/q system rd/s/q userdata rd/s/q images echo custom maderomBagProduction completed!!) rem ========================================================================================================================= if %version%==5.0 ( %premise:从手机middlepullOut of what you needfile_contextsdocument% %打Bagsystem% if exist .\system ( echo 正在制作middle... if exist .\sysApk ( echo Unzipping what is needed.sodocument... for /f "tokens=1,2 delims=." %%a in ('dir /b/a-d/oN .\sysApk\*.*') do ( if %%a==usbhelp ( ren .\sysApk\ md .\syslib\ move .\sysApk\ .\syslib\) for /f "tokens=1,2 delims=:" %%i in () do ( if %%a==%%i ( ren .\sysApk\%% %% HaoZipC x .\sysApk\%% -o.\syslib\%%j lib\armeabi\*.* -y -sn ren .\syslib\%%j\lib\armeabi arm move sysApk\%% syslib\%%j))) if %is_framework%==y ( xcopy/s/y syslib system\framework) else ( xcopy/s/y syslib system\app) rd/s/q syslib) for /f "skip=1 tokens=1,2,3" %%i in () do ( if %%i==%var% make_ext4fs -S file_contexts -s -l %%j -a system ./ ./system) echo Production completed) %打Baguserdata% if exist .\userdata ( echo 正在制作middle... if exist .\userApk ( if not exist userdata\app ( md userdata\app ) move userApk\*.* userdata\app) for /f "skip=1 tokens=1,2,3" %%i in () do ( if %%i==%var% make_ext4fs -S file_contexts -s -l %%k -a data ./ ./userdata) echo Production completed) del file_contexts if not exist .\system ( if not exist .\userdata ( echo 找不arrivesystem or userdatadocument夹,Please copysystemoruserdataarrive当前目录)) %deal withupdatedocument% HaoZipC d -tzip -ri!images\system images\userdata -sn if not exist .\images ( md .\images ) if exist .\ ( move .\images) if exist .\ ( move .\images) HaoZipC a -tzip .\images\ -sn ren rd/s/q system rd/s/q userdata rd/s/q images rd/s/q sysApk rd/s/q userApk echo custom maderomBagProduction completed!!) pause
Notice:
The directory is set as follows:
Run bat:
Through the study of this article, I have reviewed the commonly used command-line commands again. I also hope that the description of this article will be helpful to everyone.