[Galaxy S 4 General] Deus_ex11:
I have found a solution for your low memory space problems on a Galaxy S4 GT-I9505 16GB

Courtesy of TweakerL, modified for the S4 with his permission.

Original script http://xdaforums.com/showthread.php?t=1888986

Features:

Install apps and data directly to the external SD

[*]Moves existing apps and data to the external SD

[*]Mounts the /data folders to the external SD on boot

[*]Free your internal SD memory for use

[*]Uses a second EXT4 partition on your MicroSD

[*]Seamless intergration

NOTE: This now works on stock ROM's and stock kernel's.

I have tested this script successfully on stock MDF, ME3, MEA, MF4, MF8 and Omega ROM's. Works with ktoonsez 6/23/2013 and Abyss 1.1 kernels. Adam 1.4 kernel hangs on reboot, but can be flashed after the script has installed successfully. This works on faux kernel even though it does not have init.d support.

Requirements:

Experience with Android modding, although not strictly required

Galaxy S4 GT-I9505

ROOT Access

Fuse mod which will be installed

MicroSD, preferably a blank 64GB Class 10

Busybox Installer from Playstore https://play.google.com/store/apps/details?id=com.jrummy.busybox.installer

Terminal Emulator from Playstore https://play.google.com/store/apps/details?id=jackpal.androidterm

Any root explorer from Playstore, I use ES https://play.google.com/store/apps/details?id=com.estrongs.android.pop

PerfMon from Playstore, free from here http://xdaforums.com/showthread.php?t=1933284

Any zip extractor app from Playstore, ES has one built-in

Partition Table from Playstore https://play.google.com/store/apps/details?id=com.cls.partition

A computer to create EXT4 partition on the MicroSD

MiniTool Partition Wizard Home Edition v7.8 free from here http://www.partitionwizard.com/free-partition-manager.html

Pre-install preparations:

Do a Nandroid backup of your current ROM, if you have a custom recovery

Although not required with this script, backup your apps with Titanium or another app.

Backup your MicroSD. This is important if you have files on it that you want to keep.

Using MiniTool Partition Wizard, format your whole MicroSD to FAT32

Then resize the first partition to your requirements. e.g. 30GB and 30GB for the second

Create the second partition and select Primary, EXT4 and 4KB cluster size

In my example below I have a 40GB EXT4 partition for my apps and games

While your waiting for the MicroSD to finish formatting, install the apps listed above

Install busybox v1.20.2 to /system/xbin. This is a important step.

Once thats done put your MicroSD back into your S4

Installation instructions:

Extract the A2SD zip to /sdcard

Run the Terminal Emulator

Type [B]su[/B] then press enter
Type [B]cd /sdcard/a2sd[/B] then press enter
Type [B]sh ./install-a2sd[/B] then press enter

It should install successfully, press enter to reboot

Once rebooted, run your root explorer

Navigate to /sdcard/Tweaked.Scripts/A2SD

If there is a DEVICE_IS_READY file you can reboot again

Upon reboot, run PerfMon, select Disk I/O

You will see the data moving between internal to external SD

Run root explorer and navigate to /sdcard/Tweaked.Scripts/A2SD

Wait till all the data has been moved. NOTE: It can take a while if you have a full sdcard

IMPORTANT: The Read and Write columns on DISK I/O must all be '0' before you reboot

Refresh /sdcard/Tweaked.Scripts/A2SD in root explorer

If there is a DEVICE_IS_READY file you can reboot again

Once rebooted, your apps and data now reside in your external SD

It does look like nothing has happened but everything is now running from external SD

If you find the 'SD-EXT' folder in '/Android/data' ; '/Android/obb' ; '/data/app' ; '/data/data' then these folders are now mounted on your external EXT4 partition instead of the internal sdcard.

Now reboot again for the fourth and final time

Once rebooted all apps and app data will be deleted from the internal sdcard except your user files

Open the Application Manager in More Settings

You can see the free space increasing before your very eyes

As you can see your apps are still installed with their data

You can see what was deleted in /sdcard/Tweaked.Scripts

To find out how much space is being used on your MicroSD's second partition

Run the Partition Table app and look for /storage/sd-ext/data

If you subtract the available from the total space in the screenshot below, it is less than the applications and other data added together.

NOTE: At the moment, there is no reversal script. Restore a nandroid backup to reverse. This will not restore the Android/data though. Remember to put back your files on your MicroSD that you backed up

WARNINGS:

DO NOT DELETE '/sdcard/Tweaked.Scripts' OR IT WILL STOP THE SCRIPTS WORKING

DO NOT REMOVE MICROSD CARD WHILE THE PHONE IS ON. ALWAYS POWER OFF FIRST SO TO NOT CORRUPT DATA.

DO NOT REBOOT THE PHONE WITHOUT THE MICROSD CARD, YOUR PHONE WILL BE IN A STOCK STATE AGAIN IF YOU DO AND FORCE CLOSURES MIGHT HAPPEN

Changelog:

v1.0 Released 16-06-2013

v1.1 25-06-2013

Runs on stock ROM and kernels

Flashing custom or stock kernel will not affect script

Rename install-recovery.sh in Omega ROM as not needed

Add a init.d test script