BootBuddy - Run Boot Scripts from SDcard (a safe alternative to init.d)

Last Updated:

  1. Sepero

    Sepero Linux Guru

    (The OLD BootBuddy thread can be found here)

    Due to lack of time, BootBuddy has limited development support from me for now. BootBuddy was originally designed to work on a select number of LG phones (Motion, Spirit, L9) but may work for many others. The code is open source and anyone may contribute to development if they choose. I would be happy to feature your updates and I welcome support for new devices. Cheers.

    Boot Buddy will allow you to run Linux shell scripts when your Android device is booting up. It will run your scripts early in the boot process, before the home screen appears.

    The intended audience is generally intermediate to advanced users, and those who want to play with shell scripting on their device.

    BootBuddy is similar to init.d scripts, but with a core difference that it stores boot scripts on your SDcard instead of the internal system. This allows for several interesting enhancements. Feature listing-

    • Much more Safe than init.d. If you have a script that is malfunctioning, just boot with the sdcard out, and put the sdcard back in after your device reaches home screen. Your device is Saved, No Problem!
    • Boot Buddy is designed from the start to run scripts right from your SDcard. Just download any scripts to your boot_buddy_scripts directory and they're ready to run. (No more screwing around with permissions and files in your /system/etc/init.d/*)
    • SDcard storage allows you to copy a script to another device, or multiple devices easily.
    • Boot Buddy's author has several years of scripting and programming experience. It is streamlined, fast, and doesn't perform worthless functions like repeatedly logging the authors name and time.
    • Clear goals of making operation simple, intuitive, and clean.
    • If you're currently using an "init.d" solution, BootBuddy can integrate seamlessly with it.
    • If you try BootBuddy and you don't like it, the installer also works as an uninstaller for easy clean removal.
    • BootBuddy is Open Source GNU GPL. Open for anyone to modify and improve upon.
    As a developer, I make software to operate the way I would want if I were an end user, because I actually do use it, and I am an end user like you.



    1. Start Script Manager, and allow/grant root access.
    2. Navigate to the file.
    3. Tap on the file to show the menu options.
    4. At the top, highlight the "Su" icon.
    5. On the top-left, tap "Run".
    The script will run quickly. It will automatically detect your sdcard location and create a folder on your sdcard named "boot_buddy_scripts". In that folder, you put the scripts you want to run at system boot. A log file will be kept at /data/boot_buddy.log

    If you need your scripts to run in order, they are ordered by filename using the busybox "sort" program. They will run in alphabetical order using this format 0-9A-Za-z.

    Here are a couple example scripts you may use.

    The Android /system is normally mounted with read-only permissions by default. We will change that with the first script listed below. It will cause /system to be remounted to read-write permissions during boot.

    The second script will create a file at every boot named /mnt/sdcard/sys_mount_info.txt. That txt file will give us information about how /system is currently mounted.

    1. Download the file into your boot_buddy_scripts folder.
    2. Download the file into your boot_buddy_scripts folder.
    3. Reboot your phone.
    That's it, you just installed 2 new scripts and had them run at boot. It's Really just that simple to add startup scripts to your system.

    To verify they are running, use any text viewer to open the file /mnt/sdcard/sys_mount_info.txt. It may show more than one line of text. There should be a line similar to this:
    /dev/block/(device specific text) /system (fstype) rw,(more text)

    The rw means that /system was successfully remounted as read-write during boot.

    At any time you can delete either script if you choose. Easy!

    If for any reason you find you don't want or don't like Boot Buddy, you can cleanly uninstall it using the installer These instructions are almost identical to installing. (All match the installation steps, except step 4)

    1. Start Script Manager, and allow/grant root access.
    2. Navigate to the file.
    3. Tap on the file to show the menu options.
    4. ** Type --uninstall in the text area labeled Arguments.
    5. At the top, highlight the "Su" icon.
    6. On the top-left, tap "Run".
    Boot Buddy will be uninstalled. It will not remove the contents of your boot_buddy_scripts folder. If you have an "init.d" system installed, it will cleanly remove only Boot Buddy parts and leave the rest.

    Boot Buddy will Not cause harm to your system, but it may not work on custom roms. Also, it may fail to detect the real location of your SDcard. It requires that /system/etc/ is run during the boot process, and that file will be created if it does not exist. Also the file /data/ will be created. The script /system/etc/ will run /data/ The script /data/ will run the scripts on your sdcard. The file /data/boot_buddy.log will log any script output.

    For Windows and Mac users- If you download the installer to your pc first, do not edit the installer with a text editor. Your computer will add hidden markers at the ends of each line that will prevent the installer from running. If you want to edit it, you should do so on a Linux pc or directly on your Android device.

    Tell us about your results!!! :)

    BootBuddy source code:

    tigerstown, DNRDustin, sammyz and 4 others like this.
  2. Sepero

    Sepero Linux Guru

    (Mention your script and get listed here)

    Device specific scripts:


    For maximum compatibility with BootBuddy your script should be able to run with the standard busybox shell, and simply have a file name in the following format-

    NN- A 2 digit number like "00", to indicated how soon or late a script should run in relation to other scripts. If the internal sdcard mount location is moved, it should be done at the prefix "50". Your script must run as prefix "49" or earlier to access the sdcard at it's default location ("51" or later at the moved location). If you are unsure what to use, most general scripts will be safe with the digit prefix "10".

    aaaaa_aaaaa- This is the name of the script. It should be in all lowercase, and may use letters, numbers, periods, and underscores. An underscore_ should be used to separate words. For example "10my_fancy_script_v1.5"
    pmb116 and twogbsd like this.
  3. rhino889a

    rhino889a Well-Known Member

    This is fricken awesome. Once i get the concept of writing scripts and finding premade scripts i will totally utilize this .
    My daily entertainment phone . Movies ,music browsing emails text.
    Toss in a different sdcard and my phone is an agressive machine set for more serious functions.Within 2 minutes my playstation is nasa server

    My new script wasnt coded properly crap, yank sd and everything is fine. I think this has far more value than people think
    This is more for people that look at thier phone as laptop and not just a phone.
    And i was never asked to pay for it.
  4. funkyman

    funkyman Well-Known Member

    Color me stupid, but can i drag and drop any script i find to be safe for the device on the boot buddy scripts folder, or do you need to modify that script to work with boot buddy? i noticed that all the scripts so far that are for boot buddy end with .sh and im a noob so i am not familiar with this.
  5. Sepero

    Sepero Linux Guru

    The .sh extension refers to "SHell script". Linux scripts often have this extension, but it's not 100% necessary. Scripts may have another extension, or no file extension at all and still be able to run just the same.

    If the script creator says that the script will work with BootBuddy (or init.d), and the script is made for your device, then it should be safe.

    Doing anything else is at your own risk.
    funkyman likes this.
  6. Sepero

    Sepero Linux Guru

    Yes, you will want to write your code in this format

    Code (Text):
    1. # Wrap the delayed code in a function so it doesn't stop other scripts.
    2. delayed_code () {
    3.     busybox sleep 10 # Waits for 10 seconds.
    4.     ## The code you want to run after waiting ##
    5. }
    7. # The & sign tells it to run the function in the background so that other scripts can continue.
    8. delayed_code &
  7. rhino889a

    rhino889a Well-Known Member

    Thanks alot this will help greatly
    When i get a script running with this i will post a copy. As i think certain settings will need this feature.
  8. rhino889a

    rhino889a Well-Known Member

    So would it be safe to say the busybox sleep number can be modified in the in /data
    To put a delay on every script in the bb folder?
  9. Sepero

    Sepero Linux Guru

    The BootBuddy script is located at /data/

    Feel free to edit it at your own risk. BootBuddy has it's own delay currently. Every 1 second it will check to see if the sdcard has been mounted. After the sdcard has been found as mounted, it will then proceed to run all the scripts in the boot_buddy_scripts folder.
  10. rhino889a

    rhino889a Well-Known Member

    Thank you
    And i wanted to add something about boot buddy that can be very valuable in the future

    You can install BootBuddy now ,even if you have absolutley no intentention of using it

    Next month you may have some issue with your phone

    Maybe you dont have current backup and may lose valuable info if you unbrick
    Maybe a little script can be run by bootbuddy at boot to correct the problem

    Like this guy who installed a galaxy voice app that screwed his phone up.he installed as system app so reset wont fix

    He will probably have to unbrick since he has no recovery

    If he had bootbuddy ,a simpke
    Mount system/app/galaxy whatever
    Rm system/app/galaxy whatever

    Or sometging like that i guess
  11. Xieon

    Xieon Well-Known Member

    I use Rom Toolbox Pro, and I had App2SD set to "external". If you use this program, or a similar app2sd program you must set it to "AUTOMATIC" or it will not work. I switched it to automatic, and the program installed flawlessly, without even needing a reset.

    Left below for reference
    I spent a while messing around with BootBuddy to get it back to the way I wanted it to function, now I'm getting errors when I try to install apps, says I have no free memory.

    Maybe move interal_fs to sdcard? (
    Sepero likes this.
  12. TOMOTH

    TOMOTH Member

    Hello Everyone;

    Well - I'm sorry I didn't see this thread sooner: it would have saved me a lot of time fighting the system.

    After about 3 days worth of hacking around, my environment works the way I want it to and I got <crond> and <crontab> to work.


    o / and /system mount as read-write.

    o tcsh starts up and reads the .tcshrc file.

    o I can run cron jobs.

    o my external memory card is known as sdcard1 instead of extSdCard.

  13. Sepero

    Sepero Linux Guru

    Very cool. Thanks for sharing!
  14. JPowers2112

    JPowers2112 Member

    BootBuddy didn't even install, so there's nothing to uninstall. I had the phone turned on overnight, and the script was still running.
  15. veletron

    veletron Member

    Just a note to folks that if, when trying this, you get errors about 'sed' or other linux command line apps then you need to install/update busybox to get the latest linux packages or to add those that are missing. Download: and run the app on the device to install/update busybox.

    Sepero likes this.
  16. rhino889a

    rhino889a Well-Known Member

    i been trying to get this running on my motion
    But it wont execute scripts from my sd card
    BB instaled fine. have 775 perms for bb folder on my external sd
    but they wont execute. when i run the i get Cant find sh applet
    logs say Running the file but cant find .sh
    Funny thing is i can run scripts directky from the sd card
    I am running firmwarw F ,busybox 1.22.1,Gamwrheorys OC kernel
    I tried modifying the mount file in Proc but it doesnt stick
    Anybody have a clue?

    it just not letting the system execute any of my files
  17. Sepero

    Sepero Linux Guru

  18. rhino889a

    rhino889a Well-Known Member

    well i can execute the scripts directly from inside the boot buddy folder on my sd card
    But have negative results at boot up
    i even executed the install then i executed the script in /data
    i also tried to execute the sxripts on my sd card through terminal emulator which told me Pernission Denied
    Even though the sd folder and scripts show full permissions ,I am not able to execute them from the system
  19. rhino889a

    rhino889a Well-Known Member

    i am wondering if there may be i ssues with the latest busybox
    i just installed this to ny l9 with same issues

    both have the latest busybox installed to xbin
    installs seem to work fine as i dont seem to be having any other troubles
    oh well i will keep tinkeriing with it
  20. Sepero

    Sepero Linux Guru

    Boot buddy doesn't require scripts to have executable permission.

    Short explanation:
    Boot buddy executes a new shell instance, and feeds the script into it.

    Long explanation:
    Sdcards usually do not support executable permissions, because they are vfat (windows fat32) filesystem. Fat32 filesystems do not recognize executable flags. On Windows, anything can be executable if you just name it *.exe. For Android (Linux), special mounting is required to allow executing files (and it would result in every file on the sdcard becoming executable). Because of this, it's just easier to execute a new busybox shell and give it the script to read.

    Hopefully that answers some questions for ya. Best of luck getting it resolved.
  21. rhino889a

    rhino889a Well-Known Member


    Note for lg motion
    if you use Pathkicks Lte2VU2 2nd init (2nd version) cwm recovery
    Every single time you use the app
    IT installs Busybox 1.81.1
    i made a modified app that no longer does this
  22. rhino889a

    rhino889a Well-Known Member

    so on my L9
    there was not an sh in the xbin folder
    so i copied sh from my bin folder and pasted to xbin
    then in the bootbuddy script in data,i removed (busybox) from the (busybox sh) line
    now it works for me

    Now my motion has an sh in xbin and it shows it linked to busybox
    so i am gonna work on it next
  23. rhino889a

    rhino889a Well-Known Member

    on mt motion
    copied sh from bin pasted in xbin
    removed (busybox) from (busybox sh) lines from the data/boot_buddy script
    changed the log to go to the sdcard
    works great

    then i moved the data/ to my bin folder
    remived .sh from
    then i changed lines to this


    bootbuddy no longer exists in data

    now i have gametheorys kernel on my motion it has sysinit as a boot service
    so i use it to exec bootbuddy instead of install_recovery_sh

    now i am going to see if i can add run parts and logwrapper to view script exec results in logcat
  24. Sepero

    Sepero Linux Guru

    Hey rhino889a,
    If you found the answer to your problem, it would be good if you posted it for others. It looks like it may have helped you to install busybox into /system/xbin (instead of /system/bin)

    Not sure
  25. divinebovine

    divinebovine Well-Known Member Contributor

    rhino889a, why did you edit your posts down to nothing?
    Sepero and scary alien like this.

Share This Page