[Epic 4G Android Development] chris41g:
Even though I put this in the Epic forum, this will work on any zImage based android kernel as far as I am aware.. from Eclair to Gingerbread, maybe previous, maybe in the future..

I will post my tweaks here (please give credit), and even my ext4 modules (again please give credit, to both me and Rodderik, as he helped with one of them) for Gingerbread.

First off, you will need either a linux based computer, a remote linux box, or a virtual machine.. I don't think cygwin will be enough. I'm not going to go through the steps of setting that up because it's out of the scope of this How-to, maybe in another post.

Second, you need some scripts to decompile the initramfs from the kernel, or you can do it manually with grep or a hex editor ( I don't recommend ), I'll provide the scripts I use, which I procured from supercurio's project voodoo github then modified to work a little better with zImages that have 2 signatures (happens sometimes) like EH06...

http://chris41g.devphone.org/voodoo.tar.gz

in voodoo/config.sh you will need to set your compiler path.

also read the readme.txt it will pretty much describe how it all works, and remember all the gingebread leaks only work with gzip compression when repacking.

to unpack the initramfs

./extracter.sh -s "/path/to/original/zImage" -d "/path/where/you/want/initramfs/"

and after a few minutes your initramfs will be wherever you told it to go with -d.

now the initramfs is pretty much the meat and potatoes when repacking a kernel.

adding EXT4

this is a pretty popular request...

to do this you need just a few things, the correct modules, and the correct mount options. both of which i will provide.

the modules for Gingerbread are called ext4.ko and mbcache.ko and need to added to lib/modules in the initramfs - link http://chris41g.devphone.org/gbext4modules.tar.gz

then the following lines need to be added to init.rc lpm.rc and recovery.rc

insmod /lib/modules/mbcache.ko
insmod /lib/modules/ext4.ko

right around the lines that look like

insmod /lib/modules/fsr.ko
insmod /lib/modules/fsr_stl.ko
insmod /lib/modules/rfs_glue.ko
insmod /lib/modules/rfs_fat.ko

to the same files look for:

mount rfs /dev/block/stl9 /system check=no

and under it add

mount ext4 /dev/block/stl9 /system noatime nodiratime errors=continue

now in init.rc and recovery.rc look for

mount rfs /dev/block/stl10 /data nosuid nodev crypt check=no

and under it add

mount ext4 /dev/block/stl10 /data nosuid nodev crypt noatime nodiratime

and look for

mount rfs /dev/block/stl11 /cache nosuid nodev check=no

and under it add

mount ext4 /dev/block/stl11 /cache nosuid nodev noatime nodiratime errors=continue nobh data=writeback barrier=0 noauto_da_alloc

now usually there will be some stuff you need to comment out.. which means adding # to the beginning of the line..

i always comment this out because it can mess with my tweaks later on and its useless

mount rfs /dev/block/stl9 /system ro remount

i also comment out or delete left over stuff for other phones that samsung has a habit of leaving in our init.rc... lazy people..

How to Root a Kernel Re-Pack:

This may seem basic, and to some it is, but I'm going to cover it anyway. Also it has changed in gingerbread, as you can't suid anything in /sbin, and that is the beginning of your PATH.

First we need some files.

su binary Stable - http://xdaforums.com/showthread.php?t=682828 Beta - http://chris41g.devphone.org/su3.tar.gz

Superuser.apk Beta - http://chris41g.devphone.org/Superuser.apk

busybox binary (this one is dependent on whether you have purple cwm built in or not, since we havent got that far ill assume you dont) busybox 1.20.0 compiled by me http://chris41g.devphone.org/busybox

copy those files into /sbin in the initramfs, also do a

ln -s busybox sh

from the sbin directory in your initramfs on your linux box to make a symlink from sh to busybox

then goto the initramfs root

and do

ln -s sbin bin

to make a symlink from sbin to bin, it's probably not necessary but i always do it for consistency.

now go into /sbin and make a new sh script called whatever you want.

#!/system/bin/sh
# Remount filesystems RW
busybox mount -o remount,rw /
busybox mount -o remount,rw /system
#install busybox links
busybox cp /sbin/busybox /system/bin/busybox
/system/bin/busybox rm /sbin/busybox
busybox --install -s /system/bin
busybox --install -s /system/xbin
#establish root
busybox cp -f /sbin/su /system/bin/su
chmod 6755 /system/bin/su
busybox rm /sbin/su
busybox ln -s /system/bin/su /system/xbin/su
#check if Superuser.apk exist if not install but also delete bloat to make room
if [ ! -f "/system/app/Superuser.apk" ] && [ ! -f "/data/app/Superuser.apk" ] && [[ ! -f "/data/app/com.noshufou.android.su"* ]]; then
if [ -f "/system/app/Asphalt5_DEMO_ANMP_Samsung_D700_Sprint_ML.apk" ]; then
busybox rm /system/app/Asphalt5_DEMO_ANMP_Samsung_D700_Sprint_ML.apk
fi
if [ -f "/system/app/Asphalt5_DEMO_SAMSUNG_D700_Sprint_ML_330.apk" ]; then
busybox rm /system/app/Asphalt5_DEMO_SAMSUNG_D700_Sprint_ML_330.apk
fi
if [ -f "/system/app/FreeHDGameDemos.apk" ]; then
busybox rm /system/app/FreeHDGameDemos.apk
fi
busybox cp /sbin/Superuser.apk /system/app/Superuser.apk
fi
sync
# Fix screwy ownerships

for blip in conf default.prop fota.rc init init.goldfish.rc init.rc init.smdkc110.rc lib lpm.rc modules recovery.rc res sbin bin
do
chown root.shell /$blip
chown root.shell /$blip/*
done

chown root.shell /lib/modules/*
chown root.shell /res/images/*
#setup proper passwd and group files for 3rd party root access
# Thanks DevinXtreme

if [ ! -f "/system/etc/passwd" ]; then
echo "root::0:0:root:/data/local:/system/bin/sh" > /system/etc/passwd
chmod 0666 /system/etc/passwd
fi
if [ ! -f "/system/etc/group" ]; then
echo "root::0:" > /system/etc/group
chmod 0666 /system/etc/group
fi
# fix busybox DNS while system is read-write
if [ ! -f "/system/etc/resolv.conf" ]; then
echo "nameserver 8.8.8.8" >> /system/etc/resolv.conf
echo "nameserver 8.8.4.4" >> /system/etc/resolv.conf
fi
sync
# patch to prevent certain malware apps
if [ -f "/system/bin/profile" ]; then
busybox rm /system/bin/profile
fi
touch /system/bin/profile
chmod 644 /system/bin/profile
# remount read only and continue
busybox mount -o remount,ro /
busybox mount -o remount,ro /system

Now you need to make a change in your init.rc file to call this new script..

add this to your init.rc in the services section, around where the factory bootanimation service is loaded.

# Custom Script Configuration
service userscript /system/bin/sh /sbin/[whateveryounamedyour].sh
user root
group system
critical
oneshot

now you have rooted your own repack...

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Adding init.d support...

this is pretty easy, didn't want to add another post..

Let's open up /sbin/[whateveryounamedyour].sh

right after installing Superuser.apk, lets add this section...

if [ -d /system/etc/init.d ]
then
logwrapper busybox run-parts /system/etc/init.d
fi
sync

There ya go, thats it, you're done..

-----------------------------------------------------------------------------------------------------------------------------------------------

Ok, since I'm on a roll haha lets go with bootanimations... they are different on Gingerbread..

this is all done in the init.rc so lets open that up in your text editor, I recommend Geany btw..

First off in GB I had to disable stock animations to make it not look like trash, because they won't always start at the same time.. but it's your option.. ymmv

service samsungani /system/bin/samsungani
user graphics
group graphics
disabled
oneshot

Comment that section if you want to disable the stock animations... you can leave it and custom animations will still work if you want, but fair warning, its weird...

service bootanim /system/bin/bootanimation
user graphics
group graphics
critical
oneshot

Add that section to enable custom animations..

I never have but just incase you want to, you can comment this section out to disable boot sounds..

service playsound /system/bin/playsound
user media
group system
disabled
oneshot

one more thing, the new binary works, but it doesn't know when to stop playing....

add this line to the very end of the init.rc

on property:sys.boot_completed=1
stop bootanim

Thanks to tanimn for help on that one...

Now remember, before gingerbread, custom animations were bootanimation.zip, but now they are sanim.zip you can leave it that way, or for the users sake you can crack open the [whateveryounamedyour].sh and make a workaround.

add this line to [whateveryounamedyour].sh before you remount the partitions at the end.

busybox ln -s /system/media/bootanimation.zip /system/media/sanim.zip

basically what that does is create a symlink from the users bootanimation.zip to sanim.zip, so when the bootanimation binary looks for sanim.zip its redirected to bootanimation.zip.. so the user can put bootanimation.zip in the directory transparently without having to rename...

More to come, and I'm still taking request for additions to this how to....