Maybe a noob question, but how do you guys split and repack SGS3 boot.img ?
The usual perl scripts don't seem to work with any S3 boot.img I came across (neither for the Galaxy Tab 7.7 boot.img's btw).
I keep getting this error :
Android Magic not found in boot.img. Giving Up.
Click to expand...
Click to collapse
Thanks for answering.
To unpack, you can do this:
Code:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames
Of course, that assumes you have abootimg installed. The above will split the zImage and the ramdisk from the boot.img and then proceed to extract the files from the ramdisk. Some ramdisks are not Gzip compressed so in that case use cat instead of zcat. Also: run that as root to make sure you don't mangle the files' permissions. I haven't tried repacking, though. ("find . -print | cpio -o -H newc | gzip > ../initrd.img" followed by "cd .. ; abootimg -u boot.img -r initrd.img" worked for my U8800pro, but I've had no need to try it with GS3 images.) I'd start by looking at the tools that come with the official Samsung source distribution and guides that tell you how to build a Samsung kernel.
Thanks a lot for this thorough answer
Trying this right now.
Couldn't find a specific Samsung kernel-related tutorial, though good idea to go take a look at Samsung's official kernel documentation.
qwerty12 said:
To unpack, you can do this:
Code:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames
Of course, that assumes you have abootimg installed. The above will split the zImage and the ramdisk from the boot.img and then proceed to extract the files from the ramdisk. Some ramdisks are not Gzip compressed so in that case use cat instead of zcat. Also: run that as root to make sure you don't mangle the files' permissions. I haven't tried repacking, though. ("find . -print | cpio -o -H newc | gzip > ../initrd.img" followed by "cd .. ; abootimg -u boot.img -r initrd.img" worked for my U8800pro, but I've had no need to try it with GS3 images.) I'd start by looking at the tools that come with the official Samsung source distribution and guides that tell you how to build a Samsung kernel.
Click to expand...
Click to collapse
Great!! Thanks for your information.
Here is what I use. Inside there are three binaries and two perl scripts,, copy the binaries into /usr/bin/ or you can add them in their own place and add that to the path. Then use this to help you use the files
Thanks for that too, ima try those scripts
Getting this error :
~$ perl unpack-bootimg.pl boot.img
could not find any embeded ramdisk images. Are you sure this is a full boot image?
Click to expand...
Click to collapse
Apparently, from what I have been reading, Samsung uses a different type of kernels than other manufacturers.
Although there's a huge number of custom samsung kernels out there. There might be a way^^
Here is the kernel i'm trying to edit if anyone wanna give a try at unpacking it for me.
That is true up until the S3 boot.img/kernel They have always used a zImage. Now Google has forced them to move over to EXT4 system and change the kernel format.
That file is only 2.88 mb's that is way too small to be a full kernel. Even for stock with no tweaks. That's why you are having an error.
This is the original boot.img from the CM9 for Galaxy Tab 7.7 update.zip
However i get the same error when trying to unpack S3 stock boot.img or even CM10 boot.img, although when i try the same scripts on my Xperia Play's kernels they unpack properly.
Good thing if Google made Samsung do kernels like others
Hi,
Did you manage to unpack/repack the SGS3 boot image? I'm trying to modify init.rc in an international SGS3 (i9300).
I've managed to unpack the boot image (from /dev/block/mmcblk0p5) as per qwerty12's command but how do I repack it?
Thanks!
Related
I have currently been testing the method of rooting leaked 2.1 phones. There was a little discussion running in that thread (and other threads, I've found) that poses the question whether or not the RUU is the same as 2.1 Leak v3.
The RUU I'm using is referenced here: http://forum.xda-developers.com/showthread.php?t=695667 -- which can be found here: http://shipped-roms.com/shipped/Des...WWE_2.36.605.1_release_signed_with_driver.exe
Leak 2.1 v3 I'm using is referenced here: http://androidforums.com/htc-droid-eris/69688-htc-droid-eris-os-2-1v3-download.html -- which can be found here: http://www.mediafire.com/?qymwuzug5gl
So, the process that I've been using to root these phones involves flashing the RUU OTA onto the phone. With some help from user bftb0, I have taken the time to do the analysis.
How did I get system.img and boot.img off of the RUU OTA, you might ask? Well, after I flashed the RUU OTA onto the phone, I went through the Incredible/Slide root method to root the phone I'm working with (without changing any phone settings within Sense). After getting adb to recognize the device in recovery, I took the steps necessary to flash Amon_RA's recovery. I then took a Nandroid backup of my phone, and extracted the system.img and boot.img files off of the SD card where the Nandroid backup was stored.
Then, I used unyaffs to unpack system.img into 2 separate directories, and used split_bootimg.pl to unpack boot.img
so, for split_bootimg.pl I did this, starting at the directory where each respective boot.img file is
Code:
$ mkdir unpak
$ cd unpak
$ split_bootimg.pl ../boot.img
... [output] ...
$ mkdir ramdisk
$ cd ramdisk
$ gunzip -c ../boot.img-ramdisk.gz | cpio -i
The test after it's unpacked
Code:
#!/bin/bash
mydir=`pwd`
for tree in leakv3 RUU ; do
cd $tree
touch ./md5sigs
find . -type f -print | while read fnam ; do md5sum $fnam >> ./md5sigs ; done
cd $mydir
done
cat leakv3/md5sigs RUU/md5sigs | sort | uniq -u
Code:
$ ./md5test.sh
6951ac78e8f9ae5e6c4c4cb50803fed9 ./bin/su
9512ebf90efee5ea996ec59456cf4b03 ./md5sigs
c6212fa45ab99c3a5d731bca06184023 ./md5sigs
This output should be expected; we should expect the su executable to be in one and not the other if I've rooted it, and the md5sigs that the script creates are not going to have the same md5sums
Pastebins for both the leak v3 list of md5sums, and RUU list of md5sums
Leak v3 md5sigs pastebin: http://pastebin.com/PGZDbC1r
RUU OTA md5sigs pastebin: http://pastebin.com/qz5z0Vdr
Conclusion: They are identical
Anyone know how to do that and bundle it back up into a zImage we can flash on the Vibrant/Galaxy S? HTC's boot.img was reasonably simple to mod, but I haven't found any good data on re-assembling the zImage Samsung uses. I have been able to extract the initrd, but nothing on putting it back together.
I'd prefer not to completely build the kernel, as I'd like to keep using JACs and he hasn't posted the source. And I'd have to build the cross-compiler as well, time consuming.
Irritating, the Samsung kernel source build works but doesn't do this bit either. No initrd... grrrr...
No doubt there is a way to reverse-engineer the way the kernel and ramdisk is put together, but it's way beyond my capability at the moment. With that said, if we can take it apart, we can probably put it back together.
i too am looking for instructions how to repack and/or split this
Jr33 said:
i too am looking for instructions how to repack and/or split this
Click to expand...
Click to collapse
Here's how you pull the initrd out from a Vibrant image, well, JAC OCv4 anyway.. Based on a thread and script in the international Galaxy S forum. I still don't know how to re-assemble it, but Wes put some stuff in git that might help, I'm still building after a repo sync. After you run the script with the zImage as the only parameter, you should get an initrd directory with the extracted contents of the ramdisk.
Code:
#!/bin/sh
zImage=$1
#=======================================================
# find start of gziped kernel object in the zImage file:
#=======================================================
pos=`grep -a -b --only-matching $'\x1F\x8B\x08' $zImage | cut -f 1 -d :`
echo "-I- Extracting kernel image from $zImage (start = $pos)"
# dd if=$zImage bs=1 skip=$pos | gunzip > kernel.img
#===========================================================================
# find start and end of the "cpio" initramfs image inside the kernel object:
# ASCII cpio header starts with '070701'
# The end of the cpio archive is marked with an empty file named TRAILER!!!
#===========================================================================
search=`perl -e'print "\x1F\x8B\x08"'`
start=`grep -a -b --only-matching $search kernel.img | head -1 | cut -f 1 -d :`
echo "-I- Extracting initramfs image from kernel.img (start = $start, end = $end)"
dd if=kernel.img bs=1 skip=$start | gzip -d -c > initramfs.img
mkdir initrd
cd initrd
cpio -i --no-absolute-filenames < ../initramfs.img
Hi,
has anyone unpacked the boot.img of our ace 2? I created the boot.img with a CWM backup and also with this command:
Code:
su
dd if=dev/block/mmcblk0p15 of=/mnt/sdcard/boot.img
but i can't unpack the file, get the message "Android 'magic' header not found at start of boot.img" or similar. Tried with Android Kitchen and this command:
Code:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames
Can anyone help me?
rs90xda said:
Hi,
has anyone unpacked the boot.img of our ace 2? I created the boot.img with a CWM backup and also with this command:
Code:
su
dd if=dev/block/mmcblk0p15 of=/mnt/sdcard/boot.img
but i can't unpack the file, get the message "Android 'magic' header not found at start of boot.img" or similar. Tried with Android Kitchen and this command:
Code:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames
Can anyone help me?
Click to expand...
Click to collapse
I took boot.img from CWM Recovery during making recovery
boot.img
If you guys can, take my kernel from MX general thread, take out the kernel.bin.md5, remove the md5 extension by removing the hash sum and then rename kernel.bin to zImage. Then inject it into the boot.ing you have
Sent from my GT-I8160 using Tapatalk 2
michal_ag said:
I took boot.img from CWM Recovery during making recovery
boot.img
Click to expand...
Click to collapse
I think OP did the same... So this boot.img is not proper one? because i want to try do do some "digging" (i'm a newbie in android development/linux) and boot.img is crucial
judas1977 said:
I think OP did the same... So this boot.img is not proper one? because i want to try do do some "digging" (i'm a newbie in android development/linux) and boot.img is crucial
Click to expand...
Click to collapse
I'm struggling with the same problem... Did you already found a solution for this?
These tools that you are using doesn't work because for our device there isn't a regular boot.img
kernel.bin.md5 is just gzipped zImage with ramdisk. Note that ramdisk is not compressed (it's raw cpio file). Tomorrow I'll post script to unpack kernel.bin.md5.
But to pack it again the best way is compile kernel with CONFIG_INITRAMFS_SOURCE specified.
Thanks but how could I know that? I have been looking a lot but couldn't find much info about it... Perhaps I was looking at the wrong places...
[Edit] After your explanation I've found the script myself and extracted the kernel.img.md5
Actually, it's quite simple.
For unpacking:
http://forum.xda-developers.com/wiki/index.php?title=Extract_initramfs_from_zImage
And to be honest, kernel.bin.md5 is nothing but a zImage with MD5 checksum at the end of the file.
bagnz0r said:
Actually, it's quite simple.
For unpacking:
http://forum.xda-developers.com/wiki/index.php?title=Extract_initramfs_from_zImage
And to be honest, kernel.bin.md5 is nothing but a zImage with MD5 checksum at the end of the file.
Click to expand...
Click to collapse
Don't know why but for me this script didn't work on Arch Linux. I had to remove the part where it's checking if cpio is gzipped.
ccnky said:
Don't know why but for me this script didn't work on Arch Linux. I had to remove the part where it's checking if cpio is gzipped.
Click to expand...
Click to collapse
You might need to get these:
Code:
cpio gzip
And don't remove that gz part.
bagnz0r said:
You might need to get these:
Code:
cpio gzip
And don't remove that gz part.
Click to expand...
Click to collapse
I'm not so much noob
This script created empty files for me. I manually typed commands (without gzip) and worked perfect.
ccnky said:
Don't know why but for me this script didn't work on Arch Linux. I had to remove the part where it's checking if cpio is gzipped.
Click to expand...
Click to collapse
Try the last version in github (see at bottom of page on the link bagnz0r has sent) That one worked for me on cygwin.
Sent from my GT-I8160 using xda app-developers app
h3llrais3r said:
Try the last version in github (see at bottom of page on the link bagnz0r has sent) That one worked for me on cygwin.
Sent from my GT-I8160 using xda app-developers app
Click to expand...
Click to collapse
Thanks for your advice but I unpacked ramdisk once and don't have to do that anymore.
I am trying to install Linux on my Samsung Galaxy Tab S using the directions described in How to run Debian or Ubuntu GNU/Linux on your Android (I am not yet allowed to specify the URL but you might google it). However I cannot find the zImage (which is the original kernel in the tablet) to be used in the command
Code:
# mkbootimg --base 0x00200000 --kernel zImage --ramdisk initramfs.cpio.gz -o my-boot.img
What dælen can I do to find and extract it?
Thanks in advance.
CMJager said:
I am trying to install Linux on my Samsung Galaxy Tab S using the directions described in How to run Debian or Ubuntu GNU/Linux on your Android (I am not yet allowed to specify the URL but you might google it). However I cannot find the zImage (which is the original kernel in the tablet) to be used in the command
Code:
# mkbootimg --base 0x00200000 --kernel zImage --ramdisk initramfs.cpio.gz -o my-boot.img
What dælen can I do to find and extract it?
Thanks in advance.
Click to expand...
Click to collapse
You need to unpack the boot image to separate the kernel(zImage) and ramdisk. There are various tools about to do this.
ashyx said:
You need to unpack the boot image to separate the kernel(zImage) and ramdisk. There are various tools about to do this.
Click to expand...
Click to collapse
So where (or how) do i find the boot image?
CMJager said:
So where (or how) do i find the boot image?
Click to expand...
Click to collapse
The boot.img can either be found in the stock firmware or pulled frm the device or use a custom kernel posted in development.
Found it:
Code:
# ls -l /dev/block/platform/dw_mmc.0/by-name/BOOT
lrwxrwxrwx root root 2015-12-27 19:43 BOOT -> /dev/block/mmcblk0p9
Put the contents in a file:
Code:
# cat /dev/block/mmcblk0p9 /sdcard/boot.img
And at my linux box extracted the contents:
Code:
$ adb pull /storage/sdcard0/boot.img
$ unpackbootimg -i boot.img
BOARD_KERNEL_CMDLINE
BOARD_KERNEL_BASE 10000000
BOARD_PAGE_SIZE 2048
$
Then I also found a more robust mkbootimg-command:
Code:
$ mkbootimg --kernel boot.img-zImage --ramdisk boot.img-ramdisk.gz -o my-boot.img --base $(cat boot.img-base)
I recently got my hands on a WeTek Hub. All round quite a nice little box, but the default lowmemorykiller settings are a little annoying, and sometimes result in the boot failing because the kernel decided to kill one of the startup processes. I'm trying to modify the settings in the init.rc, but I'm having a spot of trouble with a boot loop after repacking the boot image.
I copied the image off the device by using dd to extract the partition to a file, and then used the built-in FTP server to copy it off the device, and extracted it using unmkbootimg. after unzipping, extracting, modifying, and re-packing, I used mkbootimg to recreate the image, and dd'd it back onto the box (commands below).
Code:
dd if=/dev/block/boot of=/sdcard/boot.img
Code:
./unmkbootimg boot.img
mv initrd.img{,.gz}
gunzip initrd.img.gz
mkdir initrd
cp initrd.img initrd
cd initrd
cpio -i < initrd.img
rm initrd.img
# change stuff here
find . | cpio -o -H newc > ../initrd.cpio
cd ..
gzip initrd.cpio
./mkbootimg --kernel kernel.gz --ramdisk initrd.img.gz -o new_boot.img
Code:
dd if=/sdcard/new_boot.img of=/dev/block/boot
Unfortunately, that left me with a flashing WeTek logo as the it continuously rebooted. examining the logs from u-boot didn't give anything useful, but luckily I was able to get it into recovery and flash Ricardo's Android TV ROM back on there. Unfortunately, I'm still stuck with the original boot failure issue. Any clues as to what I've missed?
I do so
Code:
cd boot
../mkboot boot.img unpaсk
cd unpack/ramdisk
find . | cpio -o -H newc | gzip > ../ramdisk.packed
[I][B]# (edit size ramdisk in /boot/unpack/img_info file)[/B][/I]
cd ../..
../mkboot unpack boot.img
all is working