Android: Quickly modify the ramdisk. IMG script

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.