[Samsung Epic 4G Touch] egingell:
I decided to write a script to do this automatically.

[size=+1]As before, I provide this with no warranties or guarantees. Use at your own risk. Make a NAND backup of at least System and Data before attempting.[/size]

The script assumes you have busybox and root access.

The script does not check for supported hardware. It has only been tested on the SPH-D710.

The script will check for /mnt/sdcard/external_sd, /mnt/emmc, and /mnt/sd-ext and that at least one is mounted. It bails otherwise. If your external SD card is mounted elsewhere, you can add it to line 9 of the script file (`mountpoint <real path to external SD (no symlinks)>`).

This script must be executed from a live boot (ie, not from recovery) using either Root Explorer, Scripter, a terminal emulator, ADB, or anything else that will run scripts as root.

The file must be on an EXT# partition (just put it in /data and you'll be fine) with 777 permissions unless you're using Scripter.

The script backs up your vold.fstab file to /data/vold.fstab.bak. If the backup file exists, the script will restore it, delete the Link2SD file, and delete the backup file.

Executing the script from Recovery is not advisable.

Executing the script after it has already been executed and the backup file no longer exists is also not advisable.

Your phone will reboot immediately after the script has executed.

Method 1 (terminal emulator or ADB shell):

Put the file from the zip into the /data directory.

Use the following commands from the shell:

su
chmod 777 /data/eg.link2sd.sh
sh /data/eg.link2sd.sh

Method 2 (Root Explorer | Root Browser):

Put the file from the zip into the /data directory.

Long tap the file, click "Permissions", check every box (the bottom row (there are only two boxes in that row) can be unchecked), and tap Ok.

Tap the file and tap "Execute".

Method 3 (Scripter):

Put the file from the zip wherever, but remember where.

Open Scripter, tap the "+", tap "Import", find the file, and tap it.

Tap the file in the list, tap "Run script", make sure "Execute script as root" is checked, and tap "Execute".

The full script:

#!/system/bin/sh
LOG=/data/testlog.log
VTEMP=/data/eg.vold.fstab
LTEMP=/data/eg.11link2sd
TEMPFILE=/data/eg.temp
BVOLD=/data/vold.fstab.bak

EXTMOUNTED=""
for N in `mountpoint /mnt/emmc` `mountpoint /mnt/sdcard/external_sd` `mountpoint /mnt/sd-ext`
do
if [ $N ]; then
echo "Found external card. ($N)";
EXTMOUNTED="Yes";
break;
fi
done

if [ ! $EXTMOUNTED ]; then
echo "Can't find external SD card. Make sure it's inserted and mounted and try again.";
exit;
fi

mount -o remount,rw /system

# System files
MOUNTPOINTS=/proc/mounts
VOLD=/system/etc/vold.fstab
LINK2SD=/system/etc/init.d/11link2sd

EXTPATH="";
EXTDEV="";
INTPATH="";
INTDEV="";
LINK2SDPATH="";
LINK2SDDEV="";

x=0;
while [ $x -lt $(cat $MOUNTPOINTS | wc -l) ]
do
let x=x+1;
LINE=`head -n $x $MOUNTPOINTS | tail -n 1`;
DEVICE=`echo "$LINE" | cut -d' ' -f1`;
POINT=`echo "$LINE" | cut -d' ' -f2`;
if [ $POINT = "/mnt/sdcard/external_sd" ] || [ $POINT = "/mnt/emmc" ] || [ $POINT = "/mnt/sd-ext" ]; then # It's the external SD
EXTPATH=$POINT;
EXTDEV=$DEVICE;
elif [ $POINT = "/mnt/sdcard" ]; then
INTPATH=$POINT;
INTDEV=$DEVICE;
elif [ $POINT = "/data/sdext2" ]; then
LINK2SDPATH=$POINT;
LINK2SDDEV=$DEVICE;
fi
done

if [ -f $BVOLD ]; then
echo "Restoring backup. ($BVOLD > $VOLD, '' > $LINK2SD)";
cp $BVOLD $VOLD;
rm $LINK2SD;
rm $BVOLD;
exit;
else
echo "Making backup. ($VOLD > $BVOLD)";
cp $VOLD $BVOLD;
fi

if [ $EXTPATH ] && [ $EXTDEV ]; then
echo "External SD ==";
echo "$EXTPATH: $EXTDEV";
fi
if [ $INTPATH ] && [ $INTDEV ]; then
echo "Internal SD ==";
echo "$INTPATH: $INTDEV";
fi
if [ $LINK2SDPATH ] && [ $LINK2SDDEV ]; then
echo "Link2SD ==";
echo "$LINK2SDPATH: $LINK2SDDEV";
fi

echo "" > $VTEMP;
echo "" > $LTEMP;
echo "" > $TEMPFILE;

echo "#!/system/bin/sh" > $LTEMP;
echo "#added by link2sd" >> $LTEMP;
echo "LOG=/data/link2sd-11link2sd.log" >> $LTEMP;
echo "echo \"\$(date) mounting...\" > \$LOG" >> $LTEMP;
echo "" >> $LTEMP;

VEXT="";
VINT="";

x=0;
while [ $x -lt $(cat $VOLD | wc -l) ]
do
let x=x+1;
LINE=`head -n $x $VOLD | tail -n 1`;
ACTION=`echo "$LINE" | cut -d' ' -f1`;
DEVID=`echo "$LINE" | cut -d' ' -f2`;
POINT=`echo "$LINE" | cut -d' ' -f3`;
PART=`echo "$LINE" | cut -d' ' -f4`;
DEVICE=`echo "$LINE" | cut -d' ' -f5`;
if [ "$POINT" = "$EXTPATH" ]; then # It's the external SD
echo "#$LINE" >> $TEMPFILE;
echo "INT 1" >> $TEMPFILE;
VEXT="$ACTION $DEVID $INTPATH $PART $DEVICE";
elif [ "$POINT" = "$INTPATH" ]; then
echo "#$LINE" >> $TEMPFILE;
echo "EXT 1" >> $TEMPFILE;
VINT="$ACTION $DEVID $EXTPATH 12 $DEVICE";
echo "mount -t vfat -o rw /dev/block/mmcblk0p$PART /data/sdext2 1>>\$LOG 2>>\$LOG" >> $LTEMP;
else
echo "$LINE" >> $TEMPFILE;
fi
done

x=0;
while [ $x -lt $(cat $TEMPFILE | wc -l) ]
do
let x=x+1;
LINE=`head -n $x $TEMPFILE | tail -n 1`;
ACTION=`echo "$LINE" | cut -d' ' -f1`;
if [ "$ACTION" = "EXT" ] && [ "$VEXT" ]; then
echo "$VEXT" >> $VTEMP;
elif [ "$ACTION" = "INT" ] && [ "$VINT" ]; then
echo "$VINT" >> $VTEMP;
else
echo "$LINE" >> $VTEMP;
fi
done

echo "" >> $LTEMP;
echo "mount >> $LOG" >> $LTEMP;
echo "\"\$(date) mount finished\" >> \$LOG" >> $LTEMP;

cp $LTEMP $LINK2SD;
cp $VTEMP $VOLD;
rm $LTEMP;
rm $VTEMP;
rm $TEMPFILE;

chmod 777 $LINK2SD;
mount -o remount,ro /system
reboot;