- ConvertSparsechunk2Img is designed to assist in converting Android system.img files from sparsechunk format to raw img format, removing certain headers and footers specific to Moto devices in the process.
- CleanMotoImg will simply remove the Motorola headers from a system.img.raw file, if you have already performed sparsechunk conversion
- simg2img - A tool to convert sparse images to raw images.
- ddrescue - A data recovery tool which can copy data from one file or block device to another.
- Bash Shell
-
Clone the Repository: Clone this repository to your local machine or download the script file directly.
git clone https://github.com/FroggMaster/CleanMotoImg.git
-
Navigate to the Directory: Change your current directory to where the script is located.
cd path/to/script/directory
-
Provide Necessary Permissions: If required, provide execution permission to the script.
chmod +x ConvertSparsechunk2Img.sh
-
Execute the Script: Run the script with the following command:
./ConvertSparsechunk2Img.sh
The script performs the following operations:
- Sparsechunk Conversion:
- Utilizes
simg2img
to convert the Android system image from sparsechunk format (system.img_sparsechunk.*
) to raw image format (system.img.raw
).
- Utilizes
- Remove Moto Header:
- Utilizes
ddrescue
to remove the Moto header from the raw image by skipping the first 131072 bytes.
- Utilizes
- Remove Moto Footer:
- Utilizes
ddrescue
to remove the Moto footer from the modified system image by removing the last 4096 bytes.
- Utilizes
- Clean Up:
- Removes intermediate raw image (
system.img.raw
), sparsechunks (*sparsechunk.*
), and renames the final cleaned system image tosystem.img
.
- Removes intermediate raw image (
- This script assumes the presence of
simg2img
andddrescue
in your system's PATH. - Ensure you have sufficient permissions to execute the script and write to the directories where the script operates.
- Always make sure to have backups of your sparsechunks before performing any modifications, they will get deleted once the process completes.
- You obviously need to have sparsechunk files to convert into .img format.
- The resulting img file should be readable VIA 7-zip