yashsingh1/xdaforums huggingface dataset:
[Galaxy Tab 2 7" Android Development] stranxk:
I have changed some parts on your script to make it rrun without errors this way:

#!/system/bin/sh
LOG=/data/local/tmp/log.txt
exec 3>&1 4>&2 >$LOG 2>&1
echo "Script start"
echo "Now attempting to remount root filesystem RW"
mount -o remount,rw /
echo "Now attempting to remount /system filesystem RW"
mount -o remount,rw /system
echo "Removing regular symlinks"
rm /sdcard
rm /extSdCard

echo "Making reversed symlinks"
ln -s /mnt/sdcard /extSdCard
ln -s /mnt/extSdCard /sdcard

echo "Script done"

The good news is that it partially works, but apps like to save or download data at /mnt/sdcard... when using that directory they are using the internal storage.
[Galaxy Tab 2 7" Android Development] DivinityCycle:
I have been hacking away on ICS / CM9. Here's what I have determined:

1-You'll need to execute the script using some sort of "auto start" application like Script Manager, init.rc and userinit.sh won't work.

2-I haven't been able to find a mount point for the internal sdcard storage space. Without this, I don't see any way to re-mount that storage anywhere aside from /mnt/sdcard

3-I'm relatively certain that because of how the internal sdcard is mounted up during boot, modifying vold.fstab will not work either.

The external micro SD card slot can be found at /dev/block/vold/179:25 as well as at /dev/block/platform/omap/omap_hsmmc.0/mmcblk1p1

I have crawled through the various other devices in /dev/block/vold and /dev/block/platform/omap, and as far as I can tell, no internal sdcard.

So, pretty much like I posted earlier, for now, if you're running CM9 or ICS on this device, you can have this script auto-run via Script Manager or a similar app.

#!/system/bin/sh
LOG=/data/local/sdcard_log.txt
exec 3>&1 4>&2 >$LOG 2>&1
echo "Now Running SDCard Rotate Script"
echo "Now unmounting internal storage from /mnt/sdcard"
umount /mnt/sdcard
# echo "Now unmounting micro SD card from /mnt/extSdCard"
# umount /mnt/extSdCard
echo "Now mounting micro SD card to /mnt/sdcard"
mount -t vfat -o umask=0000 /dev/block/vold/179:25 /mnt/sdcard
echo "Script done"

I have commented out some of the stuff until we can find the actual mountpoint for the internal sdcard, which will then let us mount that to a different mount point.

Also note that if we can't find a way to "fix" the mounts via vold.fstab (which I don't think is doable in ICS), it will not be possible to package this up into a flashable ZIP.

Time for sleep!
[Galaxy Tab 2 7" Android Development] DivinityCycle:
May have made some progress, I think I figured out the sdcard riddle. It looks like the "sdcard" file system is setup by this command being run during boot-up:

service sdcard /system/bin/sdcard /data/media 1023 1023

Need to sleep, but if this is true then the internal "sdcard" storage is simply located in /data/media. I'm pretty sure with this info I can work out a something that uses some sort of symlink or vold.fstab solution. I'm not sure if this will be applicable to JB, or if that'll even matter, but we'll see.
[Galaxy Tab 2 7" Android Development] DivinityCycle:
OK, I wasn't very sleepy so I finished this up.

-EDIT-

I thought I had finished this up, since the script below actually does mount the microSD card to /mnt/sdcard. However, there are currently permissions issues on the mount, I can't seem to get it to stick with RW permissions on boot.

#!/system/bin/sh
LOG=/data/local/log.txt
exec 3>&1 4>&2 >$LOG 2>&1
echo "Script start"
echo "Now attempting to remount root filesystem RW"
mount -o remount,rw /
echo "Now attempting to remount /system filesystem RW"
mount -o remount,rw /system
echo "Now attempting to mount micro SD card to /mnt/sdcard"
mount -t vfat -o rw,umask=0000 /dev/block/platform/omap/omap_hsmmc.0/mmcblk1p1 /mnt/sdcard
echo "Now removing existing /mnt/extSdCard"
rm /mnt/extSdCard
rm -r /mnt/extSdCard
echo "Now linking /data/media to /mnt/extSdCard"
ln -s /data/media /mnt/extSdCard
echo "Now linking /extSdCard to /mnt/extSdCard"
ln -s /mnt/extSdCard /extSdCard
echo "Script done"
[Galaxy Tab 2 7" Android Development] poulsen93:
It WORKS :D

But I get a massive decrease in performance from this, oppose to the manually launching your previous script at boot :(
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Yeah, I'm pretty sure for the external card to work right, it needs to be mounted using vold. However, vold initializes after userinit runs, so that means its back to running it via Script Manager. I have a couple other things I need to try, but I'm thinking this is pretty much it.
[Galaxy Tab 2 7" Android Development] poulsen93:
If we can unmount /sdcard via a script, and then edit vold.fstab to mount the "real" sdcard to /sdcard, do you think that would work?
[Galaxy Tab 2 7" Android Development] poulsen93:
Nice, you got it working! :victory: Your the MAN!

But I must say, you are right, I will soon force feed my tab with some Jelly Beans.
[Galaxy Tab 2 7" Android Development] CYBERFANT:
Hi, i am to stupid to use the Script Manager App. I use the Script Manager from devwom. (https://play.google.com/store/apps/details?id=os.tools.scriptmanager&feature=more_from_developer)

I put the Script named sdcard.sh to /data/local/sdcard.sh.

When i execute the Script manual over the Script Manager App, i becomes a error

When i use an other App (Scripter) the script work fine. Any ideas?
[Galaxy Tab 2 7" Android Development] CXENTE:
Just checking in, is there a zip file, we can flash for the extSDcard mount :) just wanted to know if this was still being worked on, thanks
[Galaxy Tab 2 7" Android Development] DivinityCycle:
@ Cyberfant, are you running the stock Samsung ROM? Cuz I have only ever tested this stuff on CM9 and CM10, and it may not work at all on the stock stuff.

@CXENTE it's been on my to-do list for a while, but I have had it on the back burner since my current solution "works for me".

I just got my boot animation stuff and the phone / SMS stuff pretty much figured out so now I'm ready to mess with making my own ZIPs next. Life just gets busy sometimes :P
[Galaxy Tab 2 7" Android Development] CXENTE:
@CXENTE it's been on my to-do list for a while, but I have had it on the back burner since my current solution "works for me".

I just got my boot animation stuff and the phone / SMS stuff pretty much figured out so now I'm ready to mess with making my own ZIPs next. Life just gets busy sometimes :P[/QUOTE]

Thank you ,thank you thank you... :thumbup::D:beer:
[Galaxy Tab 2 7" Android Development] azturbomini:
I want to thank you for working on this. I do not have the knowledge to do this and a flashable zip would be awesome!

Thanks again!
[Galaxy Tab 2 7" Android Development] primetime34:
+1 for a working zip that can be flashed. This is a huge shortcoming for this tablet and having a nice workaround would be fantastic. Thanks for all your work.
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Didn't get much work done this weekend because I ended up getting sucked into a different project entirely (XBMC-related), plus we had a serious heat wave. I don't know why we couldn't get super hot weather during the week when I'm in an air-conditioned office all day, but whatever.

In addition to that, I was working on "cleaning up" my tab and managed to need to factory reset it, and now my script doesn't work for me at all :(

So I'll be troubleshooting that today, in addition to developing my own flashable ZIPs. My plan is to make myself a single flashable ZIP with pretty much all the tweaks and extras that I usually do (boot animation, SSH & rsync, Adobe Flash, MMS.apk, and my SD card swap script :))

However, first step is figure out why my script no longer works for me. It's creating a log file but not writing to it...
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Well, that's pretty dumb... Looks like the "fancy" way I was trying to capture the script output to a log file was causing the problems.

Here's the current working CM10 userinit.sh script:

#!/system/bin/sh
LOG=/data/local/tmp/log.txt
echo "Script start">$LOG
echo "Now attempting to remount root filesystem RW">>$LOG
mount -o remount,rw /
echo "Now attempting to remount /system filesystem RW">>$LOG
mount -o remount,rw /system
echo "Removing regular symlinks">>$LOG
rm /sdcard
rm /mnt/sdcard
rm /extSdCard
rm /mnt/extSdCard

echo "Making reversed symlinks">>$LOG
ln -s /storage/sdcard1 /sdcard
ln -s /storage/sdcard1 /mnt/sdcard
ln -s /storage/sdcard0 /extSdCard
ln -s /storage/sdcard0 /mnt/extSdCard

echo "Script done">>$LOG

This will re-write the log at boot each time.

Next step: package this as a ZIP for the CM10 users on this board :)
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Man oh man do I hate Edify scripting! I haven't figured out a faster / easier way to work on it than to edit my script, reload it into my .zip payload, then load that onto my tab, reboot, and try to flash it. This + a normal work day have made it slow going.

I am stuck on the first and most crucial step: Need to figure out how to mount the /data partition so I can write to it.

The update script inside the GApps package for this device uses the command

run_program("/sbin/busybox", "mount", "/system");

to mount the system partition for writing. However, the same thing but with /data slapped in there does not work.

Of the documentation I can find, this looks to be right:

mount(fs_type, partition_type, location, mount_point)

So, in my actual script I tried various permutations of:

mount("ext4", "EMMC", "/dev/block/mmcblk0p10", "data");

No luck.

Any suggestions, gang?
[Galaxy Tab 2 7" Android Development] wowmail:
I'm not totally sure if this applies (I'm a tester more then programmer) but I know I can not see, or mount data without being root or logging as su.

Hope this helps
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Right, but this is the installer script that's run when you "Flash" the zip within Clockwork Mod. As best I can tell, literally everything is done with full root access, which is why the syntax for changing permissions looks like this:

set_perm(0, 0, 0755, "/system/addon.d/70-gapps.sh");

Looks like its possible to run shell scripts from the installer script, so I may be able to use that to enumerate what's where in the file system from within CWM, which will then let me figure out how to mount /data. Its so annoying cuz the rest of the install script is trivial, and I have a bunch of other zip projects I want to do, so this is like the first step to all of it.
[Galaxy Tab 2 7" Android Development] wowmail:
Ok, Ill do a nandroid and start testing scripts, will post if I find something. Thank you , we really need this simple thing that Google / Samsung should have figured out!
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Got the installer script sorted out, I think.

Here's what is working for me:

ui_print("");
ui_print("============================");
ui_print("= SDCARD MOUNT SWAP SCRIPT =");
ui_print("============================");
ui_print("");
ui_print("Now mounting /data.");
run_program("/sbin/busybox", "mount", "/data");
ifelse( is_mounted("/data"), ui_print("Successfully mounted /data partition."), ui_print("Mount failed."));
ui_print("Now copying script to /data/local.");
package_extract_dir("data", "/data");
ui_print("Now setting script permissions.");
set_perm(0, 0, 0700, "/data/local/userinit.sh");
ui_print("");
ui_print("");
ui_print("");

It looks like the Edify interpreter is pretty fickle. What's incredibly frustrating is that the zip actually did install the script, and set the permissions as needed, but the script isn't working! I am pretty close to done, will post once I have it all good.
[Galaxy Tab 2 7" Android Development] DivinityCycle:
OK guys I have the "beta" of the flashable script for use with the CM10 nightly ROM.

Need people to test it out.

I just tested it out and it works great for me.

Let me know how it works.

You can tell things are working if after you boot and go to /sdcard you see your micro SD card contents.
[Galaxy Tab 2 7" Android Development] joemilan:
Thank first for your work. I have Rom Stock rooted: i can flash it the same?
[Galaxy Tab 2 7" Android Development] DivinityCycle:
You can but I'm pretty sure it'll do nothing, since as far as I know, the stock Android OS doesn't support userinit scripts, so the script would be installed but then just sit there.

Also the way elements are mounted and handled in Jellybean is different from Ice Cream Sandwich, so the script wouldn't work anyway.

As previously covered in this thread, on ICS the best solution I could find was to run the ICS version of the script via an app like Script Manager at boot.

Because of this, the ICS script can't really be made "flashable" the same way. Even on CM9, userinit runs too early in the boot process and so running it via app is still required. Sorry about that, but unless somebody finds a better way to do it, that's about all you can do.

Attached is a zip of the ICS version of the script, which contains this:

#!/system/bin/sh
LOG=/data/local/sdcard_log.txt
exec 3>&1 4>&2 >$LOG 2>&1
echo "Now Running SDCard Rotate Script"
echo "Now unmounting internal storage from /mnt/sdcard"
umount /mnt/sdcard
# echo "Now unmounting micro SD card from /mnt/extSdCard"
# umount /mnt/extSdCard
echo "Now mounting micro SD card to /mnt/sdcard"
mount -t vfat -o umask=0000 /dev/block/vold/179:25 /mnt/sdcard
echo "Script done"

Download & unzip that file, and then use an app like Script Manager to set it up to run at boot as root.
[Galaxy Tab 2 7" Android Development] coolypf:
mount -o bind /mnt/exSdCard/obb /mnt/sdcard/Android/obb

is enough for me
[Galaxy Tab 2 7" Android Development] CXENTE:
I see the SD card? But yet , I'm still low in storage space,, still can't move apps too it... :confused:
[Galaxy Tab 2 7" Android Development] DivinityCycle:
I honestly don't know WTF you're trying to say / do with that command. It doesn't appear to do anything, since /mnt/extSdCard/obb isn't a thing that exists. Kinda seems like you didn't read the rest of this thread.

@CXENTE

It looks like there's really no way around the need to run this script post-boot via something like SManager. I still might be able to make the whole thing flashable but that'll be tricky.

In the meantime, I was able to get a 100% working post-boot script for CM10. I had to change it up to use /storage/sdcard0 and /storage/sdcard1. These are the real roots of the two "sdcard" spaces, and unless you do stuff to them, the system just won't recognize things properly.

Check out how it looks post-script:

The script itself is pretty simple, since I now have working mount points for everything.

#!/system/bin/sh
2>&1;
LOG=/data/local/sdcard_log.txt;
echo "Now Running SDCard Rotate Script">$LOG;
echo "Now attempting to remount root filesystem RW">>$LOG;
mount -o remount,rw />>$LOG;
echo "Now attempting to remount /system filesystem RW">>$LOG;
mount -o remount,rw /system>>$LOG;
echo "Now freeing up /storage/sdcard1 point by unmounting it.">>$LOG;
umount /storage/sdcard1>>$LOG;
echo "Now binding the fake SD card space to /storage/sdcard1">>$LOG;
mount -o bind /storage/sdcard0 /storage/sdcard1>>$LOG;
echo "Now that the fake sd card is basically mounted to /storage/sdcard1, mount the real on to sdcard0">>$LOG;
mount -t vfat -o umask=0000 /dev/block/vold/179:25 /storage/sdcard0>>$LOG;
echo "Script done">>$LOG;

You'll need to run this as root at boot using SManager or something equivalent.

Attached is a zip of the .SH file for easier install.
[Galaxy Tab 2 7" Android Development] CXENTE:
The script itself is pretty simple, since I now have working mount points for everything.

#!/system/bin/sh
2>&1;
LOG=/data/local/sdcard_log.txt;
echo "Now Running SDCard Rotate Script">$LOG;
echo "Now attempting to remount root filesystem RW">>$LOG;
mount -o remount,rw />>$LOG;
echo "Now attempting to remount /system filesystem RW">>$LOG;
mount -o remount,rw /system>>$LOG;
echo "Now freeing up /storage/sdcard1 point by unmounting it.">>$LOG;
umount /storage/sdcard1>>$LOG;
echo "Now binding the fake SD card space to /storage/sdcard1">>$LOG;
mount -o bind /storage/sdcard0 /storage/sdcard1>>$LOG;
echo "Now that the fake sd card is basically mounted to /storage/sdcard1, mount the real on to sdcard0">>$LOG;
mount -t vfat -o umask=0000 /dev/block/vold/179:25 /storage/sdcard0>>$LOG;
echo "Script done">>$LOG;

You'll need to run this as root at boot using SManager or something equivalent.

Attached is a zip of the .SH file for easier install.[/QUOTE].

I never used "SManager" , I guess I'm going to give it a try :) thanks for replying
[Galaxy Tab 2 7" Android Development] CXENTE:
I think I got it :D
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Wow, you were seriously low on space!

Now its time for one of these: http://www.newegg.com/Product/Product.aspx?Item=N82E16820301037

:D
[Galaxy Tab 2 7" Android Development] CXENTE:
Thanks again :D your a genius :thumbup::D:beer: and I'm on it ;) 32GB , is the most, this tablet can take huh
[Galaxy Tab 2 7" Android Development] coolypf:
Since soft link does not work on FAT32, mount -o bind is a good replacement.
[Galaxy Tab 2 7" Android Development] azturbomini:
Could someone walk me through the steps to accomplish this please. (LAYMENS TERMS)

Thank you!
[Galaxy Tab 2 7" Android Development] DivinityCycle:
What are you referring to?
[Galaxy Tab 2 7" Android Development] DivinityCycle:
After dicking around with various screencasting apps for a couple hours I have decided to just do it in pictures / text.

For Jellybean / CM10

Step 1-Download the script From Here onto your phone and unzip it. I suggest putting it in /data/local, since that's always available and isn't on either of the "sdcard" spaces.

Step 2-I am using Script Manager in this example. I'm sure there are some other apps that can launch shell scripts, but this is the one I know works. Download it here.

Step 3-Launch Script Manager and you should end up in a file browser like this:

Navigate to where your script was unzipped (I reccomended /data/local) and then click on it to get the script management screen:

Step 4-Hit both the SU and Boot buttons since we need this script to run at boot as root. The buttons will light up like this: (check out my awesome MS Paint skillz!)

Step 5-Back out of there back to home and then reboot your device

Step 6-Profit?
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Its the most you can get up to without the standard formatting. If you wanna go over that I think you gotta use some other file system, like NTFS?
[Galaxy Tab 2 7" Android Development] coolypf:
There is no need to change around mount points.

To move data from /sdcard to /exSdCard transparently, mount -o bind is enough.
[Galaxy Tab 2 7" Android Development] DivinityCycle:
If you say so. I was mostly asking about "soft links", which you mentioned in your previous post but no one else mentioned or asked about in the entire thread. If you read my script you'd see I use mount -o bind to move the mount point for the fake sdcard. The main reason to modify the actual mount points is to make everything use the external sdcard.
[Galaxy Tab 2 7" Android Development] flukeSG2:
Is this a permanent fix, do I need to keep the SManager installed on my device for it to work every time?

Also I assume since we are swapping locations of the SD cards, I will have to transfer all my data for my apps to work?
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Script Manager runs the script that switches up the mount points at launch. If you uninstall Script Manager, it can't run the script.

And yes, you'll want to copy the data over from the "internal" to the "external" storage areas so that when you everything will just work.
[Galaxy Tab 2 7" Android Development] flukeSG2:
Out of curiosity, is this the only way to achieve these results by running this script? Is there anything in system files that can be edited to make this permanent without using script manage?
[Galaxy Tab 2 7" Android Development] DivinityCycle:
you'd need to be able to modify and rebuild the boot.img.

You are welcome to do that, just please release your work here.

I have posted all of my work and findings here, so maybe I missed something?
[Galaxy Tab 2 7" Android Development] flukeSG2:
I cant seem to download anything from the market now, it keeps saying insufficient space, even though i have 11gb free on my sdcard. Have you had any issues like that?

ok so here is the wierd part, not all apps are sayin that. i managed to install a few, but some just wont i stall because "insufficient space". i think its not insufficient space, but actually they arent compatible and thats why tbey wont install.
[Galaxy Tab 2 7" Android Development] AlexM555:
You have to have /sdcard/cache available with 1GB of free space. if your cache + download program size exceeds 1GB, it will tell you that you have insufficient space to download. Clear your cache to fix the problem.
[Galaxy Tab 2 7" Android Development] DivinityCycle:
No, I haven't seen anything like that.I am also pretty sure that has nothing yo do with this. Apps install to /data,not any of the sdcard spaces...
[Galaxy Tab 2 7" Android Development] flukeSG2:
Clearing the cache isn't changing anything. I even went back to a nandroid before I added this script and I could download again, I tried the script again and the same apps are giving me insufficient storage errors.
[Galaxy Tab 2 7" Android Development] flukeSG2:
CyanogenMod 10 Aug 10th nightly.
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Yeah I have no idea then.

Are both /sdcard and /extSdCard writable?

Do you have anything useful in the script's logfile?

Also, what apps are doing this?
[Galaxy Tab 2 7" Android Development] flukeSG2:
Both were writable, the app that was first on my list was ZipSigner2 and there were a couple others but I can't remember which now. I already reverted to an older nandroid before I did this so I don't have the logfiles, didn't think about that before I changed back.
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Alrighty then. Don't know what to tell you, I just installed ZipSigner2 without any issues.
[Galaxy Tab 2 7" Android Development] tkalfaoglu:
* * HOPELESS * *

I just realized that /mnt/sdcard is mounted R/O, and no plausible way to unmount it, as /etc/ is also R/O , and "ln" function is "not implemented":(

why not just

UPDATE..

I'm trying it now, and I'm changing the above commands slightly..

PS: cp -a gives lots of errors about not being able to symlink and owner preservation (must be FAT32 crap of the SD card)

Samsung Galaxy Tab II, 7", rooted, stock ROM.
[Galaxy Tab 2 7" Android Development] DivinityCycle:
Yeah, none of your suggested commands would work for a couple different reasons.

Yesterday I learned how to modify the boot.img, so I can actually probably change this stuff without a post-launch script.

However, I'm still working it out.