9

How can I bind my Android file system to my Linux machine, and modify it? When I plug in my Android device, it seems to use one USB interface but I couldn't find whre the mount point is. I checked /mnt but there is nothing.

5
  • shot answer adb can allow you to interact with your phone if you have the correct driver. but I wouldn't if I were you because you seems pretty rocky whit that and you rather search a bit before trying to do such a thing.
    – Kiwy
    Jan 31, 2014 at 14:54
  • I tried adb and getting permission deny
    – user55778
    Jan 31, 2014 at 14:57
  • What Linux distribution are you using? @Kiwy You don't need any special driver, it's just generic USB + adb or USB mass storage. Jan 31, 2014 at 23:39
  • ubuntu lite which is work on the my usb.
    – user55778
    Feb 1, 2014 at 7:06
  • man simple-mtpfs Jan 21, 2022 at 13:21

5 Answers 5

1

Some phones have icky USB storage interfaces, which don't work on Linux reliably (look here for example), others (e.g. my Samsung Galaxy with Android 4.3) seem not to offer USB access to their innards at all (nothing in the logs when plugging it in). Some need to be set up specially (allow USB in their configuration) to mount them.

1

If you have a newer smartphone that uses MTP/PTP protocol, I'm afraid you can't mount it to the filesystem and access it as a regular drive device with just a mount command - similar discussion here.

To make this work, you need some kind of virtual file system tool. I believe gvfs should do the trick. To make this mounting automatic, a daemon has to be running in the background. Search for gvfs, gvfs-mtp, gvfs-fuse, gvfs-deamons, etc. in your package manager.

References:

https://en.wikipedia.org/wiki/Virtual_file_system

https://wiki.archlinux.org/title/Media_Transfer_Protocol

https://superuser.com/questions/1157661/how-to-mount-an-android-smartphone-as-a-drive-in-windows

Accessing MTP mounted device in terminal

https://wiki.gnome.org/Projects/gvfs

2
  • It is unclear from your description how to used gvfs or alternatives.
    – Ole Tange
    Jan 24, 2022 at 19:43
  • It depends on distribution and system configuration. Try to search for gvfs manual in your distribution's wiki.
    – BlueManCZ
    Jan 25, 2022 at 15:08
1

MTPFS is likely what you want, it's FUSE based, but there is no reason that that wouldn't work (outside of device-specific issues)

After installing it :

Add yourself to plugdev group (to have the needed permissions)

gpasswd -a <USER_NAME> plugdev

Then, just run

mtpfs <empty folder>

To unmount :

fusermount -u <folder>
1
  • I could not find mtpfs for Ubuntu, but I found jmtpfs. When running that as normal user or as root I get: No mtp devices found. My phone "Select USB configuration" > "Media Transfer Protocol (MTP)" and plugged in USB.
    – Ole Tange
    Jan 24, 2022 at 20:03
0

I wouldn't expect to find a reliable solution that would work with USB cable, the general trend in the industry is to go fully wireless.

The method I used for a couple of years and that works with various Android devices and that works well and that doesn't require rooted device is to use SimpleSSHD on your Android device and sshfs on your desktop Linux machine.

Install and setup SimpleSSHD on your Android device and use sshfs on desktop Linux machine like that:

sshfs <PHONE_IP_ADDRESS>:<PATH_ON_ANDROID> <LOCAL_DIR>

For example, this is the command I use to mount Gallery from my Galaxy S8 phone on my Slackware system:

$ mkdir gallery
$ sshfs phone:/sdcard/DCIM/Camera gallery

phone is an alias I defined in ~/.ssh/config:

Host phone
     User shell
     Hostname Galaxy-S8
     Port 2222

Of course it requires your Android device and your Linux machine to be in the same network.

Unmount local dir without root:

fusermount -u gallery

Last time I checked SimpleSSHD was a re-packaged Dropebar binary for ARM.

7
  • sshfs 192.168.1.230:/ phone/; ls phone/ gives ls: reading directory 'phone/': Permission denied.
    – Ole Tange
    Jan 24, 2022 at 19:38
  • You don't have a rooted device, you won't be able to access / like that. Rooting an Android device is a separate issue. Jan 24, 2022 at 19:45
  • I do not want to root my device, but I want access to all the files I have access to. In other words: I want to be able to do a find dir and see all the files I have access to in dir.
    – Ole Tange
    Jan 24, 2022 at 19:59
  • That's possible only if you have a rooted device, normally you don't have access to / but to SD Card and several other directories. Jan 24, 2022 at 20:05
  • You misunderstand me. The solution I am looking for should know this and give access to the dirs I have access to. I am not looking for a solution where you need to root your phone, but simply one that will give me the same access as any filemanager app on the phone already give.
    – Ole Tange
    Jan 24, 2022 at 20:08
0

ADBFS-rootless is another option, that works better for me than the other alternatives in this thread, when proper SSH is not setup to also work via USB-NET/JumpHost.

It's trivial to compile, the usual small dance:

git clone git://github.com/spion/adbfs-rootless.git
cd adbfs-rootless
make

maybe install libfuse-dev android-tools-adb build-essential git pkg-config before.

Then mount your local usb-connected Android device with ./adbfs ~/droid.

It's originally "configured" to only connect to local ADB devices via source, but can be trivially patched to connect to remotely usb-connected Android devices, using the remote ADBd on the USB-Host as "Jumphost".

You can also use it with USB-IP to connect to Android-devices hooked up to the USB of some WIFI-APs/Routers that way.

If you need to connect to ancient versions of Android, you may need to get statically compiled adb versions for different API-levels, and just make several adbfs-binaries with hardcoded paths to specific adb-versions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .