[PRJ] apps2sd discussion

Thanks goodaone. I will try the dalvik cache when I get some more time to play with this. For now I am trying to figure out why init.rc is not getting called. I might reflash again. It is also good to see that the mount point is the same for other models as well. My one does not have the internal card.
 
Okay here's a little howto that hopefully explains things a little better (I've got everything working now)


applications to sd for 2.1 focusing on the Huawei S7

Note: this how to expects some unix or gnu/linux know how.

Things that need to be done before starting.

Have the Android SDK installed (or droidexplorer if you're on windows for adb, as I've got the sdk
this howto uses adb on the command line.)

Root the device. This goes without saying, I reccomend Z4Root.

Install Busybox. I've used Titanium Backup to do this for me (via the problems menu).

Step 1: Prepairing the SD card.

Note: I have an 8gb sd card, so my examples use this in mind.

Using which ever partitioning program you wish to use, create two partitions on your sd card.

Partition 1 is 7GB and is fat 32 formatted.
Partition 2 is 1GB and is not formatted (we will do this later on the device.)*

*in my case I've mucked up and my ext2 partition is only 400Mb

Now place the sdcard back into the device and boot.

We need to make an ext2 file system on the second partition. This is done via the command line on
the device. So fire up the adb shell

./adb shell

Type the command su to get root privilages, then type the following command:

busybox mke2fs /dev/block/vold/179:2

This will output some data. Once done on the second partition we now have an ext2 file system.

Once this is all done the SD Card is ready.

Step2: Mounting the card, and moving data to the card.

For this step we need to mount the /system partition as read write as this partition is normally
mounted read only. To do this run the following command:

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

Next run this command:

mkdir /system/sd

Then we need to mount the ext2 partition and we can do this via this command:

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

We need to now copy the data from the data directory to the ext2 partition, as we want to preserve
permissions we're going to use the command tar (cp can preserve partitions, but I've had more issues
with cp not working correctly in busybox I prefer tar.)

cd /data/
tar -cvf /system/sd/app.tar app
tar -cvf /system/sd/data.tar data
tar -cvf /system/sd/dalvik-cache.tar dalvik-cache

cd /system/sd

tar -xvf app.tar
tar -xvf data.tar
tar -xvf dalvik-cache.tar

rm *.tar

Step 3: scripts and cleanup.

To mount the ext2 filesystem at boot, we need two scripts. These both go into /system/etc

The first one is called install-recovery.sh and contains the following:

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

The next is called init-sd.sh and contains the following:

#!/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 -o bind /system/sd/data /data/data 1>>$MYLOG 2>>$MYLOG
mount -o bind /system/sd/dalvik-cache /data/dalvik-cache 1>>$MYLOG 2>>$MYLOG
mount >> $MYLOG
echo "$(date) Finishing install-recovery.sh" >> $MYLOG

now you need to use a decent text editor (I like vi) on windows I reccomend notepad++

copy both of these into /system/etc

for example:

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

Now we need to make sure these files are executable with the following commands:

chmod 755 /sdcard/etc/install-recovery.sh
chmod 755 /sdcard/etc/init-sd.sh

Finally, we need to remove everything in the existing /data/app /data/data/ and /data/dalvik-cache
with the following commands:

cd /data/app
busybox rm -rf *
cd /data/data/
busybox rm -rf *
cd /data/dalvik-cache
busybox rm -rf *

now you will notice some odd things happening on the screen of your tablet but that will be fixed
with the command:

reboot

and if all went well you now have all your applications on the sdcard.

~Ivy
 
Last edited:
Still not getting the script to run. No log file in /data either.

How can I see what is happening at boot?

Awesome work ivy.

Sent from my Ideos S7 using Android Tablet Forum App
 
Hi Pvella,

Seeing what's happening at boot time is a little difficult. But have you tried running the commands that would run in the script manually via the adb shell?

also what did you use to write the scripts, as in the windows world, a new line, is different from the unix world, and may break things (notepad is a big cause of this.) I'd recommend making sure that either you're writing the scripts using an editor like notepad++ if you're using windows, or vi if you're a masochist like me.

Also, if the scripts aren't set as exactable, this will cause an issue. the command "chmod +x filename" will fix that. (or chmod 755).

one other question, is the mount working correctly? is /system/sd/ mounted?

if not, if you could run the command mount, and paste the output here, I might be able to see what's going wrong.

~ivy
 
I can run all the steps manually and they work.

I used notepad++ (I too am a vi fan)

I tried all the steps several times. Had it working earlier.

Sent from my Ideos S7 using Android Tablet Forum App
 
Just to make sure here...since we know where the apps are stored on the device, has anyone tried just copying them to the sdcard and then leaving a symlink in their place?
 
ok i am tring to do this with a 16gb sd card
every time i run busybox mke2fs /dev/block/vold/179:2
i get mke2fs: can't open '/dev/block/vold/179:2': No such file or directory
 
I got it working. I ended up using vi on my ubuntu to edit the files. Ivy was right about the files having the wrong characters in them because of windows....

Here are my results...

$ 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,s
hortname=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
/dev/block/vold/179:2 /data/data ext2 rw,errors=continue 0 0
/dev/block/vold/179:2 /data/dalvik-cache ext2 rw,errors=continue 0 0
$ busybox df -h
busybox df -h
Filesystem Size Used Available Use% Mounted on
tmpfs 207.6M 16.0K 207.5M 0% /dev
tmpfs 4.0M 0 4.0M 0% /sqlite_stmt_journals
/dev/block/mtdblock1 160.0M 148.0M 12.0M 93% /system
/dev/block/mtdblock6 175.0M 60.1M 114.9M 34% /data
/dev/block/mtdblock5 94.8M 3.4M 91.4M 4% /cache
/dev/block//vold/179:1
13.4G 6.3G 7.0G 47% /sdcard
/dev/block/vold/179:2
1.4G 126.7M 1.2G 9% /system/sd
/dev/block/vold/179:2
1.4G 126.7M 1.2G 9% /data/app
/dev/block/vold/179:2
1.4G 126.7M 1.2G 9% /data/data
/dev/block/vold/179:2
1.4G 126.7M 1.2G 9% /data/dalvik-cache
$
 
ok i am tring to do this with a 16gb sd card
every time i run busybox mke2fs /dev/block/vold/179:2
i get mke2fs: can't open '/dev/block/vold/179:2': No such file or directory

What I did was use a program called gparted to set up the partitions on the sdcard.

GParted -- Download

The machine seems much faster now that it has breathing space for apps. I am very happy with the installation.
 
ok got the partitions right using my mac
but now when i run cd /data/
tar -cvf /system/sd/app.tar app
i get tar: not found
 
I use this command instead.

busybox cp -a /data/app /system/sd

or

Try putting the word busybox in front of the tar command.

Sent from my Ideos S7 using Android Tablet Forum App
 
The apps2sd is working really well. Been installing many many apps. There is no lag, compatibility or performance issues.

Sent from my Ideos S7 using Android Tablet Forum App
 
Seeing as how this is really starting to come together, I think the first post in this thread should consistently reflect the latest findings and procedures. Quick question...does all of this have to be done through adb, or could these scripts run via terminal emulator?
 
It is a lot easier to use adb. Apart from getting the files to your sdcard,the rest could be done in a terminal emulator. For other devices, I have seen it scripted, so that is also a possibility. Or we could build an app. I am happy to help do this.

Sent from my Ideos S7 using Android Tablet Forum App
 
Back
Top