Ubuntu – How to mount Android external storage over WiFi instead of USB

androidcommand linemountusbwireless

There is this question:

which has many answers. In the body of the question the OP asks how to mount the android file system over WiFi which is what I want to do. Yet not a single answer contains the mount command.

How do I mount my phones external storage over WiFi so I can use the ls command and get the results specifically with last access time for each file?

Instead of "pretty" GUI pictures I'd prefer CLI with the command mount to a partition like /phone. Then a command like ls /phone actually works.

Copying and pasting files over GUI isn't needed. Just the simple ls command. The easiest method is the goal.

Reply to comments

There are a number of FTP client tools you can use in Ubuntu. However they come with their own set of shell/bash-like commands running inside an interpreter. I'd like to use regular bash/shell commands and call the script from /etc/cron.daily.

Every morning a Cron job will automatically mount the the phone. Then poll last access time for thousands of files. Then update bash array with last four access times and umount the phone.

There should be no user input other than resuming the laptop every morning which is already done for the other jobs in /etc/cron.daily anyway.

Best Answer

Meet curlftpfs (package curlftpfs) - “mount a ftp host as a local directory”. First set up your Android device as an ftp server, e.g. using one of the apps explained in the question you linked, then on the host do:

curlftpfs server:port/directory /mountpoint

To unmount use:

fusermount -u /mountpoint

An example /etc/fstab line looks like this:

curlftpfs#server:port/directory /mountpoint fuse auto,user,uid=1000,allow_other,_netdev 0 0

Unfortunately since 2015 there’s a bug in libcurl3-gnutls which makes curlftpfs very slow on file operations, see these resources:

Sources/Further reading