[INIT.D][10-05-2012]Super APP2SD Script [MAJOR UPDATE][BETA]
UPDATES, WARNINGS, AND INSTALLATION STEPS ARE AVAILABLE IN THE 2ND POST
WHAT DOES THIS SCRIPT DO?
* It is the only method, that I am aware of to have apps trully run, and be installed directly to the external storage without completely switching the internal storage with the external storage.
This bings different benefits to different people:
1 - If you have a device that comes from factory with only a small amount of storage available, you can now install as many apps, and apps as big as the partition you setup to use with this script. For example, if you have a phone with only 512 MB of app storage, you can now install games that take over 1GB of app storage so long as your external partition has the space available.
2 - If you bought a 16GB device and wish you had bought a 32GB device, this is great for you as well (I'm one of these). With this script, your apps will not take up any space in your internal storage, which means that your 16GB (or whatever is left of it after factory partitioning, 11.66 GB in my case) is now available for pictures, videos, downloads, backups, or whatever else you might want to put there or have easy access to when you connect your device to your computer.
3 - If you have a lot of Android games, this is great for you too, specially if you're playing games that take a lot of space. Just get a large MicroSD (I have a 64GB partitioned to 32/32) and put as much space as you need in the second partition, and now you can have all your games intalled at the same time. No need to keep uninstalling games so that you can install other ones.
* Once and Done, across the board setup. That's right, launchers, keyboards and widgets will run from the external storage natively, something never done before in Android as far as I know.
This means that once you have the script up and running, you're good to go until the next time you reflash your /system partition. No need to choose what apps to move. No symlinks or anything. Your apps now belong in the external storage, plain and simple.
* No need to backup all your stuff before running the script (and eventually no need to back up your stuff when you want to disable it either).
That's right, the script does the hard work for you. All your stuff gets safely moved to the external storage, with all ownerships and permissions intact. It all happens so smoothly that some people have a hard time telling that the script is already at work. Nothing gets deleted from the internal storage until you're certain that everything is working as expected either. So even if something goes wrong, as long as you have ADB, all your stuff can go back to normal without a problem
(Even though you don't have to backup and restore in order to get the script going, it's always greatly recommended that you keep a backup of your apps).
* Simple intallation:
To get the script going all you have to do is download it, extract it, and run 3 commands in the terminal. It will then ask you a couple of questions, and then you'll be all set. The one downfall is that because the script requires user input (no, the required information cannot be picked from a list), the script cannot be run from a recovery zip. However, I'll emphasize once again that it only takes 3 commands to get the script going.
Also, the script comes with an options file that allows you to setup device specific variables, making the script malleable to work on just about any Android device. Just open the USER_OPTIONS file before runing the install script, and as long as you have the variables there set correctly, the script should be compatible with your device.
* You can still use the external partition for other stuff if you want to. Just remember that it's mounted to /mnt/sd-ext (or /storage/sd-ext in JB). So if you still have a ton of space left in the partition and need the space, you can still use it. Just ensure not to touch the folders Android, app and data.
* Now this is a bit more technically, but in theory, you could a third partition for this script instead of the second partition, and then still be able to use app2sd solutions, though personally I don't see what advantage there would be to doing this since apps would still be in the external storage no matter what.
WHAT DOES THIS SCRIPT NOT DO?
*** IT CANNOT BE CONVERTED INTO A RECOVERY ZIP DUE TO USER INPUT REQUIREMENT ***
*** YOU CANNOT PICK AND CHOOSE WHAT APPS TO MOVE, THAT'S PLAIN AND SIMPLE NOT THE PURPOSE OF THIS SCRIPT ***
Above you can see my storage screen. If you add the amount of used space and the amount of available space, it's ~18 GB, well over the available 11.66GB in the internal storage. Also note that when the script is enabled, the bar displaying storage usage is unreliable. All other information is reliable, including, and most importantly, the amount of available free space.
Above you can see the output of some commands in the terminal. The most important part of the output for mount above are
/dev/block/mmcblk0p12 on /mnt/temp/data type ext4 (rw,relatime,barrier=1,journal_async_commit,data=ordered,noauto_da_alloc,discard)
/dev/block/mmcblk1p2 on /mnt/sd-ext/data type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered)
/dev/block/mmcblk1p2 on /data/media/Android type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered)
/dev/block/mmcblk1p2 on /data/app type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered)
/dev/block/mmcblk1p2 on /data/data type ext4 (rw,nosuid,nodev,noatime,barrier=1,data=ordered)
As you can see, mmcblk1p2, the external storage, is mounted to /data/app, /data/data and /data/media/Android, which means that as far as Android is concerned, those folders are in the external storage. Also note that all these mounts took place before /sdcard itself was mounted, meaning that the script is ensuring that these mounts take place soon enough in the boot process to avoid problems related to mounting the app storage locations after Android has loaded the available apps.
Finally, the fact that mmcblk0p12 is mounted to /mnt/temp/data is important because of the next two commands
The output of du -sh shows the amount of storage used by a folder, and as such because the internal storage is mounted to /mnt/temp/data;
/mnt/temp/data/app = internal /data/app = 8KB
/mnt/temp/data/data = internal /data/data = 72KB
/mnt/temp/data/media/Android = internal /data/media/Android = 4KB
/data/app = 1GB
/data/data = 624.3 MB
/data/media/Android = 5.6 GB
For a grand total of 7.22 GB of used app storage in the external storage as opposed to 84 KB in the internal storage.
- Testing and Debugging
*Others who tested the script but weren't in direct contact with me.
*People who said it wasn't possible to run widgets, launchers and keyboards from External Storage (They provided the challenge I needed to make this work)
If anybody needs help or if anything doesn't work, I'll help through irc (much quicker than posting here) on freenode - #and-host
Be a nice person and hit the thanks button ;P
SM-900V - Verizon Galaxy Note 3
SM-T900 - Samsung Galaxy Tab Pro 12.2
XT875 - Droid Bionic + Lapdoc
GT-N8013 - Samsung Galaxy Note 10.1
Motorola Droid X
Motorola Droid 2
Acer Iconia A500
Asus Transformer TF201 + Dock