[HOWTO] Enable init.d on stock *rooted* Desire roms

Search This thread

moebius83

Senior Member
Dec 19, 2010
96
30
Bologna
If you are like me and you like your stock Desire rom, you rooted it using unrEVOked or some other methods, you made some custom adjustment to it and you really don't want to load a fully fledged 3rd party rom but still, you'd like to tweak it a little bit more, you'll quickly realize that you are going to need a working init.d system in order to start custom scripts on boot.
This thread will try to explain how to add init.d support to your rom, without needing to flash a new rom and wipe everything, we're just going to flash a new boot.img.

Requirements
  • Rooted HTC Desire
  • New modified boot.img, supported firmware versions: 2.10.405.2, 2.29.405.2/5, check your firmware version here: (Settings -> About Phone -> Software information -> Software number)
    Download this one: View attachment boot_2.10.405.2.zip if your "Software number" is: 2.10.405.2
    Download this one: View attachment boot_2.29.405.2_5.zip if your "Software number" is: 2.29.405.2 or 2.29.405.5
    Make sure you download the one matching your "Software number", the wrong one will cause boot loops and weird behaviors.
  • ADB shell access
  • flash_image binary, usually provided by unrEVOked under /data/local/flash_image but if you don't have grab it here: View attachment flash_image.zip
  • busybox correctly installed under /system/xbin

HOW-TO

NOTE: if your Desire is not S-OFF (meaning you can't write to the /system directory), you'll need to do the whole procedure in recovery mode.

  1. Do a nandroid backup, this in order to save your current boot.img, and also because it's never a bad idea :)
  2. Make sure the nandroid backup went ok
  3. Check your exact firmware version (Settings -> About Phone -> Software information -> Software number) and download the corresponding modified boot.img
  4. Copy and unzip the downloaded boot.img to your sdcard or wherever you like it
  5. Obtain adb shell access, become root (su) and wipe the existing boot image with:
    Code:
    cat /dev/zero > /dev/mtd/mtd2
    ignore the "write: No space left on device", it's normal.
  6. Flash the new boot image:
    Code:
    flash_image boot /sdcard/boot.img
    where "/sdcard/boot.img" is the path where you copied the downloaded boot.img
  7. Remount the /system partition read-write if you're not in recovery mode:
    Code:
    mount -o remount,rw /system
    or mount it if you are in recovery mode:
    Code:
    mount /system
  8. Create the init.d directory where all the custom boot scripts will be executed:
    Code:
    mkdir /system/etc/init.d
    and set permissions:
    Code:
    chmod 755 /system/etc/init.d
  9. Important: unzip and copy the View attachment 99complete.zip script to the newly created /system/etc/init.d/99complete, set permissions:
    Code:
    chmod 755 /system/etc/init.d/99complete
    and ownership:
    Code:
    chown root.shell /system/etc/init.d/99complete
    Failure to do so will cause a boot loops.
  10. Cross your fingers and reboot! If anything goes wrong you can always boot into recovery and fix errors or you can restore the nandroid backup (you can just restore the boot.img if you don't want to do a full restore).

From now on, every script you put inside /system/etc/init.d will be executed at boot before almost any other initializations. Make sure you set the correct permissions to your scripts (i.e. 755).

Thanks to: teppic74 for providing stock roms with init.d support (thread) where I extracted the boot images.
 
Last edited:

moebius83

Senior Member
Dec 19, 2010
96
30
Bologna
Technical explanation

The provided boot.img are the original HTC provided boot.img with the init.rc script modified to stop the init process until the cm.filesystem.ready property is set to 1:

Code:
    start sysinit                     

on property:cm.filesystem.ready=1
    class_start default

where the sysinit service is the service in charge of starting all the scripts inside /etc/init.d:

Code:
# Execute files in /etc/init.d before booting
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
    disabled                         
    oneshot

and the last of this script, 99completed, only sets that property to 1 so the normal system boot can continue:

Code:
#!/system/bin/sh

sync;
setprop cm.filesystem.ready 1;

of course changing init.rc is only possible by flashing a new boot.img with init.rc modified inside the ramdisk because that file, even if you can see it under / will be overwritten at every boot.

Another small modification of the new boot.img is the default.prop, in which rc.secure is set to 0 allowing to gain direct access through "adb shell"
 

Puenos

Senior Member
Aug 20, 2010
150
15
Sounds great :D
Thx for your work!

So if I get that right, it's the same as if we'd flash teppic74 ROM, and nandrestoring everything except system & boot?
Just our stock ROM with init.d support?
Does that also mean we could flash the optional mods from teppic74 thread like a2sd? :)

Ty again!
 

Puenos

Senior Member
Aug 20, 2010
150
15
Really? I would have tried flashing either a2sd provided in teppic74's thread or even a2sd script by DT? last I would have compared to firerat's script. But if all you need to do is pushing via adb.. Is there a script out for a2sd especially for stock/sense? (like kali advised using firerat with CM?)

Thank you :)
 

Puenos

Senior Member
Aug 20, 2010
150
15
I'm just using Sense because of it's Mail-widget, haha :)

But I guess I'll just give it a try then, will report back, when I've managed so set everything up without having my phone exploding, hehe

But thank you very much :)
 

moebius83

Senior Member
Dec 19, 2010
96
30
Bologna
exactly this boot.img will just enable init.d support, no need to flash a new system.img but you just need to create the init.d directory and put the 99complete script, after that you can install any mod you like, also the ones provided in teppic74's thread.
You can also try data2whatever by melethron (that's what I'm using), just make sure you have busybox correctly installed.
hope you enjoy it and happy new year!
 

moebius83

Senior Member
Dec 19, 2010
96
30
Bologna
well I hv software number 2.11.832.3 so what I hv to do...?

unfortunately I don't have a boot.img for that software number, you'll need to manually extract your boot.img, modify a file (init.rc) and reflash it, if you don't know how to do it I can try to do it for you but I'll need a download link for your original firmware version
 

worstenbrood

Senior Member
May 14, 2008
1,069
1,417
OnePlus 7 Pro
You could make a universal (froyo) update zip using Koush's AnyKernel installer, then you're able to update the ramdisk only and add the init.d folder/script. Thats how i did it for CM7.
 

moebius83

Senior Member
Dec 19, 2010
96
30
Bologna
You could make a universal (froyo) update zip using Koush's AnyKernel installer, then you're able to update the ramdisk only and add the init.d folder/script. Thats how i did it for CM7.

interesting, an update script that can extract the boot.img, unpack, change files, repack it and reflash it...is it safe? I may think about building an update.zip this way but I'm pretty scared by how safe it can be to automatically mess with a boot.img..

EDIT: one problem of this is that the init.rc needs to be extracted and modified, but it may be different from one firmware and another
 
Last edited:

worstenbrood

Senior Member
May 14, 2008
1,069
1,417
OnePlus 7 Pro
interesting, an update script that can extract the boot.img, unpack, change files, repack it and reflash it...is it safe? I may think about building an update.zip this way but I'm pretty scared by how safe it can be to automatically mess with a boot.img..

EDIT: one problem of this is that the init.rc needs to be extracted and modified, but it may be different from one firmware and another

Should be the same between all froyo rom's. Check this update zip, it's for gingerbread tho, you have to replace the ramdisk-new.gz with a froyo one (with edited init.rc offcourse). It also contains /system/etc/init.d/99complete.

Edit: Don't be scared, everyone who releases custom kernels uses this method. The other way around then, keep the original ramdisk and merge it with the new kernel.
 

Attachments

  • update-init.d.zip
    437.8 KB · Views: 195
Last edited:

docnasef

Senior Member
Apr 25, 2009
194
17
Hello there

Really appreciate all your efforts

Kindaa feeling real dumb in comparison! lol

Anyways
My Desire specs :
2.2
2.32.415.3
Baseband 32.49.00.32U_5.11.05.27


Now this has built in arabic enabled support and that is the main reason I would like to keep it
Am yet to run into a custom ROM that would provide that without having to downgrade my version

Also, had a lotta fun trying to root, just couldn't root, up untill a few days back when unrevoked came out with thier new 3.3 version

I noticed you had only two software versions from which to start...
So what about my case? could you please help this newbie along?!!
 

mumu_li

Member
Jan 4, 2011
24
0
Shanghai
Hello there

Really appreciate all your efforts

Kindaa feeling real dumb in comparison! lol

Anyways
My Desire specs :
2.2
2.32.415.3
Baseband 32.49.00.32U_5.11.05.27


Now this has built in arabic enabled support and that is the main reason I would like to keep it
Am yet to run into a custom ROM that would provide that without having to downgrade my version

Also, had a lotta fun trying to root, just couldn't root, up untill a few days back when unrevoked came out with thier new 3.3 version

I noticed you had only two software versions from which to start...
So what about my case? could you please help this newbie along?!!

Same thing happens to me. My spec:
2.2
2.13.707.1
32.44.00.32U

Can you help as well? Or where or how (from RUU) can I find the ramdisk-new.gz as worstenbrood's mention.
 

mumu_li

Member
Jan 4, 2011
24
0
Shanghai
Same thing happens to me. My spec:
2.2
2.13.707.1
32.44.00.32U

Can you help as well? Or where or how (from RUU) can I find the ramdisk-new.gz as worstenbrood's mention.

Thanks "worstenbrood" then I can extract boot.img from stock rom. Based on the guide, I made a new boot.img. But with this new boot.img, the phone hangs at the first screen(waiting at least for 15 mins). I don't know why. I also did as worstenbrood suggest and the system boot loopless.

Can somebody help?

I attached my boot.img (original and modified) for your information.
 

Attachments

  • boot.rar
    4.7 MB · Views: 150

moebius83

Senior Member
Dec 19, 2010
96
30
Bologna
Thanks "worstenbrood" then I can extract boot.img from stock rom. Based on the guide, I made a new boot.img. But with this new boot.img, the phone hangs at the first screen(waiting at least for 15 mins). I don't know why. I also did as worstenbrood suggest and the system boot loopless.

Can somebody help?

I attached my boot.img (original and modified) for your information.

did you create the /system/etc/init.d directory and the 99complete file with the correct permissions? as noted on the OP this is needed because that file will tell the boot process to continue, otherwise you'll be stuck at the boot screen

EDIT: also, do you have busybox installed under /system/xbin?
 
Last edited:

docnasef

Senior Member
Apr 25, 2009
194
17
Hello there

Really appreciate all your efforts

Kindaa feeling real dumb in comparison! lol

Anyways
My Desire specs :
2.2
2.32.415.3
Baseband 32.49.00.32U_5.11.05.27


Now this has built in arabic enabled support and that is the main reason I would like to keep it
Am yet to run into a custom ROM that would provide that without having to downgrade my version

Also, had a lotta fun trying to root, just couldn't root, up untill a few days back when unrevoked came out with thier new 3.3 version

I noticed you had only two software versions from which to start...
So what about my case? could you please help this newbie along?!!


@ moebius83

If you could help, I would really appreciate it...
Please take into consideration That I am more or less android dumb! :)

I attached the url for my original RUU if that helps?

http://www.mediafire.com/?ih3lbbm7yfag7d2

Would REALLY appreciate your help.

Thanks m8!
 

worstenbrood

Senior Member
May 14, 2008
1,069
1,417
OnePlus 7 Pro
Thanks "worstenbrood" then I can extract boot.img from stock rom. Based on the guide, I made a new boot.img. But with this new boot.img, the phone hangs at the first screen(waiting at least for 15 mins). I don't know why. I also did as worstenbrood suggest and the system boot loopless.

Can somebody help?

I attached my boot.img (original and modified) for your information.

i created a update.zip which replaces the ramdisk only and add /system/etc/init.d/99complete. It should work for every froyo release.
 

Attachments

  • update-froyo-init.d-signed.zip
    462.2 KB · Views: 201

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    If you are like me and you like your stock Desire rom, you rooted it using unrEVOked or some other methods, you made some custom adjustment to it and you really don't want to load a fully fledged 3rd party rom but still, you'd like to tweak it a little bit more, you'll quickly realize that you are going to need a working init.d system in order to start custom scripts on boot.
    This thread will try to explain how to add init.d support to your rom, without needing to flash a new rom and wipe everything, we're just going to flash a new boot.img.

    Requirements
    • Rooted HTC Desire
    • New modified boot.img, supported firmware versions: 2.10.405.2, 2.29.405.2/5, check your firmware version here: (Settings -> About Phone -> Software information -> Software number)
      Download this one: View attachment boot_2.10.405.2.zip if your "Software number" is: 2.10.405.2
      Download this one: View attachment boot_2.29.405.2_5.zip if your "Software number" is: 2.29.405.2 or 2.29.405.5
      Make sure you download the one matching your "Software number", the wrong one will cause boot loops and weird behaviors.
    • ADB shell access
    • flash_image binary, usually provided by unrEVOked under /data/local/flash_image but if you don't have grab it here: View attachment flash_image.zip
    • busybox correctly installed under /system/xbin

    HOW-TO

    NOTE: if your Desire is not S-OFF (meaning you can't write to the /system directory), you'll need to do the whole procedure in recovery mode.

    1. Do a nandroid backup, this in order to save your current boot.img, and also because it's never a bad idea :)
    2. Make sure the nandroid backup went ok
    3. Check your exact firmware version (Settings -> About Phone -> Software information -> Software number) and download the corresponding modified boot.img
    4. Copy and unzip the downloaded boot.img to your sdcard or wherever you like it
    5. Obtain adb shell access, become root (su) and wipe the existing boot image with:
      Code:
      cat /dev/zero > /dev/mtd/mtd2
      ignore the "write: No space left on device", it's normal.
    6. Flash the new boot image:
      Code:
      flash_image boot /sdcard/boot.img
      where "/sdcard/boot.img" is the path where you copied the downloaded boot.img
    7. Remount the /system partition read-write if you're not in recovery mode:
      Code:
      mount -o remount,rw /system
      or mount it if you are in recovery mode:
      Code:
      mount /system
    8. Create the init.d directory where all the custom boot scripts will be executed:
      Code:
      mkdir /system/etc/init.d
      and set permissions:
      Code:
      chmod 755 /system/etc/init.d
    9. Important: unzip and copy the View attachment 99complete.zip script to the newly created /system/etc/init.d/99complete, set permissions:
      Code:
      chmod 755 /system/etc/init.d/99complete
      and ownership:
      Code:
      chown root.shell /system/etc/init.d/99complete
      Failure to do so will cause a boot loops.
    10. Cross your fingers and reboot! If anything goes wrong you can always boot into recovery and fix errors or you can restore the nandroid backup (you can just restore the boot.img if you don't want to do a full restore).

    From now on, every script you put inside /system/etc/init.d will be executed at boot before almost any other initializations. Make sure you set the correct permissions to your scripts (i.e. 755).

    Thanks to: teppic74 for providing stock roms with init.d support (thread) where I extracted the boot images.
    3
    Technical explanation

    The provided boot.img are the original HTC provided boot.img with the init.rc script modified to stop the init process until the cm.filesystem.ready property is set to 1:

    Code:
        start sysinit                     
    
    on property:cm.filesystem.ready=1
        class_start default

    where the sysinit service is the service in charge of starting all the scripts inside /etc/init.d:

    Code:
    # Execute files in /etc/init.d before booting
    service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
        disabled                         
        oneshot

    and the last of this script, 99completed, only sets that property to 1 so the normal system boot can continue:

    Code:
    #!/system/bin/sh
    
    sync;
    setprop cm.filesystem.ready 1;

    of course changing init.rc is only possible by flashing a new boot.img with init.rc modified inside the ramdisk because that file, even if you can see it under / will be overwritten at every boot.

    Another small modification of the new boot.img is the default.prop, in which rc.secure is set to 0 allowing to gain direct access through "adb shell"
    2
    Thanks "worstenbrood" then I can extract boot.img from stock rom. Based on the guide, I made a new boot.img. But with this new boot.img, the phone hangs at the first screen(waiting at least for 15 mins). I don't know why. I also did as worstenbrood suggest and the system boot loopless.

    Can somebody help?

    I attached my boot.img (original and modified) for your information.

    i created a update.zip which replaces the ramdisk only and add /system/etc/init.d/99complete. It should work for every froyo release.
    1
    Sounds great :D

    Does that also mean we could flash the optional mods from teppic74 thread like a2sd? :)

    Ty again!

    Well you could but effectively all you need is an apps2sd+ script and you can adb push it to the correct location. /system/etc/init.d
    1
    Really appreciate all your help so far...

    Added the zip file to my root sd card

    flashed thro cwm recovery gave me success message
    HOWEVER on rebooting got stuck with the white screen with green HTC Logo?!:(


    Pulled battery out after 20 mins tried normal power button reboot no such luck..
    went back to nandroid back up....

    any help?
    is there a "file editor" where I can edit/add manually the directories I need which you may suggest?

    thanks for everything!

    one other thing you need is busybox in /system/xbin ...

    Try this, it also includes busybox :