Solved How to transfer files from android to FreeBSD?

I use this sshd, sftp server on android:


And then connect with ssh, scp, sftp or rsync clients from FreeBSD or other system.

It is important to have the server in android, because it is on the client side where you make the connection and, if it is a normal computer, you have on it a normal keyboard and monitor.

You use the phone as Wifi AP (tetering), start the above server, and then start the connection with the PC, on the phone you see what password to use.
 
I did allow file transfer in my phone, but I get a message said can't transfer files at the moment after run jmtpfs in the terminal.
 
I use Total Commander on my phone as my local file manager. My home file server exports as NFS for my FreeBSD boxes and SMB for my wifes Windows box. With those two conditions in place anyway, adding the LAN Plugin for Total Commander allowing my phone to connect to one or more server SMB shares was the most obvious thing for me. Total Commander is a two pane file manager, swipe to slide between panes. It works for me, YMMV :)
 
it's working for me when i start it as root
 

Attachments

  • Screenshot_2023-02-05_23-48-56.png
    Screenshot_2023-02-05_23-48-56.png
    6.6 KB · Views: 92
I compiled android-file-transfer-qt5, and run android-file-transfer as root, I can tarnsfer files between my phone and system now, thanks all.
 
sysutils/fusefs-jmtpfs, over USB cable, the Androids file system mounted on FreeBSD.

Connect android device on FreeBSD machine, as root execute jmtpfs, on android device allow access, mount file system: jmtpfs /mnt -o allow_other, as user browse file system by terminal, file manager, perform file transfer operations.

I've tried to come up with a line for /etc/fstab that would allow to mount with mount /phone (after mkdir /phone). I'm not sure what to put in column 1 (Device) and column 3 (fstype). Is this possible at all?
 
I've tried to come up with a line for /etc/fstab that would allow to mount with mount /phone (after mkdir /phone). I'm not sure what to put in column 1 (Device) and column 3 (fstype). Is this possible at all?
It’s possible, but it requires some effort.

When using /etc/fstab, a tool is called that is named mount_<type> (with device and mountpoint as arguments, as well as any -o options specified), where <type> is the 3rd column in /etc/fstab. The jmtpfs tool does not support this kind of usage, unfortunately, so you have to write a shell script that acts as a wrapper. I suggest mount_mtpfs as the name of the script, so you can use the device type mtpfs in /etc/fstab (3rd column). The script must be located in /sbin or /usr/sbin (unfortunately, /usr/local is not supported).

In the most simple case, the script just contains exec /usr/local/bin/jmtpfs "$2", mounting the first Android MTP device that it finds on the mount point given in the /etc/fstab file (2nd column). The device name (1st column) and options (4th column) are ignored. So, this would be the script mount_mtpfs:
Code:
#!/bin/sh
exec /usr/local/bin/jmtpfs "$2"
and an appropriate entry for /etc/fstab:
Code:
mtpfs   /your/mount/point   mtpfs   rw,noauto   0   0
Beware, this is a very simplistic solution. Most options will be ignored, e.g. ro (for read-only) will be ignored.
Beware #2: This is just off the top of my head, but I haven't tried it myself. I just run jmtpfs when I need it. I also just noticed that the script needs more work because of options passed to it, so you cannot use it directly. The least effort is probably to hardcode the mount point in the script (instead of $2).

Note, if you want to use this for backing up your Android device, I suggest you insert the option -o ro in the jmtpfs call in the script, so it always performs read-only mounts.
You can also improve the script to take the options from the command line (passed from /etc/fstab), this is left as an exercise to the reader.
 
Back
Top