Saturday, March 4, 2017

Structure Extract and Repack boot and recovery file in android

                          please like & Subscribe our youtube channel

         https://www.youtube.com/playlist?list=PLQzJncZC8PUwCTcniu_akzp0N0oDx7l1n



Boot file

Boot file contains ramdisk and kernel. This file is necessary to boot from any android device. The boot.img is part of the Android ROM you flash onto your device.


This is the boot partition of your Android device. It includes the android kernel and the ramdisk.  The device will not boot without this partition. Wiping this partition from recovery should only be done if absolutely required and once done, the device must NOT be rebooted before installing a new one, which can be done by installing a ROM that includes a /boot partition.




Structure of boot file

It is a like a disk image. This is the part to enable boot to phone. Its include kernel and ramdisk without this part phone it not able to boot.
We can see boot structure 


There are 6 layers of Linux boot







and execution of boot file is followed as in below diagram.




BIOS

-BIOS include basic input-out system.
-It executes the bootloader program.
-Its look bootloader in floppy, cd-ROM, and hard drive.
-Once boot loader program loaded in memory BIOS given full control to it.

MBR

-MBR stands for master boot Record.
-It is store in the bootable disk.
-It's size less than 512.

GRUB

-GRUB stand for the grand Unified Bootloader.
-If you install more than one kernel you can choose one of them.
-GRUB display splash screen.
-GRUB Configuration file located in /boot/grub/grub.conf.

Kernel

-Mounts the root file system.
-Kernel executes the /sbin/init program.

Init

-Its decide kernel run level.
-Run level
0-halt.
1-single user mode.
2-multiuser.
3-full multiuser mode.
4-unused.
5-X11
6-reboot
-Identified the default init level and load all associate programs.

Runlevel Program

-it contains all runlevel programs.
-Runlevel depend on default init level setting
Run level 0-/ete/rc.d/rc0.d/
Run level 1-/ete/rc.d/rc1.d/
Run level 2-/ete/rc.d/rc2.d/
Run level 3-/ete/rc.d/rc3.d/
Run level 4-/ete/rc.d/rc4.d/
Run level 5-/ete/rc.d/rc5.d/

Run level 6-/ete/rc.d/rc6.d/

Extract and repack boot file

We can extract boot file by two type’s first one by window command tools and other is by Linux command tools. There are lots of tools available to extract boot.img. For extract boot file firstly rename boot.fex to boot.img.
Extract and repack boot file by window command tools
We can extract boot.img using the bootimg tool.
Here there following steps to extract it.


1) extract bootimg.zip put bootimg.exe and boot.img file in test folder.





2) now go in the test folder and click Ctrl+Shift and right click and choose Open command window here.



3) And write command bootimg.exe –unpack-bootimg boot.img and press enter.


4) After edit file and folder in boot file, we can Repack boot.img.


For repack boot file run this command boot.img --repack-booting  And press enter.




Recovery File



Recovery file is an android flash memory partition that use to perform the factory reset or restore the original os and it provides clockwork mode to custom recovery for android Smartphone and tablet or we can say that it provide advanced recovery, installation, restoration, and maintenance operation for the device.


This is specially designed for backup. The recovery partition can be considered as an alternative boot partition.



Recovery File Structure


Recovery.img file contains many parts like install, Wipe, backup, restore and setting. Each part has an own different role in android device. We will discuss later in on each part.








We can run recovery mode by ADB command (ADB recovery reboot) or with hard code button (by volume+ and power).


There are the main functions of recovery file to manage the android device.


Install- Install function contains to install any android device script to install any library or application.



Wipe- This function contain wide android data to the device.
Backup- This function use to backup of the android device.
Restore- This function use for restore any android device.
Mount- This function uses to mount os files like sd card files.
Setting- This function uses to communicate device application.
Advanced- This function use for the advance setting.


Reboot- This function uses to reboot the device.


Extract and repack Recovery File

                           Here we will extract and repack recovery file using Rk Firmware tools here there is some step to extract it.


1) extract RK firmware tool and copy recovery file here.



2) run start file and press single tool.



3) Select recovery file and press Extract then it will start automatically extract recovery file.





4) Here we can see extracted recovery file in the temp folder.




5) After the edit, we can also repack recovery file using press build button. we can see it in the root directory.



Extract and repack System files in ubuntu

Required tools
  • Stock firmware - as a starting base.
  • Linux image tools - for extracting and building the partitions of the image.
  • A text editor that supports Unix line endings, do not use Notepad.

 

 


            Here there is some step to extract boot file in ubuntu system.


1) Copy boot, recovery and system file in folder custom ROM.



2) Copy tools in this folder here.




3) Extract tools.zip file here.




4) Open terminal application.




5) For extract, boot file go to custom folder using command
$ cd “custom ROM” 
And extract boot file using command
$ tools/split_bootimg.pl boot.img
And type command ls  to check files in directory
$ ls


Here you can see the ramdisk.zip file here.


6) Now we will extract ramdisk file using these command
Firstly we will create a directory using command

$ mkdir ramdisk     
                Go to ramdisk folder using command
                $ cd ramdisk
                 Now we will extract ramdisk.zip file using command 
               $ gunzip –c  ../boot.img-ramdisk.gz | cpio –i
               And check ramdisk files using ls command


                $ ls




7) Now are able to edit as need
Now we can rebuild boot file using the following command

$ cd ..

$ tools/mkbootfs ramdisk | gzip > ramdisk-new.gz

$ tools/mkbootimg --base 0x40000000 --kernel boot.img-kernel --ramdisk ramdisk-new.gz --cmdline 'console=ttyS0,115200 tw init=/init loglevel=8' -o new-boot.img



$ ls






No comments:

Post a Comment