6

I want to mount a network shared folder (Ex: \10.0.0.240\Folder) into an Android internal folder (Ex: /mnt/sdcard/MountedFolder), just like the MountManager App does.

My question it's: How can i do it, or how can i at least enter to the network folder and see the files on it directly from my app?

I'm working on a Rooted device, so it doesn't matter about permissions.

Ivan Verges
  • 595
  • 3
  • 10
  • 25

3 Answers3

2

This is how you do it in Kit Kat from the command line:

mount -o username=<user>,password=<pwd>,file_mode=0777,dir_mode=0777 -t cifs //<NAS IP Addr>/<share name> <mount point dir>

E.g.

mount -o username=guest,password=guest,file_mode=0777,dir_mode=0777 -t cifs //192.168.1.254/public /storage/nas/public

Notes:

  • Make sure the directory /storage/nas/public exists and you have set appropriate permissions.
  • If you do not use file_mode and dir_mode you will only be able to access the share from root.
Bryon
  • 939
  • 13
  • 25
0

Well, i found a way to mount a network shared folder into my android device using Xamarin (C#), just as Mount Manager and CIFS manager does;

You need root permissions to make it work because it's a unix command and need especial permisions.

The code it's as simple as the next:

Java.Lang.Runtime proc = Java.Lang.Runtime.GetRuntime();

proc.Exec(new String[] {"su", "-c", "mount -t cifs -o username=USER, " +
    "password=YOURPASS //xxx.xxx.xxx.xxx/SharedFolder /mnt/sdcard/MountPoint"});

In the code above, replace USER with the user name and YOURPASS with the password to access the network folder.

Replace xxx.xxx.xxx.xxx with the server IP.

Replace MountPoint with the name of the folder where you want to mount the network folder, you can also replace sdcard with another directory and even the /mnt with another one, but it's most common to mount into the sdcard, this way any app that scans your sd will see the network files as they're on the sd.

JG in SD
  • 5,427
  • 3
  • 34
  • 46
Ivan Verges
  • 595
  • 3
  • 10
  • 25
0

Since you are Rooted

Use rclone port for android from Magisk modules.

Rclone supports almost all cloud storages including as well standard transfer protocols.

After installing the module from the Magisk app. Create a config file following the instructions on the following command:

rclone config

After you can use rclone mount like:

rclone mount remote_name_from_config:remote/path/to/files /path/to/local/mount --daemon

--daemon option is to let it run in background

imbr
  • 6,226
  • 4
  • 53
  • 65