Sometimes we need to modify ramdisk. IMG of Android. If we repeat those commands every time, it is a bit annoying. Is there a quick and easy way? Yes. Put these commands in
Together, a simple script is created:
This script is very simple. Just put the script in the directory with ramdisk. IMG and run it,
During running, input 1 will decompress ramdisk. IMG, and input 2 will re-package the modified ramdisk into ramdisk. IMG.
Root @ o-2rl2:/home/Percy # Cat shell/ramdisk
#! /Bin/bash
Echo "Modify the ramdisk. IMG"
Echo "1. Inflate the image"
Echo "2. Create the image"
Read-P "Choose:" choose
# Case $ {choose} in
#1) inflate ();;
#2) create ();;
# Esac
If ["1" =$ {choose}]; then
Echo "inflate ()"
CP ramdisk. IMG ramdisk.cpio.gz
Gzip-D ramdisk.cpio.gz
[-E "tmp"] | {echo "mkdir tmp"; mkdir TMP ;}
CP ramdisk. cpio tmp/
CD TMP
Cpio-I-f ramdisk. cpio
Elif ["2" =$ {choose}]; then
Echo "CREATE ()"
[-E "tmp"] & amp; {cd tmp; cpio-I-t-f .. /ramdisk. cpio | cpio-o-h NEWC-o .. /ramdisk_new.cpio; echo "create ramdisk_new.cpio finished ";}
Fi
Manually decompress and modify ramdisk. IMG of Android:
Copy ramdisk.imgto another directory, change its name to ramdisk.img.gz, and run the command
Gunzip ramdisk.img.gz
Create a folder named ramdisk.
Cpio-I-f ../ramdisk. img
Now you can see and operate the content in ramdisk.
After you modify the content, you can use the following command to repackage it into an image.
Cpio-I-t-f ../ramdisk. img> List
Cpio-o-h NEWC-o lk. IMG <list
The LK. IMG generated in the current directory is our new image.