1

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.

  • Maybe a CLI FTP client, like ncftp, would suffice. – ajgringo619 Oct 5 at 3:36
  • @ajgringo619 That would probably work except 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. I will update the question with this. – WinEunuuchs2Unix Oct 6 at 15:14
  • 1
    @dessert Semantically that is correct. cron does roll of the tongue easier than anacron :) – WinEunuuchs2Unix Oct 6 at 15:50
1

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

  • +1 for answer but I was reading last night that curl has had some nasty bug since Ubuntu 13.10 with long delays in simple operations like ls: bugs.launchpad.net/ubuntu/+source/curlftpfs/+bug/1267749 – WinEunuuchs2Unix Oct 6 at 15:09
  • @WinEunuuchs2Unix Wow, and if even the Arch Linux wiki just mentions it there seems to be no good workaround, not to mention a fix in a newer version – I updated the answer with this information, seems like there’s nothing we can do about it. :I – dessert Oct 6 at 15:42
  • Yes it's amazing a 6 year old bug has been left unfixed for so long. More amazing curl is the number 1 answer in so many posts and yet only 17 people are subscribed to the bug. I just don't want to be number 18 :) – WinEunuuchs2Unix Oct 6 at 15:44
  • @WinEunuuchs2Unix Be 19! – dessert Oct 6 at 15:45
  • If this doesn't work, maybe SSHFS will: miskatonic.org/2019/07/05/sshfs-phone – ajgringo619 Oct 7 at 16:05
0

First I tried two of the most popular Android apps for sharing files over WiFi FTP server and WiFi FTP Server:

Both worked great with Nautilus. Except neither one relayed "Last Access Date" to Nautilus like my projected needed. Both showed "Unknown" instead of a valid date.

As mentioned in other answer curlftpfs doesn't work so I tried:

sudo apt-get install sshfs

However neither of the Android WiFi file sharing apps would let me signon. An email to tech support confirmed they don't support Secure Shell, only FTP which is notoriously insecure.

No matter which app you use you need to create a directory to mount the remote folder in. I used:

mkdir /mnt/phonesudo
chown rick:rick /mnt/phone

"rick" being the User ID.

You will want to sign onto your router and make the IP address (in my case 192.168.0.11) static so it doesn't change each time your phone connects to your router. Here is a link to give you an idea but, yours will no doubt be different:

Since FTP Servers on Android don't support SSH the next step try SimpleSSH as recommended here:

-  https://www.techrepublic.com/article/how-to-install-an-ssh-server-on-your-android-phone/

However SimpleSSH doesn't seem recommended in Google Play Store that well? Use this instead with very high ratings SSH/SFTP Server - Terminal from Banana Studio: - https://play.google.com/store/apps/details?id=net.xnano.android.sshserver

During testing and crashes you'll need to unmount your drive:

$fusermount -u /mnt/phone

After installing SSH/SFTP Server - Terminal use this command:

$ echo rick | sshfs -o password_stdin -p 2222 rick@192.168.0.11:/ /mnt/phone

$ cd "/mnt/phone/Music/Uriah Heep/The Magician's Birthday"

rick@alien:/mnt/phone/Music/Uriah Heep/The Magician's Birthday$ ll
total 79000
-rw-rw-rw- 1 root root  8204186 Mar 10  2016 01 Sunrise.m4a
-rw-rw-rw- 1 root root  5375331 Mar 10  2016 02 Spider Woman.m4a
-rw-rw-rw- 1 root root  7599684 Mar 10  2016 03 Blind Eye.m4a
-rw-rw-rw- 1 root root 10355301 Mar 10  2016 04 Echoes In The Dark.m4a
-rw-rw-rw- 1 root root  8087257 Mar 10  2016 05 Rain.m4a
-rw-rw-rw- 1 root root  9605474 Mar 10  2016 06 Sweet Lorraine.m4a
-rw-rw-rw- 1 root root  9141838 Mar 10  2016 07 Tales.m4a
-rw-rw-rw- 1 root root 22511187 Mar 10  2016 08 The Magician's Birthday.m4a

$ stat "07 Tales.m4a"
  File: '07 Tales.m4a'
  Size: 9141838     Blocks: 17856      IO Block: 4096   regular file
Device: 31h/49d Inode: 11          Links: 1
Access: (0666/-rw-rw-rw-)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-03-10 17:22:24.000000000 -0700
Modify: 2016-03-10 17:22:24.000000000 -0700
Change: 2016-03-10 17:22:24.000000000 -0700
 Birth: -

Voila! I can now see the Last Access Date like my project needs. Unfortunately I discover Android has the biggest security hole in the history of Mankind. Although based on the Linux Kernel Google decided to disable the date a file was opened and read.

I welcome all comments / questions about this answer

  • atime is disabled on Android to elongate NAND life by reducing unnecessary E/P cycles. atime is considered an overkill even on HDDs particularly in server environment, that's why relatime had to be introduced. Btw you can change default mount option by rooting Android. – Irfan Latif Oct 12 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.