Create symlink/mount/bind in root I want to compile (through make) on my Android phone. I have root access.

I have almost all the things set up.
But there's this hitch. All the configure files have a shebang of #!/bin/sh.
I can execute them by $SHELL configure
I've also set $CONFIG_SHELL
But some configure files execute other shell scripts and they give the /bin/sh: no such file or directory.

I'm thinking about creating a symlink /bin/sh -> /system/bin/sh
I've read somewhere that the root file system is the ramdisk and any changes to it will require to be done in the init.rc file.
So, if I want to accomplish this I'd need to first create a directory 'bin' then make a symlink 'sh' in it. I doubt that ln will work in init.rc.

I have this another idea.
Make a directory 'bin' somewhere preferably in Terminal IDE's (I'm using that) data directory. Then create a symlink in there sh -> /system/bin/sh.
Then create 'bin' in / through and use mount the first bin to /bin through init.rc

Thirdly, I can just mkdir bin and cp /system/bin/sh /bin/sh

Also, all of these methods will fail and result in boot failure if any of the source directories cannot be found.

I want to know which method will be more safe and if there exists a safer alternative?
@vishalbiswas
For that to work you may also need to export PATH and LD_LIBRARY_PATH

you can actually script out your required set up and push that script to xbin so it be run as executable. so you would be looking at something like this
for setup name the script to what works for you

#!/system/bin/sh
mount -o rw,remount /
mkdir /bin &amp;&amp; mkdir /lib
chmod 755 /bin /lib
mount -o bind /system/bin /bin
mount -o bind /system/lib /lib
export PATH=/bin &amp;&amp; export LD_LIBRARY_PATH=/lib


the above is loose, tinker with it a little, now to close it out mostly reverse order

#!/system/bin/sh
umount /bin &amp;&amp; umount /lib
mount -o ro,remount /


the directories /bin and /lib should vanish on reboot since they are living in ram
and you shouldn't need to unset PATH and LD_LIBRARY_PATH as when you close your terminal instance those variables should die with it.

The other approach is to set up a no-frills chrooted arm linux in your external sd card's second partition. I use debian and customed my init.environ.rc as follows

# set up the global environment
on init
    export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/gcc/bin:/system/xbin:/bin:/usr/bin:/usr/sbin
    export LD_LIBRARY_PATH /system/lib:/system/gcc/lib:/system/vendor/lib
    export ANDROID_BOOTLOGO 1
    export ANDROID_ROOT /system
    export ANDROID_ASSETS /system/app
    export ANDROID_DATA /data
    export ANDROID_STORAGE /storage
    export ASEC_MOUNTPOINT /mnt/asec
    export LOOP_MOUNTPOINT /mnt/obb
    export BOOTCLASSPATH [blah blah jars blah xD ]

# Debian CHROOT
    export DEBIAN_ROOT /debian
    export TMPDIR /tmp
    mount -t proc none /debian/proc
    mount -t sysfs none /debian/sys
    mount -o bind /dev /debian/dev
    mount -o bind /proc/net /debian/proc/net
    mount -t devpts none /debian/dev/pts


in this approach your file manager should read your chroot partition files directories and all without issue. i use total commander.

EDIT- i forgot the necessary entry in fstab it goes as follows, again adjust to your device's scheme

/dev/block/platform/msm_sdcc.2/by-num/p2              /debian      ext4    rw,errors=panic                               wait


Here is the tutorial i learned to do the above from
http://whiteboard.ping.se/Android/Debian

Do look for a fairly current distro image though.
As long as you don't try to delete a bind mounted directory without first UNMOUNTING IT [ i have never ever ever done that btw] you won't accidentally delete your system.