[PRJ] apps2sd discussion

pvella

Senior Member
Dec 20, 2010
392
38
I am starting a thread with the purpose of getting this working for everyone. I understand that some people have it working, I am still trying to get it working, but I think I am close. Here is basically what I am doing....

First you need to put a second partition on your sd card that is ext2 based.

Second you need to root your phone.

Third is do something like this...

adb push install-recovery.sh /sdcard
adb shell
#su
#mount -oremount,rw /dev/block/mtdblock1 /system (mount -oremount,rw /dev/block/mtdblock2 /system - for froyo)
#mkdir /system/sd
#mount -t ext2 /dev/block/vold/179:2 /system/sd
#busybox cp /data/app/* /system/sd/app/
#cd /system/sd/app
#busybox cp /sdcard/install-recovery.sh /system/etc/install-recovery.sh
#cd /system/etc
#chmod 555 install-recovery.sh
#reboot

The install-recovery.sh file should look something like this....

#!/system/bin/sh
MYLOG=/data/install-recovery.log
echo "$(date) Starting install-recovery.sh" > $MYLOG
echo "$(date) Waiting SD to become ready..." >> $MYLOG
sleep 10
mount -t ext2 /dev/block/vold/179:2 /system/sd 1>>$MYLOG 2>>$MYLOG
mount -o bind /system/sd/app /data/app 1>>$MYLOG 2>>$MYLOG
mount >> $MYLOG

I am pretty sure that this should work, but it does not run for me. I have seen many people wanting this to work, so lets get this happening. I will keep testing this as I get a chance.

Edit: As Requested, the latest guides for this can be found at these locations:

* Kev's - Especially good for those with the internal 8Gb sdcard.
* pvella's - Conservative approach with more checks and backout points
* Ivy's - Up to date and thorough explanation and steps
 
Last edited:

pvella

Senior Member
Dec 20, 2010
392
38
I will continue testing. I suggest making the script just mount first and test that part only. That is what I am doing.

Sent from my Ideos S7 using Android Tablet Forum App
 

ivyvisors

Senior Member
Dec 29, 2010
233
52
Hi Pvella,

I was just looking at how you were copying the files in /data, using cp to copy them may cause some issues with permissions. what I'd suggest is the following:

cd /data
busybox tar -czvf /ext2/data.tar.gz *

Note: /ext2 is whatever you've called the mount point where your new data partition is.

then

cd /ext2
busybox tar -zxvf data.tar.gz

This will ensure that all the permissions will be copied over correctly.

~Ivy
 

ivyvisors

Senior Member
Dec 29, 2010
233
52
Okay, as it seems it's a little hard to unmount /data while the system is running (dalvic and all that) I'm going to take a leaf out of your book Pvella, and just worry about the /data/app/ directory.

Anyway what I've done so far to test things is this:

created a 1gb ext2 partition on my sdcard

then via adb shell:

mount -o rw,remount -t yaffs2 /dev/block/mtdblock1 /system

this mounts the system partition read write

then

mkdir /system/sd

next

mount -t ext2 /dev/block/vold/179:2 /system/sd

now we need to copy the applications that are installed to this sd directory.

because I want to preserve all permissions I did the following:

cd /data

busybox tar -cvf /system/sd/app.tar app/

now to unpack this

cd /system/sd/
busybox tar -xvf app.tar

okay almost there.

mount -o bind /system/sd/app /data/app

NOTE: I killed as many applications that ran out of data that I could before doing this.

Finally all I need to do is script it all.

~Ivy
 

ivyvisors

Senior Member
Dec 29, 2010
233
52
Anyway, I've found another page that talks about doing this, and the author there has broken things down into two scripts.

Firstly a script called "install-recovery.sh"
which contains:

#!/system/bin/sh
/system/etc/init-sd2.sh&


then a script called init-sd.sh containing the script that you posted Pvella,

Anyway I'm just put these two scripts on, and I'm about to see if it works.

~Ivy
 

ivyvisors

Senior Member
Dec 29, 2010
233
52
Just to say it worked!

/dev/block/vold/179:2 /system/sd ext2 rw,errors=continue 0 0
/dev/block/vold/179:2 /data/app ext2 rw,errors=continue 0 0

~Ivy
 

ivyvisors

Senior Member
Dec 29, 2010
233
52
Now to document everything I've done.

Firstly, I created 2 partitions on my sdcard (an 8Gb sdcard.) The first been a 7Gb VFAT partition, and the second a 1Gb ext2 partition.

Now I used fdisk to do this on my Linux box:

ivy@transmission:~$ sudo fdisk /dev/sdc

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): d 1
Partition number (1-4): 1


Command (m for help): n
Command action
e extended
p primary partition (1-4)

p
Partition number (1-4): 1
First cylinder (1-19165, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-19165, default 19165): +7G


Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (18126-19165, default 18126):
Using default value 18126
Last cylinder, +cylinders or +size{K,M,G} (18126-19165, default 19165):
Using default value 19165

Command (m for help): p

Disk /dev/sdc: 7948 MB, 7948206080 bytes
81 heads, 10 sectors/track, 19165 cylinders
Units = cylinders of 810 * 512 = 414720 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdc1 1 18125 7340620 83 Linux
/dev/sdc2 18126 19165 421200 83 Linux


Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.


Okay I hope that wasn't too much of a wall of text there.

Next I needed to make filesystems on these two partitions:


ivy@transmission:~$ sudo mkfs -t vfat /dev/sdc1

and

ivy@transmission:~$ sudo mkfs -t ext2 /dev/sdc2

NOTE: there will be some output here.

Now that's done pop the card back into your s7 fire up adb.

./adb shell

su as you will need to modify the system partition.

mount -o rw,remount -t yaffs2 /dev/block/mtdblock1 /system

This will remount the /system partition read write

Now, we need to create a directory to be a mount point:

mkdir /system/sd

next, what we need to do is mount our ext2 partition, this is completed by doing:

mount -t ext2 /dev/block/vold/179:2 /system/sd

Now to make a copy of the apps folder. Now we do need to try and make sure we preserve the permissions of the apps folder to achieve this I tend to use tar:

cd /data/
busybox tar -cvf /system/sd/app.tar app

Now, we need to upack this archive:

cd /system/sd
busybox tar -xvf app.tar

Now, using a decent text editor (I prefer vi) but if you're using windows notepad++ I reccomend. DONT USE NOTEPAD, as this will make sure things won't work.

The first script, is called install-recovery.sh

This will be called on boot, but this script needs to be over and done with quickly so we use this script to call another and run this in the background.

to do this all we need to have in this script the following:


#!/system/bin/sh
#
/system/etc/init-sd.sh&


This script will now call a script in /system/etc/ called init-sd.sh and background it.

This script is pretty much the same as yours Pvella and contains:


#!/system/bin/sh
#
MYLOG=/data/install-recovery.log
echo "$(date) Starting install-recovery.sh" > $MYLOG
echo "$(date) Waiting SD to become ready..." >> $MYLOG
sleep 10
mount -t ext2 /dev/block/vold/179:2 /system/sd 1>>$MYLOG 2>>$MYLOG
mount -o bind /system/sd/app /data/app 1>>$MYLOG 2>>$MYLOG
mount >> $MYLOG
echo "$(date) Finishing install-recovery.sh" >> $MYLOG


Once you've written these, lets put them onto your device with adb:

./adb push install-recovery.sh /sdcard
./adb push init-sd.sh /sdcard

*note or sdcard2 if needbe.

Now again we need to jump into the adb shell,

./adb shell
su as we need to have the power of the superuser!

now we need to put both of these scripts into /system/etc/

busybox cp /sdcard/install-recovery.sh /system/etc/
busybox cp /sdcard/init-sd.sh /system/etc/

Now these scripts won't run till we do the following:

busybox chmod 755 /system/etc/install-recovery.sh
busybox chmod 755 /system/etc/init-sd.sh

Okay, Now if we reboot, and to check if everything is working properly, using our trusty friend adb, shell in, and type mount


# mount
rootfs / rootfs ro 0 0
tmpfs /dev tmpfs rw,mode=755 0 0
devpts /dev/pts devpts rw,mode=600 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
tmpfs /sqlite_stmt_journals tmpfs rw,size=4096k 0 0
/dev/block/mtdblock1 /system yaffs2 ro 0 0
/dev/block/mtdblock6 /data yaffs2 rw,nosuid,nodev 0 0
/dev/block/mtdblock5 /cache yaffs2 rw,nosuid,nodev 0 0
/dev/block//vold/179:1 /sdcard vfat rw,dirsync,nosuid,nodev,noexec,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,flush 0 0
/dev/block/vold/179:2 /system/sd ext2 rw,errors=continue 0 0
/dev/block/vold/179:2 /data/app ext2 rw,errors=continue 0 0


and we're done!

Now what I plan on trying to do is move the rest of the folders over, and maybe the entire data directory, as there are other things in here that could use extra space =)

Now, finally, to do this you do need some unix skills, and understanding what your doing is a real plus, not just copy and paste please, as it could cause issues.

~Ivy
 

ivyvisors

Senior Member
Dec 29, 2010
233
52
Oh and one more thing, In /data there will be a log called install-recovery.log, which will show you what happened.

and finally have fun =)

thanks to Pvella for showing me his idea for a script to do this, and thanks to saumilt on the androidforums.com for some other ideas.

~Ivy
 

pvella

Senior Member
Dec 20, 2010
392
38
Nice work ivy. Now we have a documented apps2sd procedure for this thing. Huge huge thanks for all your help.
 

ivyvisors

Senior Member
Dec 29, 2010
233
52
Not a problem Pvella, I'm looking at how to make this work a little better.

I'm trying to work out if I can possibly do this for the entire data partition, but I think this might not be possible by using these scripts.

~Ivy
 

pvella

Senior Member
Dec 20, 2010
392
38
Be careful. I think you need to be in a recovery mode to move the cache without corrupting things. You could possibly script it, reboot and cross your fingers, but I think this is a bit risky.
 

pbrauer

Administrator
Staff member
Sep 24, 2010
3,649
561
just so we have some confirmations here, as I believe this thread may explode over the weekend.

My understanding of how things now stand:

1. Ivy and PVella have worked together and now have a working process for getting App2SD working on the S7.
2. The documentation in this thread shows how to get this process working, and it is now being tested
3. Ivy is now looking at what can be done to make this a little easier

I need to know, before we really publish this out if other have tested the procedure Ivy wrote up. Anyone interested in stepping through it, please do so and then post here to say if it worked or not.

Finally, this is a really big one people. Probably as big to the S7 Users as getting Froyo will be. I am going to posting this to the other boards as well such as forum-xda-developers.com so that everyone know we were the ones with this breakthrough.

Cheers and thanks to IvyVisors and PVella! Great work people!
 

l_n

Senior Member
Dec 28, 2010
788
99
In my work on the kyros, I discovered that everything is mounted in the init.rc file in boot.img. you could do all of this there. Also, you can resize the system partition via a modified kernel command line. I'll post a link to the info later.
 
Top