We have to perform the following steps to edit your init.rc successfully:
 
.      Download the BOOT (RamDisk) image from your Android device
. Extract the boot image into RAMDISK and kernel
. Extract the RAMDISK to get your edit init.rc to be modify
. Edit the init.rc file
. Re-Pack the RAMDISK
. Re-pack the BOOT image with RAMDISK and kernel
. Flash the BOOT image into your device
. Restart and now your device running with your edited init.rc file
 
Requirements for perform this tasks :
 
1.       UBUNTU OS above 10.04 version ( if you are using windows machine you can use virtual Ubuntu OS like VMware, etc.)
2.       Andorid SDK for ADB connection
3.       Extract tools for extract the BOOT image and repack BOOT image.
 
Let we see detailed procedure of each steps,
 
1.Download the BOOT image from your Android device:
 
                Basically Android device have three types of partitions these are NAND, mtd, and mmcblck.
Reputed brand devices have NAND and mtd, some China brand device have mmcblk, which means OS stored in mmc (memory card) card. But in the memory card you can’t find the init.rc file and you can see other files except init.rc  if you takeout the mmc and connect to your PC over card reader.
                Let’s start the operation, connect your device with PC( windows or Ubuntu)  and check whether its discoverable by ADB or not.  Change the working directory into android SDK /platform-tools folder then execute
 
                # adb devices
 
If you can see your device, then you can proceed with further steps. If you couldn’t find your device download the ADB USB drivers and install on your PC.
Open the device shell by executing this command
 
                # adb shell
 
Then we have to find what kind of partitions your device have. It can be by this following command
 
                # cat /proc/partitions
 
Then you will get output like this       
      
cat /proc/partitions
major minor #blocks name mtdblock0
mtdblock1
mtdblock2
mtdblock3
mtdblock4
mtdblock5
mtdblock6
mtdblock7
mtdblock8
mtdblock9
mtdblock10
mtdblock11
mtdblock12
mtdblock13

mtdblock shows you that your device contain mtd partitions .

If your device have NAND partitions your will get NANDA, NANDB, NANDC or NAND0, NAND1 etc. like this.

If your device have mmc partitions you will get mmcblk1, mmcblk2, etc.

Our next process is find out where our BOOT image stored among these partitions.
 
If its mtd partitions:
 
 # cat /proc/mtd
dev: size erasesize name
mtd0: 00d00000 "filesystem-SF"
mtd1: "kernel-SF"
mtd2: "u-boot-SF"
mtd3: "u-boot env. cfg. 1-SF"
mtd4: "u-boot env. cfg. 2-SF"
mtd5: "w-load-SF"
mtd6: "logo"
mtd7: "boot"
mtd8: "recovery"
mtd9: "misc"
mtd10: "system"
mtd11: "cache"
mtd12: "data"
mtd13: 17b800000 "LocalDisk"

Hence our boot partition is mtd7, we have to download the BOOT image from that partitions.

 
If its NAND partitions:
 
# cat /proc/mtd
dev: size erasesize name
/boot emmc /dev/block/nandc
/bootloader emmc /dev/block/nanda
/cache ext4 /dev/block/nandh
/data ext4 /dev/block/nande
/emmc vfat /dev/block/nandi
/recovery emmc /dev/block/nandg
/misc emmc /dev/block/nandf
/sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0
/sd-ext auto /dev/block/mmcblk0p2
/system ext4 /dev/block/nandd
 
Hence our boot partition is NANDC, we have to download the BOOT image from this partition.
 
 
Download the image from boot partitions:
 
Execute the following command to pack your boot image.
 
                # cat /dev/block/mtdx > /mnt/sdcard/boot.img
 
x- Replace the x with your boot partition number.
 
In our case this command will be
 
                # cat /dev/block/ mtdblock7  >  /mnt/sdcard/boot.img
               
                # cat /dev/block/ nandc  > /mnt/sdcard/boot.img
 
Now your boot image got ready. you can move this boot.img to your UBUNTU PC  for further action.

Come out from your terminal window and pull the boot.img file to your PC over ADB
 
                # adb pull /mnt/sdcard/boot.img  <PC destination location> 
 
But all devices wouldn’t show this message for this command, Its works for mtd partitions. some devices only show the following information
 
                # cat /proc/mtd
                dev:  size  erasesize  name
 
Hence we need to go for other choice. The other choice is below            
 
                # mount
 
rootfs on / type rootfs (rw)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /mnt/asec type tmpfs (rw,relatime,mode=755,gid=1000)
tmpfs on /mnt/obb type tmpfs (rw,relatime,mode=755,gid=1000)
/dev/block/mmcblk0p5 on /system type ext2 (rw,relatime)
/dev/block/mmcblk0p6 on /data type ext2 (rw,nosuid,nodev,relatime,errors=continu
e)
/dev/block/mmcblk0p7 on /cache type ext2 (rw,nosuid,nodev,relatime,errors=contin
ue)
none on /proc/bus/usb type usbfs (rw,relatime,devmode=666)
/dev/block/vold/179:1 on /mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,r
 
        From the output you can see some partitions name and its file system purpose.  Hence you can omit this partitions because its allotted for filesystem not for boot image. And then we have to try trail and error method. which means you have convert other possible partitions as part1.img, part2.img etc like this. Then we can find which one is boot image while we extracting the boot images by extract tool.
 
 
2.Extract the boot image into RAMDISK and kernel
 
                You can download the extract tools below. In the attachment copy the unmkbootimg file to your boot.img location and execute the following command
 
                # ./unmkbootimg boot.img
 
This command will extract your boot.img into ramdisk and kernel and another one important thing is after extracting you will get the command for recreate the boot.img with this ramdisk and kernel  in terminal so please note it.
 
If you are not using unmkbootimg file for extracting the boot image means you have to do one important work that is, you have to note your boot image BASE address its very important to recreate your boot image with edited init.rc. If you recreate the boot image with wrong BASE address your device won’t get boot So be careful.
 
Now you have ramdisk in your hand 
 
 
3.Extract the RAMDISK to get your edit init.rc to be modify
 
               Now the time for extract your ramdisk to get init.rc. 
According to this do the following things
                create the folder name it as newramdisk
                Inside the newramdisk folder create another folder and name it as oldramdisk.
                Copy your ramdisk into your oldramdisk folder
                Goto the oldramdisk in terminal
                Execute the following commands to extract your ramdisk
 
                # gzip –dc initramfs.cpio.gz | cpio –i
 
                                Now you can find extracted files including init.rc, in same directory. Now you can edit init.rc and other files if you need.
 
4.Re-Pack the RAMDISK
               
                After edit the init.rc you have to re-pack the ramdisk. Execute the following commands to re-pack the ramdisk. Before you giving this command you have to delete your initramfs.cpio.gz  file, because the following command compress the all files inside the folder.
               
                # find . | cpio –o –H newc | gzip > ../initramfs.cpio.gz
 
                This command create your new ramdisk into your newramdisk folder. You can check this in newramdisk location.
 
Now you have new edited ramdisk file in your hand.
 
5.Re-pack the boot image.
 
                Now you have newramdisk + kernel file + command  to create the boot image for your device.
Create the final folder and place the newramdisk and kernel file and change the working directory into this folder. Then you have to give the mkbootimg command to create your boot image.
              Before you giving this command you have to install mkbootimg binary in your UBUNTU host system. This binary is attached with extract tools.
 
                # mkbootimg  --kernel kernel.gz –ramdisk initramfs.cpio.gz –o new_boot.img
 
Note: its just a example command execute the command which one you got while extracting the boot image because that command only generated with your BASE address
 
This command create the boot image to your device with your BASE address.
 
 
6.Flash the BOOT image into your device
 
              Now you have create the boot image with edited init.rc and its ready to flash into your device.
Push the new_boot.img file into your device over ADB
 
              # adb push <source_location/new_boot.img> /mnt/sdcard
 
Then you can see the new_boot.img file into your /mnt/sdcard location
Next step is final step, that is flash the image into your device
 
              # cat /mnt/sdcard/new_boot.img  > /dev/block/nandc
 
Note: nandc is your boot partition, from where you got your boot image. Replace the nandc with your boot partition name.
 
Now you had edited your init.rc then reboot the device. Enjoy with your modified init.rc
 
Attachments: 
Download the Extract Tools..!!
 

If you happen to face any problem during this process feel free to comment here...

If you think its really helpful for you please post your comments here..:)

How to edit the init.rc in android的更多相关文章

  1. Android修改init.rc和init.xx.rc文件【转】

    本文转载自:https://blog.csdn.net/u013686019/article/details/47981249 一.文件简介 init.rc:Android在启动过程中读取的启动脚本文 ...

  2. Android中的 init.rc文件简介

    init.rc脚本是由Android中linux的第一个用户级进程init进行解析的. init.rc 文件并不是普通的配置文件,而是由一种被称为"Android初始化语言"(An ...

  3. Android的init过程(二):初始化语言(init.rc)解析

    Android的init过程(一) 本文使用的软件版本 Android:4.2.2 Linux内核:3.1.10 在上一篇文章中介绍了init的初始化第一阶段,也就是处理各种属性.在本文将会详细分析i ...

  4. Android的init过程(二):初始化语言(init.rc)解析【转】

    转自:http://www.cnblogs.com/nokiaguy/p/3164799.html Android的init过程(一) 本文使用的软件版本 Android:4.2.2 Linux内核: ...

  5. Android 的 init.rc 文件简介【转】

    转自:http://blog.csdn.net/yimiyangguang1314/article/details/6268177 init.rc由许多的Action和Service组成.每一个语句占 ...

  6. Android init.rc解析【转】

    转自:http://www.linuxidc.com/Linux/2014-10/108438.htm 本文主要来自$Android_SOURCE/system/init/readme.txt的翻译. ...

  7. Android init.rc文件格式解析

    /***************************************************************************** * Android init.rc文件格式 ...

  8. init进程 && 解析Android启动脚本init.rc && 修改它使不启动android && init.rc中启动一个sh文件

    Android启动后,系统执行的第一个进程是一个名称为init 的可执行程序.提供了以下的功能:设备管理.解析启动脚本.执行基本的功能.启动各种服务.代码的路径:system/core/init,编译 ...

  9. android init.rc 语法分析

    此文来自于对http://source.android.com/porting/index.html中bring up段的简译.其中有一处与源码的 system/core/init/readme.tx ...

随机推荐

  1. python面向对象(五)之多态

    继承 ​ 在讲多态之前我们再复习下继承,下面是一个例子. ​ Circle 和 Rectangle 继承自 Shape,不同的图形,面积(area)计算方式不同. # shape.py class S ...

  2. 洛谷P2149 Elaxia的路线

    传送门啦 分析: 我最开始想的是跑两遍最短路,然后记录一下最短路走了哪些边(如果有两条最短路就选经过边多的),打上标记.两边之后找两次都标记的边有多少就行了. 但...我并没有实现出来. 最后让我们看 ...

  3. 网络协议之UDP

    前言 TCP协议在不可靠的网络环境上提供了可靠的通信通道,隐藏了大量的底层细节,使应用程序更加简洁.但有些应用并不需要这么高的可靠性,并不需要按序交付,而且TCP为了提高可靠性也增加了延时,在某些对延 ...

  4. 淘宝开放平台TOP SDK调用对接淘宝或天猫

    如果在淘宝/天猫上开了网店,用户自己也有一套自己的管理平台,这时可能会考虑和淘宝进行数据对接.这就需要考虑调用阿里提供的开发接口来推送和接收数据. 对接的方式有2种,一种是通过http接口,另外一种是 ...

  5. UVA 10559 Blocks(区间DP&&递推)

    题目大意:给你玩一个一维版的消灭星星,得分是当前消去的区间的长度的平方,求最大得分. 现在分析一下题目 因为得分是长度的平方,不能直接累加,所以在计算得分时需要考虑前一个状态所消去的长度,仅用dp[l ...

  6. 破损的键盘(UVa 11988)

    s[] 数组用来保存原有的字符序列 nex[] 数组记录打印的下标顺序 C++11 代码如下: #include<iostream> #include<cstring> usi ...

  7. day2编写购物商城(1)

    作业:购物商城 商品展示,价格 买,加入购物车 付款,钱不够     具体实现了如下功能: 1.可购买的商品信息显示 2.显示购物车内的商品信息.数量.总金额 3.购物车内的商品数量进行增加.减少和商 ...

  8. Rookey.Frame之实体FluentValidation验证

    昨天给大家介绍了Rookey.Frame框架的实体设计,今天继续跟大家分享实体的FluentValidation验证,在Rookey.Frame框架中可以设置多种验证方式:FluentValidati ...

  9. Loadrunner上传文件解决办法(大文件)

    Loadrunner上传文件解决办法(大文件) 最近再做一个跟海量存储相关的项目测试,需要通过LR模拟用户大量上传和下载文件,请求是Rest或Soap,同时还要模拟多种大小尺寸不一的文件 通常情况下, ...

  10. 005 爬虫(requests与beautifulSoup库的使用)

    一:知识点 1.安装requests库 2.Brautiful soup 可以提供一些简单的,python式的函数来处理导航,搜索,修改分析树等功能. 她是一个工具箱,通过解析文档为用户提供需要抓去的 ...