Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

New and improved Apps to SD(more stable, more powerful, etc) Tutorial

OP MarcusMaximus04@gmail.com

6th May 2009, 11:05 PM   |  #1  
OP Senior Member
Thanks Meter: 9
 
1,075 posts
Join Date:Joined: Jun 2007
More
Well, some of you may have heard my ramblings around here that I've been working with some of the devs here(JF and MartinFick deserve major praise, probably more than me) on getting a better way to do the whole apps to sd thing.

After 3 days of talking/discussing/working on it, I've finally reached the fruits of that investigation and thought I'd share. This new method uses the filesystem unionfs to essentially meld the /data directory with the /system/sd directory, so that they appear to be one. This has the potential to allow users to move specific apps to or from the sd card, is far more stable than the normal symlink method(will still boot, etc even if there's no SD card) and should be easier to set up. Now, onto the tutorial of setting this up.

BIG DISCLAIMER NOTE: This is a major hack of the phone and it is fully possible that it will break your phone(I've seen no permanently bricked phones but that doesn't make it impossible). Use this method, and my app along with it at your own risk.

REQUIREMENTS:
1: This only works on JF(possibly only on 1.5, not sure about the others) and The Dude's v.1.0 or greater. The Dude's 1.0 or greater actually does the steps in this tutorial for you so you can just run appstosd2 and set it all up from there if you're using his ROM.
2: This still requires you to have 2 partitions set up, first FAT32 and second ext2. Although you can use the appstosd2 app attached to this post and available in the market for $0.99 which will partition the card for you.
3: If you want your apps to go to the sd card, you must have a directory "/system/sd/app" If you didn't have apps to sd before on the ext2 partition do the following in terminal emulator or run my appstosd2 app after finishing the tutorial:
Code:
su
mkdir /system/sd/app
If you want the private-apps, or dalvik-cache moved you can replace "app" in that code with ""app-private", or "dalvik-cache" respectively. Do not copy "data" to the sd card. My script will delete it on the next reboot.

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

Alright, first there's some files you need.
1: init.rc in .zip attached to this thread
2: a2sd.sh in .zip attached to this thread

All the above listed files should be put on your sd card(my tutorial will assume they are in the root directory of the sdcard(the topmost folder)

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

If you need to undo the normal apps to SD first do the following in the recovery terminal(it's not strictly necessary but I'd recommend it):
Code:
mount data
rm /data/app
mkdir /data/app
if you moved the dalvik cache, repeat steps 2-3 with "dalvik-cache" instead of app. Ditto with "data" for the data cache.

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

Then go to terminal emulator and type the following:
Code:
su
cp /sdcard/init.rc /data/
cp /sdcard/a2sd.sh /data/
Then reboot and you're set. By default all future apps are installed to the sd card. In order to move an app to the internal memory do the following in terminal emulator:

Code:
su
cp /system/sd/app/[the app you want to move] /system/intmem/app/
rm /system/sd/app/[the app you want to move]
I will be incorporating this into my appstosd app soon(probably as a JF and TheDude-only version until the rest of the devs get on board).

I have included a copy of appstosd 2, which will copy all apps from internal memory to the sd card with an option to remove them from the internal memory. This will only work if you have followed this tutorial.

If you don't have partitions set up, appstosd2 will now do that for you with user-set partition sizes.

NOTE: If you're using The Dude's ROM and find yourself with an outdated version of this since he doesn't always update his ROMs at the same time I update this, do the following in terminal emulator to update(after putting a2sd.sh from the attached a2sd.zip on your sdcard):

Code:
su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
rm /system/bin/a2sd.sh
cp /sdcard/a2sd.sh /system/bin/
reboot
For JF1.5, do the following to update:

Code:
su
rm /system/intmem/a2sd.sh
rm /system/intmem/init.rc
cp /sdcard/a2sd.sh /system/intmem/
cp /sdcard/init.rc /system/intmem/
reboot
NOTE FOR UPDATERS: If you had your data on the sdcard(/system/sd/data), it WILL GET DELETED with the new version. This is a necessity in order to get both wallpaper and protected apps working. I recommend moving it back to the phone.

EDIT: And here's another tutorial from ThatsBS(might be easier for the less tech savvy to follow?):
I am still learning a lot everyday from this forum. So for people new to this process let me noobify it, if I can, as I am one too.
Start by reading the first page!! Get all the stuff you need from page 1. (apps2sd2.zip and a2sd.zip )

I started from a fresh wipe and flash of jf1.51 adp.
A newly formatted fat32, non partitioned sd.
Put the init.rc and app2sd.sh on the sd (the files NOT the zip)

Then go to the terminal emulator and typed:
su
cp /sdcard/init.rc /data/
cp /sdcard/a2sd.sh /data/

Then reboot

Next I ran the apps2sd 2 app. It will ask you how much to you want to partition. I did 3000mb the first successful time and the dreaded low mem notice would not leave the status bar. I have read not to make it more then 1500mb. Have a good connection, dont force close it. It will reboot.

Next, after the reboot, I ran the apps2sd 2 app again and pressed "copy apps to sd" (let it do its thing)
Reboot.

Next I went back to the emulator and typed:
su
mkdir /system/sd/app-private
mkdir /system/sd/dalvik-cache
Reboot.

Go back to the apps2sd 2 app and hit move dalvik-cache.
Reboot for good measure and your done.

I did this in about 10 mins. Worked flawlessly.
Attached Files
File Type: zip AppstoSD2.zip - [Click for QR Code] (45.4 KB, 39568 views)
File Type: zip a2sd.zip - [Click for QR Code] (634 Bytes, 15333 views)
Last edited by MarcusMaximus04@gmail.com; 2nd June 2009 at 08:10 PM. Reason: emulator, not editor damnit!
6th May 2009, 11:23 PM   |  #2  
ArmandHammer's Avatar
Senior Member
Flag Ohio
Thanks Meter: 2
 
260 posts
Join Date:Joined: Apr 2009
More
I have a ?, if i have been using your app what dod i do diferent or what should i change?
Thanks
6th May 2009, 11:24 PM   |  #3  
Dimath's Avatar
Member
Flag Los Angeles
Thanks Meter: 1
 
77 posts
Join Date:Joined: Nov 2008
More
Good job, thanks!

Quote:
Originally Posted by MarcusMaximus04@gmail.com

will still boot, etc even if there's no sim card

You mean SD card?

Quote:
Originally Posted by MarcusMaximus04@gmail.com

Alright, first there's some files you need.
1: unionfs.ko from here:

JF1.5 build has already unionfs.ko in it, doesn't it? Is there any difference between this unionfs.ko and the one included?

1. I hear unionfs is not really stable at this point, is it true?
2. Why do you want to move the whole /data folder to sd, instead of just /data/app, /data/app-private?
3. You might want to add a command to remove previous app2sd changes (i.e. delete symlinks, create folders.)
4. How do you put selected apps to internal memory after this? Copying to /data will copy to sd card again.

The whole idea is really interesting! Thank you for your work!
6th May 2009, 11:32 PM   |  #4  
OP Senior Member
Thanks Meter: 9
 
1,075 posts
Join Date:Joined: Jun 2007
More
Quote:
Originally Posted by ArmandHammer

I have a ?, if i have been using your app what dod i do diferent or what should i change?
Thanks

You don't have to do anything different. It will find all the apps you put on the sd card. If you want to set the phone back to normal(so the phone memory apps can still be there), you can do the following in the recovery terminal:

Code:
mount data
rm /data/app
rm /data/dalvik-cache (only if you moved the dalvik-cache)
mkdir /data/app
mkdir /data/dalvik-cache
@Dimath: yes, I did mean SD card, good catch
1:JF didn't mention it and from a little bit of using it, it seems stable to me. Plus, no matter how much I've screwed up, I haven't managed to boot loop my phone yet.
2: You could just mount those independently. I might end up doing that eventually but for now the way it is works for reasons I'll get to.
3: True, although it's not strictly necessary. If apps2sd already works, this won't break it. I'll put in a guide on undoing the symlink method
4: Actually, no. My script sets the internal memory as the main file system in the union, so apps automatically go there. Moving apps to the sd card just involves copying them to /system/sd.
Last edited by MarcusMaximus04@gmail.com; 6th May 2009 at 11:36 PM.
6th May 2009, 11:52 PM   |  #5  
Member
Thanks Meter: 0
 
49 posts
Join Date:Joined: Oct 2008
Ok, just a little confusing.

I didn't use the apps2sd to move apps over to my SD card. What I did was set it with the busybox ls command. I guess that's the symlink.

My question is, if I didn't use apps2sd, can I still use your method? I also moved the dalvik cache also, everything works fine for me now, my apps go directly to the SD card when installing since my memory stays at around 65 MB no matter what I do.

Just need some laymen terms to help me understand that if I'm NOT using apps2sd, and I just linked them with the recovery method, what's my pitfalls / advantages?

Thanks.
7th May 2009, 12:06 AM   |  #6  
OP Senior Member
Thanks Meter: 9
 
1,075 posts
Join Date:Joined: Jun 2007
More
Quote:
Originally Posted by larrygates

Ok, just a little confusing.

I didn't use the apps2sd to move apps over to my SD card. What I did was set it with the busybox ls command. I guess that's the symlink.

My question is, if I didn't use apps2sd, can I still use your method? I also moved the dalvik cache also, everything works fine for me now, my apps go directly to the SD card when installing since my memory stays at around 65 MB no matter what I do.

Just need some laymen terms to help me understand that if I'm NOT using apps2sd, and I just linked them with the recovery method, what's my pitfalls / advantages?

Thanks.

Yes, any other method of apps to sd currently uses the same symlink method, so following the directions as if you installed my app will work. A note though is that all future apps will install to the internal memory by default. I did that because it's MUCH easier to move apps from the memory to the sd card than vice versa. You can use the code I posted if you want it the other way around.
7th May 2009, 12:26 AM   |  #7  
Senior Member
Thanks Meter: 3
 
835 posts
Join Date:Joined: Nov 2008
More
would this also work for /data/data and app-private?

or is this particular setup only for dalvik-cache and app?

oh and before I do this, just wondering, so in theory, since I have a 1.5GB ext2 partition, my free memory will be 1.573GB (1.5GB + 73Mb internal)? The internal memory will just run down and switch over to the sdcard when needed (but be seen as one filesystem)?
Last edited by andonnguyen; 7th May 2009 at 12:31 AM.
7th May 2009, 12:31 AM   |  #8  
OP Senior Member
Thanks Meter: 9
 
1,075 posts
Join Date:Joined: Jun 2007
More
Quote:
Originally Posted by andonnguyen

would this also work for /data/data and app-private?

or is this particular setup only for dalvik-cache and app?

This works for the whole /data folder and everything under it. Everything is automatically installed to the phone memory right now so you can just move over anything you don't want on it(will be making an app to do this automatically)

EDIT: oh and anything you already moved over to the sd card will still show up.
7th May 2009, 12:40 AM   |  #9  
Member
Thanks Meter: 0
 
49 posts
Join Date:Joined: Oct 2008
Code:
su
mount -o remount,rw /dev/block/mtdblock3 /system
cp /sdcard/unionfs.ko /system/
cp /sdcard/init.rc /data/
cp /runme.sh /data/
cp /sdcard/a2sd.sh /data/
I see, when I run these lines of code (I can do this from adb also right using adb remount) this IS the new symlink method. It's just all at one time without me having to manually link anything.

Right?
7th May 2009, 01:19 AM   |  #10  
OP Senior Member
Thanks Meter: 9
 
1,075 posts
Join Date:Joined: Jun 2007
More
Quote:
Originally Posted by larrygates

Code:
su
mount -o remount,rw /dev/block/mtdblock3 /system
cp /sdcard/unionfs.ko /system/
cp /sdcard/init.rc /data/
cp /runme.sh /data/
cp /sdcard/a2sd.sh /data/
I see, when I run these lines of code (I can do this from adb also right using adb remount) this IS the new symlink method. It's just all at one time without me having to manually link anything.

Right?

Wrong, no symlinks here. Pure unionfs goodness. Basically it convinces the operating system that /data and /system/sd are the same thing. So anything that's on /system/sd shows up under /data but everything that's normally under /data is still there. Think of it like what happens in windows when you merge folders with the same name, but in this case in actuality everything stays exactly where it was.
Last edited by MarcusMaximus04@gmail.com; 7th May 2009 at 02:01 AM.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes