[How To] Mount a Nas Drive / Cloud Services Natively to Android

Post Reply
thering1975
Posts: 50
Joined: Sat Apr 18, 2020 12:39 am
languages_spoken: english
Has thanked: 7 times
Been thanked: 9 times
Contact:

[How To] Mount a Nas Drive / Cloud Services Natively to Android

Post by thering1975 »

I wanted to try and get a network drive mounted natively in android so that various apps such as retroarch can see the roms files rather than having to copy them to an external ssd.

What i mean by natively is that your remote drive will appear automatically in any file browser or app and can be browsed like you were browsing internal memory. The drive /cloud service is mounted at boot and survives reboots.

This guide is no means the defacto way of doing it and comes with no guarantees and will be updated once i work out the best settings for speed and reliability.

If you choose to follow this guide then you must understand that google will be your support as i have just worked through this today and there are too many variables that could cause issues.

I can only vouch this works on my setup, which is Voodiks ATV 10 Rom, i offer no guarantees this will work on other roms boxes etc.

Proceed at your own risk lol (reminds me of the good ole XDA Dev days).

Pre-Requisites

Android Installed obviously (i am using Voodiks ATV 10 edition)
Magisk Installed (this is required - easy to install, download from Voodiks rom page, reboot to recovery and flash - not sure if works on non voodiks roms)
Termux from the play store
SSH access or File explorer that shows hidden files (i use solid explorer, however i did find it easier using filezilla and connecting via Magisk SSH module (thats a whole different tutorial lol))

Your Nas must be setup to allow the connection type you pick below i.e sftp or webdav etc, have any port numbers ready and setup, setup user and password etc as per your nas drive and folder permissions. If connecting to cloud like google, dropbox etc get the connection details from them)

Okay so lets say you have magisk installed and it's setup correctly you need to do the following:
1) Open Magisk Manager
2) In the menu click on downloads
3) Scroll through the list until you come to rclone-mount
4) Click install and wait until it shows you it is installed
5) It should reboot but after successful install if it does not, reboot your device

Preparation

This step can be done either via FTP client (if you have ssh magisk module installed) or via File browser like Solid Explorer.

1) Navigate to your Internal Memory (where your download / dcim etc folders are) make sure hidden files are viewable
2) Create a hidden folder and call it ".rclone" without the question marks obviously
3) Create a file called ".global.param" (this can be done on a pc before you start and copied to your box ready for placing in the folder mentioned above. These can be adjusted after to improve performance but will get you going for now, or you can create the file in your file manager)

Code: Select all

CACHEMODE=minimal
BINDSD=1
ADD_PARAMS=--fast-list --allow-non-empty
4) Save the file if created on the N2 or copy the file into this folder if you created on your pc

Now we need to prepare Termux for action.

1) In your app drawer long press the app (in atv) to show information (this varies on non ATV versions, but you want to be where you can clear cache/permissions)
2) In permissions tab allow Termux to have Storage / Writing permissions
3) Go back to homescreen
4) Open Termux
5) Type "su" no quotes and click the approve prompt to give superuser access

Now this is where i found an issue with the current version of rclone on android. It does not actually have the path set in global environment so it failed to write the config file.

You can try first to see if it works or you can just enter the following which actually got the config file to save for me (adjust the path after the equals sign to your sdcard folder where your created the .rclone folder accordingly (this is how mine appeared in filezilla, however in solid explorer you can get it by going through root in the menu then storage then emulated and then whatever shows next may vary on your rom

Code: Select all

export RCLONE_CONFIG=//storage/emulated/0/.rclone/rclone.conf
Terminal will not show any confirmation if you got this right or wrong so now lets go through standard setup (note this will have to be typed in every time you create a new connection)

1) type rclone config and press enter

The Rclone text wizard will now start here you can add delete profiles however we wish to add so lets continue

2) Enter N for new config
3) Enter the NAME you want it to appear as in your file browser/ apps. In my example i called it Synology and press enter

Now here we will use SFTP as an example, but this is where you choose the protocol or service you want to connect to, so if you wanted webdav you would type that, the list gives you the name to type for the service you want to connect to, so just read and type what is relevant to you.

The wizard will show various different options depending on the connection type however lets proceed with sftp for now

4) Type SFTP and press enter
5) Enter the NAS IP address i.e 192.168.1.10 whatever yours may be and press enter
6) Enter the Username that is permitted to access this (remember you set one up before you started this didn't you) and press enter
7) Set port to whatever you set SFTP Port to on your nas. SFTP is done over SSH port i.e port 22 if left at default, but if you change the port number on your nas enter that instead so if left at default enter 22 and press enter
8) Enter the password for the user you setup on the nas and press enter
9) Repeat the password and press enter
10) On the next question (raw pen question) just press enter to accept default
11) On the next question (default path question) just press enter to accept default
12) On the next question ( pen encrypted question) just type N and press enter.
13) On the next question (when a key file is also set question) just press enter to accept default
14) Enter True for encryption type and press enter
15) On the next question (disable the execution of ssh commands question) just press enter to accept default
16) Type N to avoid advanced editing and press enter
17) Type Y to accept config

As mentioned earlier if you get a message that it failed to save 10 times, then you need to revisit the export path and make sure you have the right path to the .rclone folder you created earlier and check the permissions on this folder (adjust to be less restrictive to test also and rule out permission issues)

However if you did not get an error then we are nearly there

18) Type Q to quit
19) Reboot your device.

If all went well, then when you reboot if you open your file manager you will see a rclone.conf file in your .rclone hidden folder.

However if it went really well you will now notice a folder in your Internal Memory called Cloud if you click on that you should notice a new folder called (whatever you named it in termux step 3 above) i.e in my example its called Synology.

If you click that folder you should now be able to browse and see the remote files as if they were on your device. Apps like Retroarch can see them natively.

However if you cannot see your files, you need to revisit the config and adjust as well as checking the ports/usernames/passwords are correct, you can do this by either repeating the steps above (choose edit instead of new) or if your file browser has a text editor, open the rclone.conf file amend as required and save then reboot to test again.

As mentioned at the beginning there are so many variables between setups and devices that this guide may or very well may not work for you. But i have succesfully connected via SFTP and WEBDAV to my Synology and it connects upon every reboot.

The next step is to tweak the performance flags set in the .global.param file to speed up throughput, they are not required but rclone site explains what settings and variables can be used. The ones i used are just guesses and once i have had more time to play and test performance i will update this accordingly.

Setting up WEBDAV

Webdav would be a preferred connection for certain areas such as Streaming files and retro-gaming. However setting up webdav can be a little more difficult and requires some different parameters

The example below if for connecting to a SYNOLOGY NAS which adds in another layer of complexity. Most Webdav servers work on Port 80 or Port 443, these are the default ports rclone will try and connect to, Synology Boxes however default to 5005 for un-secure and 5006 for secure connections.

Unlike the FTP setup above there is no option to set a port during the new configuration stage, however you can append the port to the end of the URL.

Setup Webdav

Open Termux

Enter

Code: Select all

su

and grant super user rights if not previously granted

Enter

Code: Select all

export RCLONE_CONFIG=//storage/emulated/0/.rclone/rclone.conf
Terminal will not show any confirmation if you got this right or wrong so now lets go through standard setup (note this will have to be typed in every time you create a new connection)

1) type rclone config and press enter

The Rclone text wizard will now start here you can add delete profiles however we wish to add so lets continue

2) Enter N for new config
3) Enter the NAME you want it to appear as in your file browser/ apps. In my example i called it Synology and press enter
4) Type webdav and press enter
5) Enter the NAS IP address
5b) If an external server set as http://my.server.com
5c) If an exteranl server via a secure link set as https://my.server.com
5d) If the server is on an internal network you still need the http statement so http:// or https://

It should be noted that if set the IP as above then it will try and access via port 80 (http) and port 443 (https),if your device or service uses a different port you need to append it as such

5e) http://192.168.1.xx:5005 (non ssl)
5e) https://192.168.1.xx:5006 (ssl)

In this example which is set for synology i have set the port number at the end of the address. 5005 is for non ssl port, for ssl you would use 5006


6) Enter the Username that is permitted to access this (remember you set one up before you started this didn't you) and press enter
7) Enter the password for the user you setup on the nas and press enter
8) Repeat the password and press enter
10) On the next question (bearer token) just press enter to accept default
11) On the next question of advanced editing just type "N" or press enter
17) Type Y to accept config
18) Exit out of termux

Now through trial and error i have got a better configuration for webdav.

This can be copied and pasted into the .global.param file you created earlier in the hidden .rclone folder

Code: Select all

BINDSD=1
CACHEMODE=minimal
BUFFERSIZE=512M
ADD_PARAMS=--fast-list --allow-non-empty --no-checksum --no-check-certificate
It should be noted that you may not require the following flag

Code: Select all

--no-check-certificate
However if one of the following scenarios is relevant to you then you will require it:

[*]If you have a self signed certificate
[*]If you have an imported certificate from an authority, i.e comodo, lets encrypt where a domain name normally points to your nas and where it is set as default certificate

The --no-check-certificate flag basically tells rclone to not check for the SSL certificate and if it finds a differing certificate to just ignore it. Without this flag i could not connect to my NAS as it was stuck on the fact that my certificate name did not match the internal IP as it has a FQDM.


Hopefully you are now able to have your network storage / remote servers /cloud services (google drop box etc) etc attached to your device and survive following reboot.

If not then you will need to do some working out of your own as there are too many variables that could cause issues

Timeline
27th July - Initial Guide
28th July - Amended typo in export command should be double slash
28th July - Amended initial parameters to remove those not relevant

30th July - Amended WEBDAV settings and included different global param tweak settings

Speed Information

I have now tested both SFTP and WEBDAV, my preference is always WEBDAV and this has proved to be the better of the connections. Im sure FTP would probably be fine however points to note:

Retroarch
[*]Via SFTP, slight stuttering and longer load times on PSX roms with SFTP
[*]Via WEBDAV, faster load times and no issues on PSX roms

Secure Vs non Secure

This is down to your personal choice, i am using NON SSL variants for my internal network, this makes sense why encrypt traffic and add an extra overhead, The issues i had in retroarch where could possibly be due to using SFTP over SSH. Using Webdav and the non secure variant has hit that sweet spot for performance required.

However for obvious reasons if you were wanting to add an external provider i.e Google Drive, Sharepoint, S3 for example then the secure port is a no brainer
Last edited by thering1975 on Fri Jul 31, 2020 1:24 am, edited 5 times in total.
These users thanked the author thering1975 for the post (total 2):
odroid (Mon Jul 27, 2020 11:29 am) • mad_ady (Mon Jul 27, 2020 3:38 pm)

User avatar
rooted
Posts: 7875
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 724 times
Been thanked: 222 times
Contact:

Re: [How To] Mount a Nas Drive / Cloud Services Natively to Android

Post by rooted »

Nice guide, rclone is a very cool utility.

@mad_ady Is this what you were looking for?
These users thanked the author rooted for the post:
thering1975 (Mon Jul 27, 2020 5:30 pm)

mad_ady
Posts: 8316
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 573 times
Been thanked: 434 times
Contact:

Re: [How To] Mount a Nas Drive / Cloud Services Natively to Android

Post by mad_ady »

Yes, this is what I was looking for.
I didn't know I could install Magisk on top of voodik's ATV. I will see how to do that first.
I had played a little bit with rclone on my phone, but it seemed to cause slowdowns when using a file explorer that wanted to recursively count how many files I had in each folder and took its time when it reached the Cloud folder. Also I didn't know about CACHEMODE=minimal and found out my rclone had copied over a git snapshot of a kernel I was building on my NAS... Not fun seeing where all the space had gone...

My goal for it is to be able to use MPD on Android and point it to the media that lives on my NAS. Sadly the MPD version I managed to get running only reads media from /sdcard/Music, so I'll need to see if I can symlink it to the Cloud/NAS/Music folder instead.

But, thanks for the tutorial. Hope to manage to go through it at some point (you know, with everybody working from home these days, I do have to work from home when "working from home", and this leaves very little time for ones hobbies)!
These users thanked the author mad_ady for the post:
thering1975 (Mon Jul 27, 2020 5:29 pm)

thering1975
Posts: 50
Joined: Sat Apr 18, 2020 12:39 am
languages_spoken: english
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: [How To] Mount a Nas Drive / Cloud Services Natively to Android

Post by thering1975 »

mad_ady wrote:
Mon Jul 27, 2020 3:34 pm
Yes, this is what I was looking for.
I didn't know I could install Magisk on top of voodik's ATV. I will see how to do that first.
I had played a little bit with rclone on my phone, but it seemed to cause slowdowns when using a file explorer that wanted to recursively count how many files I had in each folder and took its time when it reached the Cloud folder. Also I didn't know about CACHEMODE=minimal and found out my rclone had copied over a git snapshot of a kernel I was building on my NAS... Not fun seeing where all the space had gone...

My goal for it is to be able to use MPD on Android and point it to the media that lives on my NAS. Sadly the MPD version I managed to get running only reads media from /sdcard/Music, so I'll need to see if I can symlink it to the Cloud/NAS/Music folder instead.

But, thanks for the tutorial. Hope to manage to go through it at some point (you know, with everybody working from home these days, I do have to work from home when "working from home", and this leaves very little time for ones hobbies)!
Well hopefully it will work for you, the above bit is easy to be fair once you have done it once it takes like 2 minutes to add a new connection. The part i am working on now is finding the best configuration for speed and throughput. For example testing webdav, small roms for retroarch work perfectly as obviously they are small files, psx roms however can buffer here and there. So going to work out the best settings and switch back to sftp as my main option and tweak from there.

But retorgaming is a unique case, for example under the webdav a 1080p high bitrate hs audio file is playing faultlessly, will test 4k sample next

Oh and installing Magisk was super easy all i do is:

1) Download Magisk from Voodiks thread place in download folder
2) Open up termux or local terminal client and enter "reboot recovery"
3) Android will reboot into recover click Apply Update (or similar term) and navigate to the file you downloaded
4) It will install, once finished back out and reboot to system
5) Job done, Magisk Manager will appear in App Drawer (grey icon one)
6) Open that install whatever modules you want, i use SSH so i have ssh and sftp to my machine and Rclone for now
These users thanked the author thering1975 for the post:
mad_ady (Mon Jul 27, 2020 6:16 pm)

thering1975
Posts: 50
Joined: Sat Apr 18, 2020 12:39 am
languages_spoken: english
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: [How To] Mount a Nas Drive / Cloud Services Natively to Android

Post by thering1975 »

@mad_ady Once you get it set up, you can take a look at the github repo help. You can set individual paramaters for different connections.

So from what i read you could set up one connection which purely maps to music
Then set an additional parameter in the file above which reads

SDBINDPOINT=Music

If i read right, this should then map the Nas Music folder to the SDcard music folder directly, may require trial and error, but from the github page

Code: Select all

The following configuration will disable caching for remote Movies, bind to /sdcard/Movies & add the -fast-list/--allow-non-empty flags to it's mounting command.

   /sdcard/.rclone/.Movies.param

   1| CACHEMODE=off
   2| BINDSD=1
   3| SDBINDPOINT=Movies
   4| ADD_PARAMS=--fast-list --allow-non-empty
   5| 
   
These users thanked the author thering1975 for the post:
mad_ady (Mon Jul 27, 2020 9:22 pm)

mad_ady
Posts: 8316
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 573 times
Been thanked: 434 times
Contact:

Re: [How To] Mount a Nas Drive / Cloud Services Natively to Android

Post by mad_ady »

Sounds great! That's what I want to do!

thering1975
Posts: 50
Joined: Sat Apr 18, 2020 12:39 am
languages_spoken: english
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: [How To] Mount a Nas Drive / Cloud Services Natively to Android

Post by thering1975 »

Testing so far on sftp to Synology Nas from both a N2 and N2+

Loads of work to go for Retrogaming testing various settings and so far as follows

Current Configuration

Code: Select all

BINDSD=1
CACHEMODE=minimal
ADD_PARAMS=--fast-list --allow-non-empty --buffer-size 512M --drive-chunk-size 16M
Increased buffer size and chunk size (careful with chunk size should be a % of your bandwidth)

The increased buffer size affected playback of 4k content.

Pre Buffer increase-

[*]Big Buck Bunny played from Solid Explorer through Kodi - 4k 30 FPS - minor stuttering
[*]Big Buck Bunny played from Solid Explorer through Kodi - 4k 60 FPS - Buffered more than it played

Post Buffer increase-
[*]Big Buck Bunny played from Solid Explorer through Kodi - 4k 30 FPS - Flawless Playback
[*]Big Buck Bunny played from Solid Explorer through Kodi - 4k 60 FPS - Loaded and started fine but obviously 4k 60fps is pushing the N2 anyway, micro stutters but expected

So for 1080p and 4k 24fps material playback in Kodi was fine. VLC takes longer to start but also played back fine

Retroarch

Work to do here on the config but results so far:

[*]Scans for roms takes circa 30% longer than local hosted
[*]Save and load states from Nas are speedy
[*]Roms such as GB,GBA,MG,SG,Lynx,atari,GBC,32X etc all load normally as expected
[*]PSX roms are 90% there, some with ploads of cut scenes can stutter for a second but gameplay is max fps
[*]DreamCast Roms are Not playable (most likely core)

Redreem
Dreamcast Roms stutter at cut scene but gameplay is perfect

One tweak for retroarch and PCSXREARMED is to switch CD loading to Asynchronous, this helped massively.

thering1975
Posts: 50
Joined: Sat Apr 18, 2020 12:39 am
languages_spoken: english
Has thanked: 7 times
Been thanked: 9 times
Contact:

Re: [How To] Mount a Nas Drive / Cloud Services Natively to Android

Post by thering1975 »

Updated initial guide with a more detailed section on Webdav to a Synology NAS

This has solved my retro gaming issues and includes a tweaked .global.param file settings which is providing better performance than over SFTP

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 0 guests