[Miscellaneous Android Development] alecxs:
[TUTORIAL] SCROLL DOWN BELOW TO NEXT POST

Seems i have accidentially written the nearly same Init.d Enabler like term-init.sh by Ryuinferno @ XDA.

the small different, no busybox run-parts required, and install-recovery-2.sh is used (because SuperSU is running from install-recovery.sh)

However, main intent was to increase internal memory with Bulent Akpinar's Link2SD, but without using a 2. partition.

First have installed Androguide.fr's Universal Init.d, but the scripts were executed delayed. a quick view in SuperSU daemon install-recovery.sh proposed me to write my own script, so i decided to uninstall the App. besides this i highly recommend this app! always give it a try first (i just later realized that this is another version of term-init.sh - which i found on XDA after i was finished and decided to share...)

Once the init.d job was running, it turned out the delay wasn't Universal Init.d App's fault. instead the reason is the Android OS is mounting sdcard delayed. this means the provisional watchdog mount script 00_mount_sdext2.sh becames unusable for me. anyway i keep it attached for using with 2. partition. the final Link2sd mount script 4.3+ 00_mount_sdcardtmp.sh is pre-mounting the sdcard first, then mounting the ext4 image file. both files are just examples and will not work for you without modifying the paths.

Stock kernel does support init.d, but SuperSU is required for this. for better understanding please read Pandages' short description how it works.

For Link2SD i have installed a ext4 image file located on external microSD Card. Due the limitation of FAT32 file systems, the maximum file size is 4 GB. However, some busybox binaries are compiled without large file support and cannot create files bigger then 2 GB - thats why this download comes with busybox. if you don't have arm cpu, there is a copy of busybox /system/xbin/busybox.bak which you must manually rename.

initial create empty ext4 image file

busybox dd if=/dev/zero of=/sdcard/.data.sdext2.img bs=4k count=1048576

busybox mke2fs -T ext4 -F -q /sdcard/.data.sdext2.img

run the commands from adb shell or terminal emulator

the dd command creates a new file on sdcard. the file size is specified with count.

the mke2fs command is formatting the image file with ext4 file system.

the (.) dot in front makes a filename hidden.

helpful commands for initial gathering

busybox df
busybox cat /proc/partitions
busybox mount

all mount points with same size usually have identical partition (group by block size). query for matching major + minor in /proc/partitions and find the name (for example /dev/block/mmcblk1p1). make sure the mount point exists and is empty, or create a new folder (for example /storage/sdcardtmp). mount shows the file system type (for example vfat).

modify the paths in 00_mount_sdcardtmp. you have to define two different mounts. the mount point for Link2SD is /data/sdext2.

After this, Link2SD now detects 2. partition on boot. but instead of a 2. partition you just have a single image file on sdcard (which can easily copied for backup)

the download includes a small install shell script which just copy the files into /system. provision for making files executable is unpacking the downloaded zip file init_d.zip to /data/local/tmp. don't forget to set permissions after unpacking.