[Android Q&A, Help & Troubleshooting] Rderasta:
Hello guys, i need some help fixing internal storage issues, in general. -- solved it, but i'd stiil love an explanation lol --

I mean, i need to understand what needs to be edited, and what options do i have (i want to know the differences)?

Internal as main, external mounted, sd, emulated storage, fused storage and what not..

Note: Please notice i am not asking the "hows", i know how to de/compile boot.img and framework-res succesfully.

I want to understand why some roms use my SD as "main" and my phone doesn't succesfully recognise the amount of space it has available, hence resulting in insuficient storage issues and/or broken app2sd.. and i want to be able to fix this - avoiding bootloops.

I also need to understand a flashable fix i found, and how to succesfully edit it to make it "fix" storage working internal as main, and sd as sd.. and/or leave it as is, but make it so i'd could move apps to my sd and not to external..

Gona get a bit more technical here, here are the main files (the ones that matter I THINK):

From the original App2SD fix i found:

-fstab.mt6572

#APP TO SD AND STORAGE FIX BY ADITYA KUMAR
# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/emmc@android /system ext4 ro	wait
/emmc@usrdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@cache /cache ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_f /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_s /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check

/devices/platform/mtk-msdc.0/mmc_host auto vfat defaults voldmanaged=sdcard0:7,noemulatedsd
/devices/platform/mtk-msdc.1/mmc_host auto vfat defaults voldmanaged=sdcard1:auto

-init.fuse.rc

# MTK project .rc configure
#APP TO SD AND STORAGE FIX BY ADITYA KUMAR

on post-fs-data
mkdir /data/media 0770 media_rw media_rw
chown media_rw media_rw /data/media

on init
# Catalog
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/usbdisk0 0700 media_rw media_rw
mkdir /storage/sdcard1 0700 root root
mkdir /storage/sdcard0 0700 root root
mkdir /storage/usbdisk0 0700 root root

# Path
export EXTERNAL_STORAGE /storage/sdcard1
export USBOTG_STORAGE /storage/usbdisk0
export SECONDARY_STORAGE /storage/sdcard0:/storage/usbdisk0

# Links
symlink /storage/sdcard1 /sdcard
symlink /storage/sdcard1 /mnt/sdcard
symlink /storage/sdcard0 /mnt/sdcard2
symlink /storage/usbdisk0 /usbdisk0
symlink /storage/usbdisk0 /mnt/usbdisk0

on post-fs
mount rootfs rootfs / shared rec
mount tmpfs tmpfs /mnt/secure private rec

on fs
setprop ro.crypto.fuse_sdcard true

service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled
service fuse_usbdisk0 /system/bin/sdcard -u 1023 -g 1023 /mnt/media_rw/usbdisk0 /storage/usbdisk0
class late_start
disabled

-init.mt6572.rc

import init.mt6572.usb.rc
import init.modem.rc
import init.fuse.rc

on init
mkdir /protect_f 0771 system system
mkdir /protect_s 0771 system system
#Create CIP mount point
mkdir /custom

chown system graphics /dev/ion
chmod 0644 /dev/ion
....

So, its pretty clear mt6572.rc is cleared of all or most the storage related lines, and thus import init.fuse.rc..

Now, as a result here the rom storage "fused" between internal [1.3gb] and external [1gb] (both the device's storages end up active and working like a charm), and as an extra storage = the microSD [4gb]. - this is kind of not what i wanted since i've a total of 2.3gb for apps and data..

I've tried temperimg this files, switching numbers and whatnot, trying to "fix" it, as in, i need my microSD as external...

All my attempts did nothing, or ended up in a stuck boot.

Am i missing something? - All the times i edited the storage.xml from framework res i also ended up in bootloops (might need to try to edit that alone first?)

Here's the original storage.xml from the custom CM12.1 ported rom:

Note: i left this untouched after all.

<?xml version="1.0" encoding="utf-8"?>
<StorageList
xmlns:android="http://schemas.android.com/apk/res/android">
<storage android:mountPoint="/storage/sdcard0" android:storageDescription="@string/storage_sd_card" android:primary="true" android:removable="false" android:allowMassStorage="true" />
<storage android:mountPoint="/storage/sdcard1" android:storageDescription="@string/storage_internal" android:primary="false" android:removable="true" android:allowMassStorage="true" />
<storage android:mountPoint="/storage/usbotg" android:storageDescription="@string/storage_usb" android:removable="true" />
</StorageList>

Ok, lets get to the workaround:

Custom CM12.1 stock fstab.mt6572

# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/emmc@android /system ext4 ro,commit=1,noauto_da_alloc	wait
/emmc@usrdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@cache /cache ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_f /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_s /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/devices/platform/mtk-msdc.0/mmc_host/mmc0/mmc0	auto	auto	defaults	voldmanaged=sdcard1:[COLOR="red"]8,nonremovable[/COLOR],noemulatedsd
/devices/platform/mtk-msdc.1/mmc_host/mmc1/mmc1	auto	auto	defaults voldmanaged=sdcard0:auto
/devices/platform/mt_usb	auto	auto	defaults	voldmanaged=usbotg:auto

Edited "fixed" fstab.mt6572

# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/emmc@android /system ext4 [COLOR="red"]ro[/COLOR]	wait
/emmc@usrdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@cache /cache ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_f /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/emmc@protect_s /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc,discard	wait,check
/devices/platform/mtk-msdc.0/mmc_host/mmc0/mmc0	auto	[COLOR="red"]vfat[/COLOR]	defaults	voldmanaged=sdcard1:[COLOR="red"]7[/COLOR],noemulatedsd
/devices/platform/mtk-msdc.1/mmc_host/mmc1/mmc1	auto	[COLOR="red"]vfat[/COLOR]	defaults voldmanaged=sdcard0:auto
/devices/platform/mt_usb	auto	auto	defaults	voldmanaged=usbotg:auto

Custom CM12.1 stock init.mt6572.rc

import init.mt6572.usb.rc
import init.modem.rc

on init
mkdir /protect_f 0771 system system
mkdir /protect_s 0771 system system
#Create CIP mount point
mkdir /custom

export LD_PRELOAD /system/lib/libxlog.so
export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/sdcard1

mkdir /storage/sdcard0 0700 root root
mkdir /storage/sdcard1 0700 root root

symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
symlink /storage/sdcard1 /mnt/sdcard2

mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw

[...]
on fs
write /proc/bootprof "INIT:eMMC:Mount_START"
mount_all /fstab.mt6572
[...]

# virtual sdcard daemon running as media_rw (1023)
service sdcard /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start

service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -l /data/media /storage/sdcard1
class late_start

service fuse_usbdisk0 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/usbdisk0 /storage/usbdisk0
class late_start
disabled

Edited "fixed" init.mt6572.rc

import init.mt6572.usb.rc
import init.modem.rc

on init
mkdir /protect_f 0771 system system
mkdir /protect_s 0771 system system
#Create CIP mount point
mkdir /custom

export LD_PRELOAD /system/lib/libxlog.so
export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/sdcard1

mkdir /storage/sdcard0 0700 root root
mkdir /storage/sdcard1 0700 root root

symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
symlink /storage/sdcard1 /mnt/sdcard2

mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw

[...]
on fs
write /proc/bootprof "INIT:eMMC:Mount_START"
mount_all /fstab.mt6572
[COLOR="red"] setprop ro.crypto.fuse_sdcard true[/COLOR]
[...]
# virtual sdcard daemon running as media_rw (1023)
service sdcard /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start

service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -l /data/media /storage/sdcard1
class late_start
[COLOR="Red"]disabled[/COLOR]
service fuse_usbdisk0 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/usbdisk0 /storage/usbdisk0
class late_start
disabled

------------------------

I've noticed some custom roms give errors in the "labels" of the storages, resulting in weird symbolic names, showing "$%1 $%2 ..." instead of "Sd card".. i'd like to know why this happens.

------------------------

Here's the fix app2sd patch i've been working on: no its not mine ofc.. the original link is broken i'll give my up. (its ported for a y221 rom)

https://mega.nz/#!BVAF1RKD!4vInEgeSQ2MNE8uqoUymft6NoBCoJq2MdVcz39oPJyo

Here's the custom rom [cm12.1] i'm working on:

https://www.youtube.com/watch?v=T67oNdeW5Yc&lc

Here's MY fix:

https://mega.nz/#!Jd5TiA4T!gjz3w5Fo1d0P1re8XBFW5YfvhGb5tQpJs7N2R5tc1lw

I'm patient and willing to read.

Please point me to tutorials and whatnot. Altho keep in mind i've read some already. Like this one here.

Ty in advance.

Found some reading here:

https://source.android.com/devices/storage/config-example.html