[MOD] Homemade Apps2SD - Updated

simon.ponder

Well-known member
Dec 3, 2010
444
46
0
Android 2.2 and newer implements it's own Apps 2 SD process. In most ROMs, you can let the OS decide where it should put apps, or tell it explicitly where to put them. You can also go into manage applications and move applications one by one to the sd. Any of the above mentioned processes use a single moint per application, which will eventually degrade your performance.

What the following modification does is make one mount, and moves files, if any are available at boot.

That being said, if you are using this mod and need to reload a phone after flashing a new rom, you may need to fill up the internal memory, reboot the phone and then load the rest of the apps that couldn't fit the first time, and reboot again.

I use this because I have a 16G class 10 card, and I figure I can give up a gig for apps and not miss the space.

Usual Disclaimer:

'We are not responsible if your phone starts to chant and make weird noises at the guy across from you.'

Requirements:
- Root access
- At least a class 4 SD card, recommended class 8 or higher.
- This relies on CM7 or a ROM that looks for userinit scripts during boot and can reference a second partition on the SD. On CM7 you can see that it looks for these scripts, by looking in /etc/init.d (The file that references the userinit scripts is 20userinit). This has been tested with the 4/4 nightly.

Instructions:

1) Make a Nandroid backup.

2) Back up contents of your sd card to a computer.
3) Partition your sd card into two primary partitions, the first being FAT32 and the second being ext(2,3,4). This may work with a FAT32 second partition, but I didn't test that. The first partition must be FAT32, or Windows will no longer see the SD card.

You can use drelisdee's or clockwork's recovery to partition the card directly from the phone. If on linux, you can use gparted or similar. Windows, you can use mini tool Partition Wizard.

4) Restore your SD contents to the first partition.
5) Boot phone with SD card in slot.
6) Put a copy of the userinit.sh script in two locations on your system, after creating a couple directories. First, download attached zip, extract script, and place where ever you will be launching your command prompt from to perform some good ol' adb. Use these commands:

Create the two directories needed:

adb shell
cd sd-ext
mkdir app
mkdir userinit.d
cd ..
mount -o rw,remount -t yaffs2 /dev/block/mtdblock6 /data
exit

Push script to two locations:

adb push userinit.sh sd-ext/userinit.d/
adb push userinit.sh data/local/

Change permissions, ownership, and make executable:

adb shell
chmod 775 data/local/userinit.sh
chmod +x data/local/userinit.sh
chown root:system data/local/userinit.sh
chmod 775 sd-ext/userinit.d/userinit.sh
chmod +x sd-ext/userinit.d/userinit.sh
chown root:system sd-ext/userinit.d/userinit.sh

There seems to be an issue with the script moving applications from data/app to sd-ext/app, so after issuing above commands, please issue the following manually through adb as it will move the applications for you:

mv /data/app/* /sd-ext/app/
reboot

After your phone has settled, you can check to see if this worked, by typing 'mount' in adb shell or terminal emulator. You should be able to find the following in the output returned:

/dev/block/mmcblk0p2 on /data/app



To remove this modification:

Delete scripts in both data/local and sd-ext/userinit.d after mounting data as read/write:

adb shell
mount -o rw,remount -t yaffs2 /dev/block/mtdblock6 /data
rm data/local/userinit.sh
rm sd-ext/userinit.d/userinit.sh

Move apps back to data/app with the following command:

mv sd-ext/app/* data/app
reboot

**Keep in mind, that after using this for a while, when one decides to go back to how the ROM natively handles apps2sd, you may have more space used up than can fit on internal memory. In that case, before you undo the modification, you will want the OS to move some of the apps to its version of external, by using manage apps > press on the 'On SD card' tab, press on the app to move, and then press 'Move to SD card'**

Both current version of the recoveries available for this phone restore their backups fine, although you may need to restore, reboot, restore.

This is only supported as is on the CM7 port that zefie had been working on. I am looking into other ROM's, but as the other ROMs do not currently notice a second partition on the sd card, it is unlikely as they are currently set up.


Big thanks to:

mercrapper
 
Last edited:
Thanks for putting this in a concise form. I was reading mercrapper's instructions in the other thread with interest. A few questions:

1) Will this work with Lego ROM?
2) Since this only copies over /data/app, it sounds like all apps moved over with with Froyo's internal apps2sd or forced to SD with Titanium (or other means) will have to be moved back to internal memory before reboot. Correct?
3) How big is the impact you've noticed on performance? I just checked the mount count on my phone, and there are 74 mounts alone for the apps2sd items.
4) If reloading after flashing a new ROM, couldn't you set this up, reboot, then do the app restore, i.e. once sd-ext is mounted as /data/app, wouldn't the restored apps go automatically go to sd-ext?
5) Any impact on the performance or initialization of widgets moved to SD this way?

Thanks again.
 
Thanks for putting this in a concise form. I was reading mercrapper's instructions in the other thread with interest. A few questions:

1) Will this work with Lego ROM?
2) Since this only copies over /data/app, it sounds like all apps moved over with with Froyo's internal apps2sd or forced to SD with Titanium (or other means) will have to be moved back to internal memory before reboot. Correct?
3) How big is the impact you've noticed on performance? I just checked the mount count on my phone, and there are 74 mounts alone for the apps2sd items.
4) If reloading after flashing a new ROM, couldn't you set this up, reboot, then do the app restore, i.e. once sd-ext is mounted as /data/app, wouldn't the restored apps go automatically go to sd-ext?
5) Any impact on the performance or initialization of widgets moved to SD this way?

Thanks again.

1) I am looking into the other Roms that are available for the Optimus.

2) You are correct, apps that have been moved by the OS previously will need to be moved back to the phone.

3) This would probably depend on the speed of your card, but think of it this way. It's like having to go through one of 50 different doors, each for a different app to get to the same room on the other side, or to simply go through the one door that leads to the same point.

4) Correct

5) I have seen no degradation, again I am using a class 10 SD. This may not work as well for those who use it and have a lower class card.

STATS - 87 user apps with 107/172 MB internal storage free.
 
Last edited:
1) I am looking into the other Roms that are available for the Optimus.

2) You are correct, apps that have been moved by the OS previously will need to be moved back to the phone.

3) This would probably depend on the speed of your card, but think of it this way. It's like having to go through one of 50 different doors, each for a different app to get to the same room on the other side, or to simply go through the one door that leads to the same point.

4) Correct

5) I have seen no degradation, again I am using a class 10 SD. This may not work as well for those who use it and have a lower class card.

STATS - 87 user apps with 107/172 MB internal storage free.

Great tutorial. I couldn't have written it this good. ;)
 
STATS - 87 user apps with 107/172 MB internal storage free.
Using Froyo's app2sd and forcing pretty much everything else except widget-ey apps to the SD card, I'm currently at ~98 user apps with 112.5/164.9 MB internal storage free. At this point there are 24 apks (~21MB) in /data/app, so it looks like the most I'd free up would be that 21MB gained by moving widgets to sd-ext.

One other question about booting. With almost all of my apps moved to SD it takes a while until the apps on SD show up in the app drawer (suppose it's kind of understandable when one considers the 74 mounts). That's with an 8 GB Transcend Class 6 card that benches at over Class 6 speeds. Does moving /data/app to SD speed up the boot process over the Froyo app2sd?
 
Using Froyo's app2sd and forcing pretty much everything else except widget-ey apps to the SD card, I'm currently at ~98 user apps with 112.5/164.9 MB internal storage free. At this point there are 24 apks (~21MB) in /data/app, so it looks like the most I'd free up would be that 21MB gained by moving widgets to sd-ext.

One other question about booting. With almost all of my apps moved to SD it takes a while until the apps on SD show up in the app drawer (suppose it's kind of understandable when one considers the 74 mounts). That's with an 8 GB Transcend Class 6 card that benches at over Class 6 speeds. Does moving /data/app to SD speed up the boot process over the Froyo app2sd?

I find this much faster to load and the apps seem to run faster. Also, I don't have to worry about having to move apps to the sdcard when I install them unless they get installed to the sdcard by the system, then I just have to move them back. I currently have a class to 16GB (4GB allocated to sd-ext). I have run this on a class 4 and was a lot faster then the built-in apps2sd.

Again, this is my experience (opinions). You should judge for yourself ;-)
 
I find this much faster to load and the apps seem to run faster. Also, I don't have to worry about having to move apps to the sdcard when I install them unless they get installed to the sdcard by the system, then I just have to move them back. I currently have a class to 16GB (4GB allocated to sd-ext). I have run this on a class 4 and was a lot faster then the built-in apps2sd.

Again, this is my experience (opinions). You should judge for yourself ;-)
Thanks for the feedback (and original idea). I think I will give it a shot over the weekend and report back.

BTW, is there a way to batch move apps from the app2sd location back to internal memory?
 
Thanks for the feedback (and original idea). I think I will give it a shot over the weekend and report back.

BTW, is there a way to batch move apps from the app2sd location back to internal memory?

Instructions at bottom of OP.

Sent from my Gingerbreaded Optimis S using tapatalk...
 
Thanks for the feedback (and original idea). I think I will give it a shot over the weekend and report back.

BTW, is there a way to batch move apps from the app2sd location back to internal memory?

As root in terminal emulator or adb, try...

mv /sdcard/.android_secure /data/app

the reboot

I haven't tried this myself.
 
I started trying this with V9, LegoROM 1 & Beezy's pre-OC'd 806 kernel. Results weren't good (disclaimer - I'm definitely not a Linux guy):

1) sd-ext isn't mounted with a normal boot, so the "cd sd-ext" command didn't work. However, when I booted into the custom recovery, sd-ext was available. The filesystem on the apps partition (tried ext3 & ext4, plus reformatted the card using recovery) didn't make any difference.
2) I tried the instructions in recovery, and the chown command didn't work - said something like unknown owner

I was going to try a bit more, but came on today and saw version 2 of LegoROM and the VD update. I think I'll tackle the V9 -> VD update and LegoROM2 upgrade before I play with this more.

Thanks again to both of you.
 
I started trying this with V9, LegoROM 1 & Beezy's pre-OC'd 806 kernel. Results weren't good (disclaimer - I'm definitely not a Linux guy):

1) sd-ext isn't mounted with a normal boot, so the "cd sd-ext" command didn't work. However, when I booted into the custom recovery, sd-ext was available. The filesystem on the apps partition (tried ext3 & ext4, plus reformatted the card using recovery) didn't make any difference.
2) I tried the instructions in recovery, and the chown command didn't work - said something like unknown owner

I was going to try a bit more, but came on today and saw version 2 of LegoROM and the VD update. I think I'll tackle the V9 -> VD update and LegoROM2 upgrade before I play with this more.

Thanks again to both of you.

Read the entire OP, I know it is a lengthy read, but it covers most all bases. It relies on CM7 or a ROM that is able to view sd-ext. CM7 is the only rom that currently does this in a way that is easily used by the consumer.
 
Read the entire OP, I know it is a lengthy read, but it covers most all bases. It relies on CM7 or a ROM that is able to view sd-ext. CM7 is the only rom that currently does this in a way that is easily used by the consumer.
I had - I was just reporting back that it doesn't work with Lego, since I thought a previous edit of your initial post had said it worked with ThundeROM.

As an aside, is this a ROM or kernel issue (or both)? IIRC in one of the Xionia threads zefie had mentioned he was going to recompile the recovery with a different kernel to fix the sd-ext issue.
 
I had - I was just reporting back that it doesn't work with Lego, since I thought a previous edit of your initial post had said it worked with ThundeROM.

As an aside, is this a ROM or kernel issue (or both)? IIRC in one of the Xionia threads zefie had mentioned he was going to recompile the recovery with a different kernel to fix the sd-ext issue.

A previous edit did say that the script worked with ThundeROM, but ThundeRom does not view a second partition on the SD as sd-ext for this to work. CM7 does this out of the box, if you can call the many shaped container that CM7 comes in a box. I believe it is a ROM thing.

This mod is a set it and forget it type thing, if you have space to give.