[request] how to edit ramdisk - Captivate Android Development

I am very familiar with editing the ramdisk of a standard boot.img but have no idea how to do so with the way this phone is set up (has a zImage, etc). Can someone point me in the right direction so we can make some great things happen for this device? Thanks in advance

I can tell you how to extract the initramfs image, but I don't think anybody has had success in inserting an altered image into the stock kernel, so it's only of use in building your own kernel. You need to search for a gzip header in the zImage, it is a sequence of three bytes: 1F8B08. Gunzip this and all data following it to get the Image file. Search that for another gzip header, which is the start of the initramfs, in the form of a gzipped cpio archive. You will need to unpack this if you want to modify it. Be aware that it contains absolute pathnames and that cpio will cheerfully and silently extract these to the root of your filesystem if to don't explicitly tell it not to.
Sent from my SAMSUNG-SGH-I897 using XDA App

Related

[Q] creating kernel & ramdisk

I see that things are quite different in Samsung Android modding. I have the kernel compiled. that is no issue. what i am having a difficult time figuring out is how to include and create the ramdisk to flash in Odin. My compiled zImage is only 2.7MB while the stock one is 7.5MB.
There is a build option you can set as the path where the initramfs is. Then in the kernel building process, a cpio archive is created, gzipped, appended to kernel image, and then gzipped again and after adding a header, it becomes the large zImage
Sent from my SGH-T959 using XDA App
neasoon said:
There is a build option you can set as the path where the initramfs is. Then in the kernel building process, a cpio archive is created, gzipped, appended to kernel image, and then gzipped again and after adding a header, it becomes the large zImage
Sent from my SGH-T959 using XDA App
Click to expand...
Click to collapse
ok that is what i thought was going on. it was just creating a larger zImage. has anybody seen a tutorial laying around anywhere??
Find the wiki page of galaxy s on xda-developers.com. There is a link to a script which shows how to extract initramfs cpio from the zImage but you should change it a bit to make it work.
So basically, you dump the stock kernel image, extract the stock initramfs and insert it into your customized kernel image.
Sent from my SGH-T959 using XDA App
neasoon said:
Find the wiki page of galaxy s on xda-developers.com. There is a link to a script which shows how to extract initramfs cpio from the zImage but you should change it a bit to make it work.
So basically, you dump the stock kernel image, extract the stock initramfs and insert it into your customized kernel image.
Sent from my SGH-T959 using XDA App
Click to expand...
Click to collapse
i didn't know there was a wiki lol. thanks man

[Q] How to change the initrd.gz boot image?

Hi guys,
Can anyone explain me how to change the boot image contained in initrd.gz?
Thank you vary much...
erestor6 said:
Hi guys,
Can anyone explain me how to change the boot image contained in initrd.gz?
Thank you vary much...
Click to expand...
Click to collapse
+1 for this, I'm trying to do the exact same thing! Check out this post to create the image in the correct format:
http://forum.xda-developers.com/showthread.php?t=537515
I created a logo.rle image from a 480x800 image (both attached) but don't know how to overwrite the one inside my initrd.gz file. I tried using 7zip but it seems that it is write-protected. If anyone knows how to do this, it would be much appreciated. I've changed all of the other boot screens but just want to change the green HTC logo if I can.
Thanks in advance
gargon01 said:
+1 for this, I'm trying to do the exact same thing! Check out this post to create the image in the correct format:
http://forum.xda-developers.com/showthread.php?t=537515
I created a logo.rle image from a 480x800 image (both attached) but don't know how to overwrite the one inside my initrd.gz file. I tried using 7zip but it seems that it is write-protected. If anyone knows how to do this, it would be much appreciated. I've changed all of the other boot screens but just want to change the green HTC logo if I can.
Thanks in advance
Click to expand...
Click to collapse
thank you very much..but I was arrived at that poit.
In second of me the normal procedure is wrong, there wil be some steps that will be immediate and that we don't know.
help please...
Yeah - now it's working on my HD2!
This method is applicable for firmware, which include the file initrd.gz in zip archive. Many firmwares are distributed as img files, and I have not tried to extract initrd.gz from there, though perhaps it is possible.
The file logo.rle is not the usual rle and programs for creating or convert rle can not create it, also You can not view logo.rle by any usual rle-viewer. I took logo.rle from another firmware, because I could not do it (it can be reached by 7zip from initrd.gz; or copied from root directory after boot by root explorer, if firmware is already installed).
For this process Linux on a PC required - terminal emulator on phone doesn't work correctly! I used Chaox Live CD because I use Windows on my PC.
I put the file initrd.gz (from my firmware) in a folder and the new logo.rle file near this folder. In a Linux terminal I entered to that folder (by command cd) and ran the commands:
gunzip initrd.gz
cpio -i < initrd
cp -f ../logo.rle
rm initrd
find . | cpio -o -H newc | gzip > ../initrd.gz
Than I change the original initrd.gz in the firmware to the one I created.
ps: Not necessarily replace the entire firmware to replace the file initrd.gz. You can replace only a boot partition. To do this, take the original files boot/zImage & META-INF/com/google/android/updater-script from the firmware and add Your own boot/initrd.gz & META-INF/com/google/android/updater-script. Now You can zip it and place the archive to the root of the sdcard. Than enter to MAGLDR-ADrecovery-install zip from sdcard
Archive must contain this 4 files with pathnames:
boot/initrd.gz
boot/zImage
META-INF/com/google/android/update-binary
META-INF/com/google/android/updater-script
file updater-script must containe this commands:
mount("MTD", "boot", "/boot");
package_extract_dir("boot", "/boot");
unmount("/boot");
In my case I use this firmware and logo.rle file from this firmware.
Hope it's will be helpfull!
I'm sorry - english is not my language.
Awesome work, vovchok!
However after reading your sequence of 'nix commands multiple times I have determined that the little white guy doesn't look bad at all.
My momma's boy ain't touching that.
I found this Thread . After reading, I landed here. Now this is where I just got stuck.
I'm using Hyperdroid and there is no initrd.gz. There's just a "boot.img" with ~3mb.
I still would like to change my second boot screen to fit in the boot sequence.
(I already mastered to create my own 1st bootscreen, flashed it, and changed my boot animation, but as said, I got stuck here finding a guide how to change the second boot screen.)
Any ideas?
smeee_again said:
I found this Thread . After reading, I landed here. Now this is where I just got stuck.
I'm using Hyperdroid and there is no initrd.gz. There's just a "boot.img" with ~3mb.
I still would like to change my second boot screen to fit in the boot sequence.
(I already mastered to create my own 1st bootscreen, flashed it, and changed my boot animation, but as said, I got stuck here finding a guide how to change the second boot screen.)
Any ideas?
Click to expand...
Click to collapse
Yeah - it's a lot more complicated to extract the initrd.gz file from a boot.img than it is from a ROM with a boot partition. I spent many hours trying to do it, and failed.
Currently just building a ROM with an edited initrd.gz file inside it. I know that the logo.rle file in the initrd.gz file is the correct image that I want (the stock white HTC screen) but I just don't know if I'm building the ROM with the correct options (using the Android Kitchen).
I'll report back with results, because I tried to do this a couple of months ago and failed, since the ROM required me to flash a separate kernel zip after the main ROM, which replaced initrd.gz, and I couldn't edit the initrd.gz file using the Android Kitchen because it was in a boot.img.
EDIT: Okay, just spent about 2 hours trying to change the damn image, having replaced initrd.gz with what was definitely the right one, and I boot it up and see the black HTC logo.
Alright, I've actually successfully modified the logo.rle file from inside a boot.img, rebuilt the ROM with it, and reflashed it - the image is now in place, and the ROM works great.
So, the steps:
Use dsixda's Android Kitchen to unpack the ROM into a working folder.
Locate the boot.img and copy it to a separate folder.
Follow this tutorial to unpack the boot.img file, then locate the logo.rle inside there (there's no initrd.gz).
Use the tools found here to convert the image that you want to use to an RLE file, and then overwrite the existing RLE file in your working directory where you unpacked the boot.img.
Continuing the tutorial found in the link from step 3, repack your boot.img with the edited logo.rle now inside it.
Head back to your working folder in the Android Kitchen, where the ROM that you want to modify has been unpacked. Replace the boot.img there with the one that you just modified.
Choose option 99 in the kitchen to build a ROM from the working folder, and follow the steps.
Now flash your ROM in CWM! I flashed straight over an existing installation instead of wiping etc., although it did still get rid of all my settings
Hopefully this is helpful to someone. I might post it in a new thread - since I spent so long trying to find this, and finally figured out how to do it for myself.
This helped a lot. Thanks.
ryan1990 said:
This helped a lot. Thanks.
Click to expand...
Click to collapse
No worries. If anyone ever gets stuck or doesn't know what I did for some bit, let me know and I'll see if I can help, because it sucked when I was trying to figure this out for ages and nobody else seemed to know how to do it either.
vovchok said:
Yeah - now it's working on my HD2!
gunzip initrd.gz
cpio -i < initrd
cp -f ../logo.rle
rm initrd
find . | cpio -o -H newc | gzip > ../initrd.gz
Hope it's will be helpfull!
I'm sorry - english is not my language.
Click to expand...
Click to collapse
search for long time, now work fine.
THX bro.
vovchok said:
Yeah - now it's working on my HD2!
This method is applicable for firmware, which include the file initrd.gz in zip archive. Many firmwares are distributed as img files, and I have not tried to extract initrd.gz from there, though perhaps it is possible.
The file logo.rle is not the usual rle and programs for creating or convert rle can not create it, also You can not view logo.rle by any usual rle-viewer. I took logo.rle from another firmware, because I could not do it (it can be reached by 7zip from initrd.gz; or copied from root directory after boot by root explorer, if firmware is already installed).
For this process Linux on a PC required - terminal emulator on phone doesn't work correctly! I used Chaox Live CD because I use Windows on my PC.
I put the file initrd.gz (from my firmware) in a folder and the new logo.rle file near this folder. In a Linux terminal I entered to that folder (by command cd) and ran the commands:
gunzip initrd.gz
cpio -i < initrd
cp -f ../logo.rle
rm initrd
find . | cpio -o -H newc | gzip > ../initrd.gz
Than I change the original initrd.gz in the firmware to the one I created.
ps: Not necessarily replace the entire firmware to replace the file initrd.gz. You can replace only a boot partition. To do this, take the original files boot/zImage & META-INF/com/google/android/updater-script from the firmware and add Your own boot/initrd.gz & META-INF/com/google/android/updater-script. Now You can zip it and place the archive to the root of the sdcard. Than enter to MAGLDR-ADrecovery-install zip from sdcard
Archive must contain this 4 files with pathnames:
boot/initrd.gz
boot/zImage
META-INF/com/google/android/update-binary
META-INF/com/google/android/updater-script
file updater-script must containe this commands:
mount("MTD", "boot", "/boot");
package_extract_dir("boot", "/boot");
unmount("/boot");
In my case I use this firmware and logo.rle file from this firmware.
Hope it's will be helpfull!
I'm sorry - english is not my language.
Click to expand...
Click to collapse
Thz for your help^^
The rom i am using hvn't boot.img.
but i can find initrd.gz and i hv change the logo.rle.
the probllem is how to edit the updater-script only update the initrd.gz?
and is it possible to random boot a few of .rle files ?
Please, make initrd.gz for CM9ight
Oops, not the right thread.

mkbootimg

ok im trying to repack a kernel and i get mkbootimg not found i already downloaded a mkbootimg zipbut dont know what to do with it can someone guide me on what to do with mkbooting thanks in advance
Check out the Kitchen
http://forum.xda-developers.com/showthread.php?t=633246
In that zip, i use scripts/boot_img_tools to unpack. Then I looked through build_boot_img to get the command syntax for mkbootfs and mkbootimg. It also shows the commands for compiling those tools. They are in the tools folder. The mkbootfs will create the ramdisk image. Then mkbootimg will combine it and the zImage into a boot.img (or recovery.img).
I can't remember the parameters off hand, but that script (build_boot_img) will tell you everything you need to know.
Thanks ill check it out
Sent from my SCH-R720 using xda premium

[Q] custom kernel with initrd?

Hi everyone, I'm looking for a little help in booting a custom linux kernel on the Acer Iconia a500 with an initrd (not an initramfs, and the distinction is important). I'm working on building an ARM version of the Porteus Linux OS, which is a slackware-based linux-live distribution.
I have compiled a custom kernel based on sp3_dev's 2.6.38 kernel sources, added a patch for aufs, compiled in support for XZ compression, squashfs and a few other things, and I can get this system to boot into a functional GUI using an initramfs that I've embedded into the kernel (it looks like this is how other folks are using a ramdisk). However, Porteus typically uses an initrd to set up the live filesystem, and moving to an initramfs will require rewriting a number of scripts and maintaining them separately from the x86 tree. I have tried booting with an initrd in a number of ways, and have failed each time and google/xda searches have not yielded a solution. I've packaged my zImage and initrd.xz with mkbootimg and flashed it to mmcblk0p1 to dual boot linux with android, and tried hard-coding a number of calls for initrd in the kernel cmdline, such as, "initrd=/dev/mmcblk0p1/intird.xz", "initrd=/initrd.xz", "initrd=0x11000000,16M" all to no avail.
So, my question is this: is there any way to get the kernel to load an initrd (which is not embedded in the kernel itself) without replacing the stock bootloader? I'd prefer to keep the installation easy and low-risk for other users.
Thanks for your time, and many thanks to the devs who have been contributing to getting native Linux on the Iconia! Your threads have been an invaluable resource.
-Ahau
And I am trying making something similar,but I'm want make initrd who boots from internal storage like tf101 kernel, and I can't make kernel working with initrd , I'm using netham's initrd source and guide http://forum.xda-developers.com/showthread.php?t=1158260&page=24 , when I compiled the kernel and make boot.img then it says - kernel panic, can't find initrd... . My question is - what format initrd should be .cpio, .img, .gz... if it doesn't matter, then what kernel command should be in boot options to kernel .config. sorry for bad English.
Thanks, Tautvaldas. If you are following netham's instructions, you are using an initramfs that is built into the kernel. You can either specify a cpio/gzipped archive in the kernel config (CONFIG_INITRAMFS_SOURCE) or point it to a directory containing the files and subdirectories you want inside your initramfs and the compiler will cpio and compress it at build time. I use the second approach as it saves the steps involved in creating the cpio image and gzipping it. Once you've done this, I don't believe you need to specify an initrd in CONFIG_CMDLINE. The initramfs is then contained inside zImage, so when you generate the new "recovery.img" with mkbootimg, you still point -initrd to /dev/zero.
To clarify, an initramfs (probably named something like initrd.gz) is both a cpio archive and gzip compressed. Google 'initrd cpio' for more on how to extract and compress them.
HTH
worked-around
Well, I didn't sort out how to load an initrd directly, but a friend did find a script for me that can be used in an initramfs and make it look (and work) like an initrd. In case anyone else runs into this issue, here's the relevant portions of the script:
# Build a ramdisk and copy ourselves over, so we look like an initrd
mke2fs -m 0 /dev/ram0 >/dev/null 2>&1
mount -t ext4 /dev/ram0 /mnt
for item in /*; do [ "$item" != "/mnt" ] && cp -a $item /mnt; done
mkdir /mnt/mnt
# Transfer control to linuxrc as an initrd would
exec switch_root -c /dev/console /mnt /linuxrc $*

MyMind's Kernel Swap

MyMinds_Kernel_Swap
===================
Based on AnyKernel, but pretty much rebuilt in every way so that it will actually work. So, many thanks to Koush for the idea.
The Idea and What It Does...
=======================
Some but not all of this script has been snippets here and there from ArchiKitchen and DSIXDA Kitchen.
This has allowed me to formulate a zip as such without the need to technically build from scratch saving me LOADS OF HOURS.
It currently uses my static compiled mkbootimg, unmkbootimg, and mkbootfs binaries to allow editing, and rebuilding of the boot.img.
Some serious modifications were made to get this to work successfully with MUCH DEBUGGING. If you change something and it breaks another function then that is on you!
# IT IS CURRENTLY STABLE!
1. It will pull your current boot.img using dd.
2. It will search for the Android! header in the boot.img and remove the unnecessary junk before it if needed to.
3. It will split the boot.img in to the kernel and ramdisk.
4. It will unpack the contents inside the ramdisk.
5. It will modify the default.prop file giving you insecure ADB. If you already have it then this will not affect you.
6. It will modify the init.rc file to give support for init.d. If you already have it then this will not affect you.
7. It will write to sysinit and install-recovery.sh for the completion of init.d support. If already done, then this will not affect you.
8. It will make the init.d folder under /system/etc on your device with required permissions.
9. It will place an init.d script to test to see if init.d is fully working. If it works, you will find a file called, HAS_INIT, located in the /dev directory of your device.
10. It will swap out the original kernel with a new prebuilt kernel upon rebuilding the new boot.img
11. It will repack you a new ramdisk using mkbootfs to be applied to your new boot.img upon rebuilding it.
12. It will remove your old modules and push your new modules that came with your new prebuilt kernel.
13. It will write your new boot.img to your boot partition using dd.
14. Hopefully, more to come!
MAKE SURE YOU CHANGE...
=======================
"$BOOT_PARTITION" ACCORDING TO YOUR DEVICE BEFORE USING THIS SCRIPT!!!!!!
How to use it...
==============
1. Place your prebuilt kernel in the prebuilt folder and insure it is named, zImage.
2. Place kernel modules in the modules folder.
3. Zip, and flash in TWRP recovery.
If you have any suggestions then let me know. My ears are open to them.
https://github.com/ModdingMyMind/MyMinds_Kernel_Swap
Sent from my C525c using Tapatalk

Categories

Resources