[Miscellaneous Android Development] alecxs:
[TUTORIAL] PLEASE CLICK HERE TO EXPAND PICTURES

(rotate the page to landscape for best view)

1. UNPACK THE FILES

2. SET PERMISSIONS

extract file init_d.zip to

make busybox and

/data/local/tmp

install.sh executable

3. INSTALL init.d

execute the shell script

make sure script was

install.sh with su permissions

finished successfully

(or terminal command: "su -c sh install.sh)"

(or you already have init.d support?)

4. GATHER SDCARD PARTITION PARAMETERS

Read Driver and Device Numbers

open a root shell. make sure you have su permissions (type "su").

type "busybox df"

identify the external microSD Card folder. its usually "/storage/sdcard"

(or something, and symlinked to "/sdcard")

group all mount points with same size (group by block size)

find the related filesystem, starting with "/dev/block/vold/puplic:179,97"

(or something)

Find the Block Partition

open a shell

type "busybox cat /proc/partitions"

identify Driver and Device Numbers, for example major = 179, minor = 97

find the name. complete the path, starting with "/dev/block/mmcblk1p1" (or something)

Copy the Mount Options

open a shell

type "busybox mount"

identify the related filesystem, starting with "/dev/block/vold/puplic:179,97" (or something)

find the filesystem type, for example "vfat" (depends on microSD Card)

copy the mount options. usually from "rw" to "uid/gid"

5. CREATE THE MOUNT SCRIPT

use Mount-Button to make system partition read-write able

(or terminal command: "su -c busybox mount -o remount,rw /system")

navigate to folder "/system/etc/init.d"

delete the example file "00_mount_sdext2" (not required)

open the example file "00_mount_sdcardtmp" in text editor

MODIFYING THE init.d MOUNT SCRIPT EXAMPLE

Pre-mounting external microSD Card

edit the first mount line. usage: mount -t <type> -o <options> <source> <target>

Source:	"/dev/block/mmcblk1p1" (Block Partition, see above 4.)

Target:	"/storage/sdcardtmp"

Filesystem type:	"vfat" (see above 4.)

Options:	"rw, ..." (see above 4.)​

example: "mount -t vfat -o rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015 /dev/block/mmcblk1p1 /storage/sdcardtmp"​

Mounting the ext4 image file

the second mount line is like the first mount, except the source is a file. thus requires the additional mount option "loop". further use same mount options as used for "/data" (usually from "rw" to "uid/gid"). these might be different from above.

Source:	"/storage/sdcardtmp/.data.sdext2.img" (Image File, see below 7.)

Target:	"/data/sdext2" (see below 6.)

Filesystem type:	"ext4" (see below 7.)

Options:	"loop,rw, ..."​

6. PREPARING MOUNT POINTS

Make sure the target folders exists and folders are empty. consider that file names are case-sensitive.

You can create a new mount point as

For Link2SD a fixed mount point

well. the folder name for microSD Card

is defined, the folder name is

is an example, vary it as you like.

detected from app.

use Mount-Button to make root directory read-write able

(or terminal command: "su -c busybox mount -o remount,rw /")

navigate to folder "/storage"

create new folder "/storage/sdcardtmp"

navigate to folder "/data"

make sure the identical path is specified

in mount script "00_mount_sdcardtmp"

(see above)

create new folder "/data/sdext2"

7. CREATE THE EXT4 IMAGE FILE

Finally, create the Image File "/storage/sdcardtmp/.data.sdext2.img". the file name is an example, vary it as you like. choose a location anywhere on external microSD Card. the (.) dot in front of filename makes a file hidden.

identify the external microSD Card folder.

its usually "/storage/sdcard" symlinked to "/sdcard"

calculate the number of blocks.

the maximum file size is 4096 bytes x 1048576 = 4294967296 bytes (4 GiB)

open a shell

create a new file with busybox "dd" command

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

wait 10 minutes

format the file with busybox "mke2fs" command. the filesystem type is "ext4"

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

make sure the identical file name is specified in mount script "00_mount_sdcardtmp"

(see above)

8. MOUNT THE (EMULATED) SECOND PARTITION

Test the mount script

open a root shell. make sure you have su permissions (type "su")

type "sh /system/etc/init.d/00_mount_sdcardtmp"

type "busybox df"

if successful, there are two new mounts "/storage/sdcardtmp" and "/data/sdext2"​

Check the mount options

type "busybox mount"

identify the new mount points "/storage/sdcardtmp" and "/data/sdext2"

compare the mount options. they should be similar:

"/dev/block/vold/puplic:179,97" = "/storage/sdcardtmp"

"/data" = "/data/sdext2"

(or something)

FINISH. REBOOT THE PHONE. CHECK IF SUCCESSFUL

NOTE: IF YOU WON'T GO THROUGHT THIS MANUALLY CODING TORTURE

there is an app from google play called Mount2SD the solution as it has most of the mount scripts needed. It won't work with encryption. I personally prefer the loop file method descriped here (and never tested it), but looks like a good alternative for Link2SD ;)

NOTE: The following apps are used:

For older versions (screenshots) please see Attached Files below