• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Prevail Kernel Ramdisk Packer

hroark13

Android Expert
Recognized Developer
Jul 15, 2011
3,280
4,113
We can not compile a bootable kernel zImage yet, but we can mod the kernel ramdisk.

I created some tools for repacking a zImage and ramdisk, so that others besides Shabby and myself can release Kernels, who knows, maybe some of you can come up with some creative mods.

My tool can create an Odin or ClockWorkMod flashable kernel.

You have to have Linux, the Android SDK and all packages required for the Android SDK
You also need Python 2.7, newer versions of Pyhton tend to have problems with the Android SDK


Download and unzip the kpack.zip file to your /home/"user" folder

Examples

To Create an Odin flashabe ShabbyKernel RC1 tar file
Open terminal
cd /home/"user"/kpack
./odinkrnl.pl shabby-rc1

you will now have a odinkrnl.tar file in the kpack folder that you could copy to a Windows computer and flash with Odin

To Create a CWM flashabe Hroarkernel 1.2 zip file
Open terminal
cd /home/"user"/kpack
./cwmkrnl.pl hroark-12

you will now have a cwmkrnl.zip file in the kpack folder that you could copy to sdcard and flash with cwm

To Create a CWM flashabe EE14 stock kernel zip file
Open terminal
cd /home/"user"/kpack
./cwmkrnl.pl stock-ee14

you will now have a cwmkrnl.zip file in the kpack folder that you could copy to sdcard and flash with cwm

To Create your own version of an Odin flashabe Kernel tar file
Copy the contents of either the hroark-12, shabby-rc1, or stock-ee14 into a new folder called myramdisk

Make your changes to the files or add modules or whatever the hell you want.
Remember that the ramdisk has a size limit, so you can not add too many modules

Open terminal
cd /home/"user"/kpack
./odinkrnl.pl myramdisk

you will now have a odinkrnl.tar file in the kpack folder that you could flash with Odin

To Create your own version of a CWM flashabe Kernel zip file
Copy either the hroark-12, shabby-rc1, or stock-ee14 folders into a new folder called myramdisk

Make your changes to the files or add modules or whatever the hell you want.
Remember that the ramdisk has a size limit, so you can not add too many modules

Open terminal
cd /home/"user"/kpack
./cwmkrnl.pl myramdisk

you will now have a cwmkrnl.zip file in the kpack folder that you could copy to sdcard and flash with cwm



MEGAUPLOAD - The leading online storage and file delivery service
 
nothing so radical. just want to see how it's done and do it.

trying with the included shabby-rc1 has me held up at this
22593 blocks
Can't exec "./mkbootimg": No such file or directory at ./odinkrnl.pl line 20.

repacked boot image written at boot.img

removed old odinkrnl.tar
tar: boot.img: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

ceated odinkrnl.tar
rm: cannot remove `boot.img': No such file or directory

removed temporary boot.img

done
zImage is there
mkbootimg is there and executable
ramdisk-repack.gz gets created and removed
boot.img not created so i understand cannot start no such file~ and exiting with failure~
so i copy one there to see what happens.
Code:
Can't exec "./mkbootimg": No such file or directory at ./odinkrnl.pl line 20.
script then completes without further error which again i understand but that line now looks complete to me. gave the same result with other folders.
what more does line 20 need?
 
Upvote 0
nothing so radical. just want to see how it's done and do it.

trying with the included shabby-rc1 has me held up at this
zImage is there
mkbootimg is there and executable
ramdisk-repack.gz gets created and removed
boot.img not created so i understand cannot start no such file~ and exiting with failure~
so i copy one there to see what happens.
Code:
Can't exec "./mkbootimg": No such file or directory at ./odinkrnl.pl line 20.
script then completes without further error which again i understand but that line now looks complete to me. gave the same result with other folders.
what more does line 20 need?

i think we either need to add the folder that has mkbootimg to your path or you can copy mkbootimg to your /bin folder
 
  • Like
Reactions: inigomontoyasr
Upvote 0
added kpack folder location to path, nothing changed. copied to /bin, nothing. copied to usr/local/bin, nothing. been reading around but can't figure out what next step is.

edit: could that file be corrupt? downloading again.


what version of linux are you using, do you have Python installed and if so what version
 
Upvote 0
can you try changing this line in the odinkrnl.pl or cwmkrnl.pl

system ("./mkbootimg --kernel zImage --ramdisk ramdisk-repack.gz -o boot.img --base 0x13000000 --pagesize 4096");

to this

system ("$dir/mkbootimg --kernel zImage --ramdisk ramdisk-repack.gz -o boot.img --base 0x13000000 --pagesize 4096");
 
Upvote 0
what version of linux are you using, do you have Python installed and if so what version
ubuntu 11.04 and Python 3.1 installing slackware now cause i read somewhere if you learn ubuntu you learn ubuntu but if you learn slackware you learn linux and i'm eager to learn.

to this

system ("$dir/mkbootimg --kernel zImage --ramdisk ramdisk-repack.gz -o boot.img --base 0x13000000 --pagesize 4096");
same error with full path instead of ./mkb~

chmod 755 /home/"user"/mkbootimg

i'd chmod-ed the whole folder 777 before i posted the first error because i had that thought. i'll try again as 755 but..*shrug*
 
Upvote 0
ubuntu 11.04 and Python 3.1 installing slackware now cause i read somewhere if you learn ubuntu you learn ubuntu but if you learn slackware you learn linux and i'm eager to learn.


same error with full path instead of ./mkb~



i'd chmod-ed the whole folder 777 before i posted the first error because i had that thought. i'll try again as 755 but..*shrug*

well I did setup my system as an Adroid development system and installed alot of packages

i am running Ubuntu 11.4 64 bit and have Python 2.7
i remember when I was setting up this system that I had to downgrade python to 2.7 for it to work with the Android SDK or something

the mkbootimg file is part of the Android SDK, the mkbootimg file in my zip file is an older version

so I am thinking maybe a required package for the mkbootimg file is not installed and I am not sure which package it is, or the newer version of Python can be the culprit

did you try running it as root
sudo su

?
 
Upvote 0
i installed the the sdk and bang. i should've thought of that earlier but i have it on the Windows machine so i figured i could shuttle files back and forth. it didn't say to use 2.7 so i left it alone and the kernel flashed fine. now to modify.

I will edit the OP and mention that the SDK is needed

so the original ummodified scripts are running right?
 
Upvote 0
I will edit the OP and mention that the SDK is needed

so the original ummodified scripts are running right?

the kernels i made first wouldn't boot.
i downgraded to pyton 2.7 and they boot.

yes your original scripts are working. i removed the kpack folder and redownloaded the zip to be sure i was using it the way you wrote it up

also i simply removed 'disabled' from shabbykernel's init.d lines and it works with S##script now. i don't know if that's an error on my part but it seems there are no adverse affects.
 
Upvote 0
the kernels i made first wouldn't boot.
i downgraded to pyton 2.7 and they boot.

yes your original scripts are working. i removed the kpack folder and redownloaded the zip to be sure i was using it the way you wrote it up

also i simply removed 'disabled' from shabbykernel's init.d lines and it works with S##script now. i don't know if that's an error on my part but it seems there are no adverse affects.

I will edit the OP again and mention Python 2.7
Shabby's RC1 kernel and mine do init.d totally different, I am not sure which is better, and I dont think it matters too much.

are only S## scripts running or can the script be any name now

I made the repacker so that curious people like yourself can mess around with it and learn, and maybe come up with some creative mods
 
Upvote 0
I will edit the OP again and mention Python 2.7
Shabby's RC1 kernel and mine do init.d totally different, I am not sure which is better, and I dont think i matters too much.

are only S## scripts running or can the script be any name now

I made the repacker so that curios people like yourself can mess around with it and learn, and maybe come up with some creative mods
I did some messing around, just testing and was able to pack shabby, yours, and a hodgepodge of the 2 with no problem.

Though I have been attempting to build my own ext4 kernel and it fails with permission denied on dbus and ends up in a boot loop. I found that using adb logcat after getting frustrated with it.

course this was trying to make a odin flashable working setup.I tried cwm flashable but it would abort every time.
I think im just a bit over my head and more trial an error is needed, I wish I had a second phone as I hate resetting mine up, and the down time. lol I had my phone in an unusable state all day today I think. And I thought I royally bricked it today
odin was stuck at data.rfs for 16 mins and so I just closed it. took some doing to get it back up and going.

on a good note, for me anyway, I was able to piece together a odin flashable ext4 with new cwm recovery with working usb storage and my apps the way I want them with my theme.
 
Upvote 0
shabbykernel init.d will now execute script of any name. no letters or numbers required.
i took a few hints and the modules from hk12 and put a kernel together that uses shabby init.d method, mounts ext4, doesn't require install-recovery.sh and has v6 agressive minfrees default. a few more tweaks and i may post it for others to try.
i'm an auto mechanic and machine fabricator by trade and my motto is less moving parts makes life easier so i like the init.d in shabby's for not referencing another script. just personal preference. both ways work fine.
i don't understand how his orders the scripts but i think i will over time.

thanks again for this. i'm only ~six weeks into experience with modifying android and a few days with linux pc but i feel like i can learn in leaps. i've been looking at code and script from other phones to see what's different. i may have discovered a new hobby.

new op, i've found, while making a2sd work, that the ext4 rom doesn't like bml mount in cwm scripts. that's why the ext4 rom is the only one you need to manually mount partitions for the installer now. i know what you mean about downtime. i have a broken one from a friend i've been using to test things. he tried to rig up an external antenna and broke the cell radio. wifi still works though so i just don't know if anything i do has an affect on reception until i flash it to MY phone. handy.

can't wait to get another phone to start doing all this again.
 
Upvote 0
shabbykernel init.d will now execute script of any name. no letters or numbers required.
i took a few hints and the modules from hk12 and put a kernel together that uses shabby init.d method, mounts ext4, doesn't require install-recovery.sh and has v6 agressive minfrees default. a few more tweaks and i may post it for others to try.
i'm an auto mechanic and machine fabricator by trade and my motto is less moving parts makes life easier so i like the init.d in shabby's for not referencing another script. just personal preference. both ways work fine.
i don't understand how his orders the scripts but i think i will over time.

thanks again for this. i'm only ~six weeks into experience with modifying android and a few days with linux pc but i feel like i can learn in leaps. i've been looking at code and script from other phones to see what's different. i may have discovered a new hobby.

new op, i've found, while making a2sd work, that the ext4 rom doesn't like bml mount in cwm scripts. that's why the ext4 rom is the only one you need to manually mount partitions for the installer now. i know what you mean about downtime. i have a broken one from a friend i've been using to test things. he tried to rig up an external antenna and broke the cell radio. wifi still works though so i just don't know if anything i do has an affect on reception until i flash it to MY phone. handy.

can't wait to get another phone to start doing all this again.
Nice job, I would love to have a look at what you did.

I have been so busy looking at the code and trying this and trying that. Most of what I can do is just from looking at what someone else has done and modifiing to suit me.

by the way I found a script to set the sd card read ahead cache place it in init.d and it will set it you dont have to have an app to do it and the benefit is its set before the screen is up and ready. I have a class 10 card and having the read ahead set to 3072 is very handy.
I tried building it into the kernel, in init.rc but it never worked, even when the kernel still booted. tried with hroarks and with shabby's and both booted after but no change in read ahead.
Code:
#!/system/bin/sh
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]
  then
    /system/xbin/echo "3072" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
fi;
for hroarks I named mine S77sdcardspeedfix
chose that to not interfere with other scripts
 
Upvote 0
the 2 modules needed for ext4 support are the ext4.ko and the jb2.ko

those two modules that came with my kernel are for this phone, I was able to compile them with the kernel source code for this phone

you can compile other kernel modules for this phone if you dowload the source code, you probably will not be able to compile a bootable zImage, but should be able to do some modules, but as I said berfore, we are working with a size limit, i did compile the ext3.ko and jbd.ko but when i added them to the ramdisk it was too big
 
Upvote 0
the 2 modules needed for ext4 support are the ext4.ko and the jb2.ko

those two modules that came with my kernel are for this phone, I was able to compile them with the kernel source code for this phone

you can compile other kernel modules for this phone if you dowload the source code, you probably will not be able to compile a bootable zImage, but should be able to do some modules, but as I said berfore, we are working with a size limit, i did compile the ext3.ko and jbd.ko but when i added them to the ramdisk it was too big
I have 2 questions, now that I see this new info.

First the jbd.ko for ext4 wont work with ext3?

for example if you want ext3 and ext4 could you just use the one jbd.ko?

and second from the way you say it became too big is it because of the 2 extra .ko modules? or would even one make it too big?

Can you upload the compiled ext3 that you have I would like to look at a few things.

There might be other areas to trim down maybe.
 
Upvote 0
I will edit the OP again and mention Python 2.7
Shabby's RC1 kernel and mine do init.d totally different, I am not sure which is better, and I dont think i matters too much.

are only S## scripts running or can the script be any name now

I made the repacker so that curios people like yourself can mess around with it and learn, and maybe come up with some creative mods

shabbykernel init.d will now execute script of any name. no letters or numbers required.
i took a few hints and the modules from hk12 and put a kernel together that uses shabby init.d method, mounts ext4, doesn't require install-recovery.sh and has v6 agressive minfrees default. a few more tweaks and i may post it for others to try.
i'm an auto mechanic and machine fabricator by trade and my motto is less moving parts makes life easier so i like the init.d in shabby's for not referencing another script. just personal preference. both ways work fine.
i don't understand how his orders the scripts but i think i will over time.

thanks again for this. i'm only ~six weeks into experience with modifying android and a few days with linux pc but i feel like i can learn in leaps. i've been looking at code and script from other phones to see what's different. i may have discovered a new hobby.

new op, i've found, while making a2sd work, that the ext4 rom doesn't like bml mount in cwm scripts. that's why the ext4 rom is the only one you need to manually mount partitions for the installer now. i know what you mean about downtime. i have a broken one from a friend i've been using to test things. he tried to rig up an external antenna and broke the cell radio. wifi still works though so i just don't know if anything i do has an affect on reception until i flash it to MY phone. handy.

can't wait to get another phone to start doing all this again.
Well I found out why they do them differently.

I also found why hroarks require S* to boot.

In Shabbys init.rc has this line

Code:
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
    enable
    oneshot

Which if im not mistaken, (and I sure could be) init.d is called by busybox as part of the addons in something like android kitchen.
and hroarks uses a script

Code:
#!/tmp/busybox sh

if cd /system/etc/init.d >/dev/null 2>&1 ; then
    for file in S* ; do
        if ! ls "$file" >/dev/null 2>&1 ; then continue ; fi
        /system/bin/sh "$file"
    done
fi
also from busybox but in a tmp location, more of a hack on I guess you may call it. and as you can see the script calls for S* in order to run.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones