[EXPANDSD] Join your external SD with internal SD!

Search This thread

ownhere

Senior Member
Jun 17, 2010
213
286
Beijing
WARN: For developer only.

attachment is the EXPANDSD script.

Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.

How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh

Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.
 

Attachments

  • init_expandsd.sh.txt
    3.6 KB · Views: 1,526

LuffyPSP

Senior Member
Aug 1, 2010
2,276
165
woohoo a great dev has come. :D glad you got here mate! love your work on Desire section.
 

TheFirstBen

Member
Jan 1, 2008
22
2
It's a great idea thanks a lot for your work. I was wondering why ln was not working.

But too bad it does not work for me, i get the following error :
[1] Segmentation fault

Do you have any idea why ?

Thanks again
 
  • Like
Reactions: BRG
D

Deleted member 267841

Guest
problems when connecting phone to pc

hi,
tried the "mount --bind" in order to try your script.
works fine. the directory contents is shared between the 2 path's,
but i have a problem when i connect the phone to a pc.
when i try to disconnect, the sdcard and external_sd are not
available anymore until i reboot the phone :(

note: the commands that i have executed are:
Code:
mkdir /mnt/sdcard/external_sd/foo
echo "test" > /mnt/sdcard/external_sd/foo/test
mkdir /mnt/sdcard/foo
mount --bind /mnt/sdcard/external_sd/foo /mnt/sdcard/foo
 
Last edited by a moderator:

skeptic1007

Senior Member
Jul 24, 2010
298
51
Can this script be placed in init.d folder for autorun at boot?

Edit: sorry, already answered above: no, it cannot.

Sent from my GT-P1000 using Tapatalk
 
Last edited:

dawabz94

Senior Member
Sep 24, 2010
522
104
France
WARN: For developer only.

attachment is the EXPANDSD script.

Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.

How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh

Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.

thanks,

this is genius


I'm not using your script (have myself some ux & scripting skills) but did not know about the -bind option on android
Ridiculously simple and efficient
Did it my own way and it works great

Thanks a lot for this :)
 

dawabz94

Senior Member
Sep 24, 2010
522
104
France
Then why not share with us :D please !
Let us know how you did :)

Hi,

it's very easy indeed, once you got the point.

I do most of my stuff using an "adb shell" session so I'll post here my steps to get it working.

Also I like simple implementation so my script is the strict minimum needed to mount necessary folders

I assume you have a rooted device with working busybox and a kernel that supports /etc/init.d/

I suggest you do the test on a dummy folder before applying on a real folder.

So start by creating a folder called /sdcard/dummy

Do it the way you want , I do it with an "adb shell" session

Code:
cd /sdcard
mkdir dummy

Then copy some files in it (photos for examples)

Code:
cd /sdcard
cd DCIM
cd Camera
cp `ls -1 |tail -5` /sdcard/dummy

From now on, we consider we want to move transparently /sdcard/dummy to the external SD

1. move the folder to the external sd

CAUTION : I'm running a CM9 rom => my external sd is mounted on /mnt/emmc
Standard samsung sdcard mount is /sdcard/external_sd
The path might be different according to your brand and rom

Moving the folder code

Code:
cd /sdcard
mv dummy /mnt/emmc/

2. Create the mount point in the indernal SD

Code:
cd /sdcard
mkdir dummy

3.a Check the mount is successful by manually doing it

Code:
mount --bind /mnt/emmc/dummy /sdcard/dummy

3.b Check you see exactly the same thing on both folders

Both commands should return exactly the same output
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy

If everything is fine, then you're good to go

4. Automate mount at boot time

Create a script in /etc/init.d to automate the mount at boot time

I personally use "vi" but most people prefer graphical UIs, I can't recommend any here, do it your own way

So basically you would go root,remount /system in read/write mode and create the file

Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
vi 90binds

Insert following lines, save and exit

Note that the "sleep 60" is to let the system boot up before mounting partitions (thanks to the initial script shared here)

Code:
#!/system/bin/sh
sleep 60
mount --bind /mnt/emmc/dummy /sdcard/dummy

Change owner and permissions, flush disk cache and remount /system in read only

Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
chown root:shell
chmod 6755 90binds
sync
mount -o remount,ro /dev/block/mmcblk0p9 /system

To check, run
Code:
su
cd /etc/init.d
ls -l 90binds

The output should look like this :
Code:
-rwsr-sr-x    1 root     shell             [I]0 MMM  D HH:MM[/I] 90binds

5. Now you can reboot and check - after reboot - that the mount is done

Both commands should return exactly the same output (always ran in an "adb shell" session)
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy

6. Now you're good to move other folders
Basically, you move the folder to external SD
Create the mount point on the internal SD
Append the mount command in the 90binds script

And that's it


Hope this helps :)

---------- Post added at 11:09 AM ---------- Previous post was at 11:04 AM ----------

Yes I'd like to know another method also.!

Sent from my GT-I9100 using XDA

Just posted :)

Take time to read and understand the idea
 

Top Liked Posts

  • There are no posts matching your filters.
  • 12
    WARN: For developer only.

    attachment is the EXPANDSD script.

    Why use it?
    So many applications use /sdcard for mass data storage(gameloft, navigation...),
    but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
    But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.

    How to use:
    1.make expandsd.ownhere dirctory in external_sd root directory.
    2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
    3.run init_expandsd.sh

    Theory:
    use 'mount --bind' feature, bind external_sd's dir to internal_sd.
    Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.
    2
    Then why not share with us :D please !
    Let us know how you did :)

    Hi,

    it's very easy indeed, once you got the point.

    I do most of my stuff using an "adb shell" session so I'll post here my steps to get it working.

    Also I like simple implementation so my script is the strict minimum needed to mount necessary folders

    I assume you have a rooted device with working busybox and a kernel that supports /etc/init.d/

    I suggest you do the test on a dummy folder before applying on a real folder.

    So start by creating a folder called /sdcard/dummy

    Do it the way you want , I do it with an "adb shell" session

    Code:
    cd /sdcard
    mkdir dummy

    Then copy some files in it (photos for examples)

    Code:
    cd /sdcard
    cd DCIM
    cd Camera
    cp `ls -1 |tail -5` /sdcard/dummy

    From now on, we consider we want to move transparently /sdcard/dummy to the external SD

    1. move the folder to the external sd

    CAUTION : I'm running a CM9 rom => my external sd is mounted on /mnt/emmc
    Standard samsung sdcard mount is /sdcard/external_sd
    The path might be different according to your brand and rom

    Moving the folder code

    Code:
    cd /sdcard
    mv dummy /mnt/emmc/

    2. Create the mount point in the indernal SD

    Code:
    cd /sdcard
    mkdir dummy

    3.a Check the mount is successful by manually doing it

    Code:
    mount --bind /mnt/emmc/dummy /sdcard/dummy

    3.b Check you see exactly the same thing on both folders

    Both commands should return exactly the same output
    Code:
    ls -l /sdcard/dummy
    Code:
    ls -l /mnt/emmc/dummy

    If everything is fine, then you're good to go

    4. Automate mount at boot time

    Create a script in /etc/init.d to automate the mount at boot time

    I personally use "vi" but most people prefer graphical UIs, I can't recommend any here, do it your own way

    So basically you would go root,remount /system in read/write mode and create the file

    Code:
    su
    mount -o remount,rw /dev/block/mmcblk0p9 /system
    cd /etc/init.d
    vi 90binds

    Insert following lines, save and exit

    Note that the "sleep 60" is to let the system boot up before mounting partitions (thanks to the initial script shared here)

    Code:
    #!/system/bin/sh
    sleep 60
    mount --bind /mnt/emmc/dummy /sdcard/dummy

    Change owner and permissions, flush disk cache and remount /system in read only

    Code:
    su
    mount -o remount,rw /dev/block/mmcblk0p9 /system
    cd /etc/init.d
    chown root:shell
    chmod 6755 90binds
    sync
    mount -o remount,ro /dev/block/mmcblk0p9 /system

    To check, run
    Code:
    su
    cd /etc/init.d
    ls -l 90binds

    The output should look like this :
    Code:
    -rwsr-sr-x    1 root     shell             [I]0 MMM  D HH:MM[/I] 90binds

    5. Now you can reboot and check - after reboot - that the mount is done

    Both commands should return exactly the same output (always ran in an "adb shell" session)
    Code:
    ls -l /sdcard/dummy
    Code:
    ls -l /mnt/emmc/dummy

    6. Now you're good to move other folders
    Basically, you move the folder to external SD
    Create the mount point on the internal SD
    Append the mount command in the 90binds script

    And that's it


    Hope this helps :)

    ---------- Post added at 11:09 AM ---------- Previous post was at 11:04 AM ----------

    Yes I'd like to know another method also.!

    Sent from my GT-I9100 using XDA

    Just posted :)

    Take time to read and understand the idea
    1
    Hi mate,

    Thks for your shares. I have a question. How run init_expandsd.sh?

    you can try to use terminal emu, just type su then navigate to folder where the script located, then type sh init_expandsd.sh then enter. this might do the trick to execute .sh ;)
    1
    It's a great idea thanks a lot for your work. I was wondering why ln was not working.

    But too bad it does not work for me, i get the following error :
    [1] Segmentation fault

    Do you have any idea why ?

    Thanks again