Go Back   Android Forums > Android Development > Android System Mods, Scripts and Hacks > Rooted Devices Only

Like Tree1Likes
  • 1 Post By downthemachine

test: Reply
 
LinkBack Thread Tools
Old March 3rd, 2013, 12:32 PM   #1 (permalink)
ROM Developer
Thread Author (OP)
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default [script] Move Game/App data to external SD (Bind)

This is very much a work in progress so would appreciate some input on this please.

For those who have an internal and external sdcard, its a shame that large games download their data to /sdcard/Android/data which is actually the internal SD on devices with both. This is no good as we may have really big microsd cards, but not so much internal SD space and games can be 1 - 1.5 GB in size.

There is an app called Directory Bind on XDA for this, but it doesn't work on 4.2.1 so I am hoping this will work instead. It isn't very elegant though, so would appreciate any input that could make it cleaner.

Code:
#!/system/bin/sh

# Set Default Script location
DIR="$(dirname "$0")"

if [ ! -d $DIR/mounter_defaults ];
then
    mkdir $DIR/mounter_defaults
fi
def=$DIR/mounter_defaults

Main_Menu='Please enter your choice: '
echo "

Main Menu

"
optionsa=("Set Defaults                          "
"Bind using existing defaults          "
"Quit")
select opta in "${optionsa[@]}"
do
    case $opta in
        "Set Defaults                          ")
	echo "

Set Defaults Menu


"
Defaults_Menu='Please enter your choice: '
optionsb=("Select the ExternalSD Mount point" 
"Set Default ExternalSD location (The new location)" 
"Select the InternalSD Mount point" 
"Return to Main menu")
select optb in "${optionsb[@]}"
do
    case $optb in
        "Select the ExternalSD Mount point")
	echo "

Select the ExternalSD Mount point

"
            select extl in /mnt/*; do test -n "$extl" && break; echo ">>> Invalid Selection, please select a number"; done
echo $extl > $def/ext

echo -e "

Set Defaults Menu

1) Select the ExternalSD Mount point
2) Set Default ExternalSD location (The new location)
3) Select the InternalSD Mount point
4) Return to Main menu

"
            ;;
        "Set Default ExternalSD location (The new location)")
	echo "

Set Default ExternalSD location (The new location)

"
            select extldir in $extl/*; do test -n "$extldir" && break; echo ">>> Invalid Selection, please select a number"; done
echo $extldir > $def/extdir

echo -e "

Set Defaults Menu


1) Select the ExternalSD Mount point
2) Set Default ExternalSD location (The new location)
3) Select the InternalSD Mount point
4) Return to Main menu

"
            ;;
        "Select the InternalSD Mount point")
	echo "

Select the InternalSD Mount point

"
            select intl in /mnt/*; do test -n "$intl" && break; echo ">>> Invalid Selection, please select a number"; done
echo $intl > $def/int

echo -e "

Set Defaults Menu

1) Select the ExternalSD Mount point
2) Set Default ExternalSD location (The new location)
3) Select the InternalSD Mount point
4) Return to Main menu

"
            ;;
        "Return to Main menu")
echo -e "1)  Set Defaults 
2)  Bind using existing defaults 
3)  Quit"
break
            ;;
        *) echo invalid option;;
    esac
done
            ;;
        "Bind using existing defaults          ")
	echo "

Bind using existing defaults

"
extdirfile=$def/extdir
extfile=$def/ext
intfile=$def/int
ext=$(<"$extfile")
extdir=$(<"$extdirfile")
int=$(<"$intfile")


# Select the App location to move
printf "

Select the directory to move data FROM: 

"
select AppO in $int/Android/data/*; do test -n "$AppO" && break; echo ">>> Invalid Selection, please select a number"; done


# Select the location to move to
echo -n "

Create a name for the new directory to move data TO (HINT - Use something descriptive): 

"
read AppN

echo -e "

Main Menu

1) Set Defaults                          
2) Bind using existing defaults          
3) Quit

"

# Create the new location
mkdir $extdir/$AppN

# Move the data to the new location
mv $AppO/* $extdir/$AppN/ 2>/dev/null

# Write this data to the bind script.
echo 'mount -o bind '$extdir'/'$AppN' '$AppO'' >> $DIR/bind.sh
sh $DIR/bind.sh
echo -e "

Now use script manager to set bind.sh to run as root on boot

"
            ;;
        "Quit")
            break
            ;;
        *) echo invalid option;;
    esac
done
Yes I know I can use loops etc, but I'm a bash novice so I haven't looked at that yet

So this is "mounter.sh" which can be run via Script manager with the root option

It assumes you want to move stuff FROM /sdcard/Android/data

It gives menu options so you can set the default location of /sdcard, /extSdCard and a default directory to bind all your stuff in (eg /extSdCard/bind).

You can name the new location through the process too. It moves the stuff then mounts it at the end of the process. It also echos that using >> to bind.sh which you have to set in script manager to run as root and at boot.

Instructions
  • Download the script and put it in a (non symlinked, non bound) directory on internal sdcard. Remove .txt from the filename
  • Install Script manager
  • Browse to your script, press it and press the "SU" button (to run it as root)
  • Press "Run"
  • Go through the menu to "Set Defaults" and set your default locations (may need to turn into landscape mode here)
  • Then go through the Bind menu and set up your binds.
  • Set the bind.sh as root and boot
Attached Files
File Type: txt mounter.sh.txt (3.3 KB, 105 views)

Advertisements
SUroot is offline  
Last edited by SUroot; March 4th, 2013 at 02:45 PM.
Reply With Quote
The Following User Says Thank You to SUroot For This Useful Post:
Lateralus138 (March 21st, 2013)
sponsored links
Old March 5th, 2013, 05:29 PM   #2 (permalink)
ROM Developer
Thread Author (OP)
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

OK so my latest is that I can mount using my script with some modifications. To mount across all applications, we need something with even more elevated permissions than su. People are using the debugger daemon, which is ugly but it works. That;s what StickMount uses too.

So you can simply use the mount commands, but they must be in /system/bin/debuggerd and the process must be started (at boot) or after a new mount is created, for the mounts to be visible.

The problem is, debuggerd is unstable if left as the mount commands. The phone seriously freezes, goes black and goes all kind of crazy, so you have to stop the daemon and put it back as it was. You need to do all this every time.

I've pretty much got it scripted here....

It's still Work in progress, so not everything that must be done, is scripted yet. There are some manual steps...

As already mentioned, you need script manager.

Instructions:
  • rename your existing /system/bin/debuggerd to debuggerd.bak (exactly this)
  • from the zip attached to this post, put debuggered.mnt in /system/bin
  • put the mounter.sh and remount.sh in a directory on your internal SD card somewhere
  • browse to this directory in script manager and set mounter.sh as "SU" then run it.
  • Go through the menu (in landscape preferably) and set the defaults (internal lists /data/media - for me in here, I select 0)
  • Then set up a bind through the menu

The script *should" now run the remount (which takes 14 seconds) but I haven't tested this yet. It can be run manually via Script manager too. Just set it as "SU" but also you want it set at boot.

***NOTE, remember, my script assumes you want to bind FROM /sdcard/Android/data/com.appname You can just manually bind using "mount -o bind /mnt/extSdCard/whereveryouwant /data/media/0/whereverelseyouwant and put it in the debuggerd.mnt then just use the remount.sh to do the necessary starting, stopping and debuggerd binary file management.
Attached Files
File Type: zip mounts.zip (1.4 KB, 44 views)
SUroot is offline  
Reply With Quote
Old March 11th, 2013, 05:19 PM   #3 (permalink)
ROM Developer
Thread Author (OP)
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

Ok I am going to mark this thread as deprecated.
SUroot is offline  
Reply With Quote
Old March 12th, 2013, 04:14 PM   #4 (permalink)
Developer Incognito
 
downthemachine's Avatar
 
Join Date: Dec 2011
Location: MinneSnowta
Posts: 2,939
 
Device(s): ZTE Warp (Sugar Kang), Samsung Prevail, HTC Evo Design, LG Optimus Elite, OG Droid
Carrier: Boost Mobile

Thanks: 1,394
Thanked 1,732 Times in 877 Posts
Default Re: [script] Move Game/App data to external SD (Bind)

Quote:
Originally Posted by SUroot View Post
Ok I am going to mark this thread as deprecated.
Or appreciated
SUroot likes this.
downthemachine is online now  
Reply With Quote
Old March 16th, 2013, 04:19 PM   #5 (permalink)
ROM Developer
Thread Author (OP)
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

Well the "0 views" said it all really

Same in the S3 ATR. 150 views+ on XDA though
SUroot is offline  
Reply With Quote
Old March 21st, 2013, 02:09 PM   #6 (permalink)
Junior Member
 
Lateralus138's Avatar
 
Join Date: Aug 2011
Location: decatur, illinois
Gender: Male
Posts: 64
 
Device(s): Rooted ZTE Warp [ROM]AlienWarp - with my mods
Carrier: Boost

Thanks: 13
Thanked 11 Times in 5 Posts
Send a message via Yahoo to Lateralus138 Send a message via Skype™ to Lateralus138
Default

Thanx for this, will check it out on 2 old Lg Apex's I have.
Lateralus138 is offline  
Reply With Quote
Old March 23rd, 2013, 06:57 AM   #7 (permalink)
ROM Developer
Thread Author (OP)
 
SUroot's Avatar
 
Join Date: May 2010
Location: Riddlesden, West Yorkshire, UK
Posts: 23,926
 
Device(s): SGS3 (Current) HTC Desire (Retired)
Carrier: 3 UK

Thanks: 1,923
Thanked 5,324 Times in 3,995 Posts
Default

It was for android 4.2, do they have that? It doesn't work well with some AOSP roms.
SUroot is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Android System Mods, Scripts and Hacks > Rooted Devices Only
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:20 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.