If you are an Android enthusiast, you must be familiar with Init.d. If you don’t, today we’ll discuss the role of Init.d on Android devices. Besides, we’ll also see how we can take advantage of Init.d support to make the best use of it.
In Unix, Linux and other Unix-like operating systems, init is the first program started by the kernel at boot. It is assigned the process ID 1 and it is responsible for firing up all the other processes, being this way the parent of all the other processes running on the system. Init is also listening to signals and takes care of starting and stopping processes at events like system suspend/shutdown etc. Traditionally, init used to rely on several configuration files, saved under locations like /etc/rc.local and etc/init.d. More specifically, the init.d directory usually contained scripts that the user could run through a terminal.
For example, executing:
would start the networking interface of the system. Functionalities like these have survived on several desktop GNU/Linux distributions until today, although the init process has evolved a lot in the last years and several init replacements have been developed.
Being based on Linux, Android uses a custom init process during its boot sequence. Its functionality is very limited, covering the needs of embedded devices. Since the early releases of Android though, developers have managed to implement support for a feature similar to the original Init.d: During boot, init searches and finds scripts inside the /system/etc/init.d directory and executes them in alphanumeric order by their filename. Init.d is a custom feature, that is why it is usually not available on stock ROMs (but there is a workaround, see below).
What you can do if you have Init.d support on your device
- Modify several kernel parameters at boot time, without having to rely on an App to do it. This can save big amounts of RAM memory as well as App storage space.
- Enable swap at boot
- Create scripts that will periodically run in the background and do tasks
- Mount partitions not defined in the device’s fstab at boot. One App that uses init.d for this purpose is Link2SD, for example.
- For advanced users, native processes can be started and stopped at different events, for example when the charger is connected.
How to check if you have Init.d support on your ROM
- Use a root File Manager to navigate to /system/etc
- Check if there is a folder named init.d inside this directory
- If the folder exists (and especially if it already contains scripts inside it), your ROM most probably packs support for Init.d
- You can also use an App to check if your ROM properly supports Init.d scripts. See the next section for more information.
Enable Init.d support on any ROM
There are several ways to enable Init.d on a ROM that does not support it out of the box:
- Flashing a zip file containing the needed modifications
- Modifying system files directly
- Using an App that emulates the Init.d function
The safest way to enable init.d support on your ROM is the last one. All you need is a device with root support. In fact, there are lots of Apps on the Play Store that can emulate Init.d . The smallest and most lightweight is Universal Init.d. This App is also Open Source and can check if your ROM has native Init.d support. It also offers a built-in script editor.
Universal Init.d runs Init.d scripts successfully, except in some rare circumstances that the script has to run early in the boot process. It listens to the BOOT_COMPLETED intent of Android Framework (which the framework sends when the device enters the home screen at boot) and then executes all scripts under /system/etc/init.d directory.
Note: Universal Init.d is no longer available in the Google Play Store. Please, download the Universal Init.d APK instead.
Alternatively, you can also try the following app:
Always make a backup of your device before enabling Init.d scripts that will change kernel and file-system parameters. When you have enabled init.d support, do not forget to check our huge list of 20 build,prop tweaks to customize your Android devices and enjoy hidden features.