Friday, September 9, 2016

Workaround for using external storage easily with Termux

Since the internal memory is so valuable on most Android phones, I wanted to use external storage directly. That should be no problem with Termux, the awesome terminal for Android.
But the inconsistent naming of sdcards in Android can always be a problem.

So, there is a directory "~/storage/external".  It points to "/storage/sdcard1/Android/data/com.termux/files"

This doesn't exists on my device (Sony Xperia Z3 tablet compact), and probably not on your device, too. It's the name of the sdcard in my case (5XD3-4FF1)... So for me "/storage/
You can find it with "ls /storage". There should be the sdcard besides other devices. Normally you can easily find it from there.
You can read most files from your sdcard there. But no write access. In Android >=Jelly Bean the write access is pretty much a mess and restricted. But you can write in Termux' own files directory. 

Be brave and (at your own risk) go to "~/storage/". With "ls" you should now see a list like that:

Run these commands:
# cd ~/storage/
# rm external
# ln /storage/5XD3-4FF1/Android/data/com.termux/files external -s

Please replace 5XD3-4FF1 with the name of your sdcard.
Now you can store things easily by accessing "~/storage/external/" from Termux.

Have fun.