Howto: Transfer files between FreeBSD and Android devices

I got my first Android phones a few weeks ago. In the last few days, I tried to transfer files directly between my phone to my computer. I first tried sysutils/mtpfs without success. Then I stumbled upon devel/android-tools-adb. Using this port, I was able to transfer files between my phone to my computer. Here are the steps I took:

Step 1: Install devel/android-tools-adb.

Step 2: Connect your Android device to your computer using USB cable. Make sure your device is detected by FreeBSD. You should see something like the following in /var/log/messages.

Code:
kernel: ugen0.5: <LG Electronics Inc.> at usbus0
devd: Executing 'logger Unknown USB device: vendor 0x1004 product 0x61f9 bus uhub3'
root: Unknown USB device: vendor 0x1004 product 0x61f9 bus uhub3
devd: Executing 'logger Unknown USB device: vendor 0x1004 product 0x61f9 bus uhub3'
This is my phone.
Code:
kernel: ugen0.5: <BN> at usbus0
kernel: umass0: <BN NOOK SimpleTouch, class 0/0, rev 2.00/2.16, addr 5> on usbus0
kernel: umass0:  SCSI over Bulk-Only; quirks = 0x0000
kernel: umass0:8:0:-1: Attached to scbus8
devd: Executing 'logger Unknown USB device: vendor 0x2080 product 0x0003 bus uhub3'
kernel: da6 at umass-sim0 bus 0 scbus8 target 0 lun 0
kernel: da6: <B&N NOOK SimpleTouch 0100> Removable Direct Access SCSI-2 device
kernel: da6: 40.000MB/s transfers
kernel: da6: 239MB (491488 512 byte sectors: 64H 32S/T 239C)
kernel: da6: quirks=0x2<NO_6_BYTE>
root: Unknown USB device: vendor 0x2080 product 0x0003 bus uhub3
aaa kernel: da7 at umass-sim0 bus 0 scbus8 target 0 lun 1
aaa kernel: da7: <B&N NOOK SimpleTouch 0100> Removable Direct Access SCSI-2 device
aaa kernel: da7: 40.000MB/s transfers
aaa kernel: da7: 3779MB (7741311 512 byte sectors: 255H 63S/T 481C)
aaa kernel: da7: quirks=0x2<NO_6_BYTE>
This is my Nook Simple Touch.

For my phone I had to enable USB debugging using the procedures outlined at developer.android.com:
To access these settings, open the Developer options in the system Settings. On Android 4.2 and higher, the Developer options screen is hidden by default. To make it visible, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options at the bottom.
Step 3: Issue the command $ adb devices. Please note that you do not need to be root to issue this command. I am not sure what effect this may have though. This command may take a few minutes to complete. If successful, you will see something like:
Code:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
your_device_number  device
Step 4: Now you have connected your device with FreeBSD. You can transfer files between them using adb pull and adb push. These commands act as cp -r.

You could also get a shell in your device using adb shell. There are even commands to backup and restore data of your devices. A basic description of adb options is provided by adb help. You can see the full description of the adb command at developer.android.com.
 
Step 3: Issue the command $ adb devices. Please note that you do not need to be root to issue this command.
I would note, though, that starting the server (# adb start-server) does require root access. If you run it as a normal user, the phone will never show the dialog with the RSA key that allows the computer to access it, and adb will fail silently (not showing any device with $ adb devices).
 
To transfer data from Android to PC, such android file transfer is very helpful. After connect Android phone with PC, we can directly transfer data to PC.
 
If you have wireless its even easier by installing an app on your phone that can run a web server on the phone temporarily. The app provides an IP and port which you access from a browser on the BSD desktop, provided you have one of course. After you are done transferring you shut down the phone app which kills the web server. Many Android phone file managers have this functionality. Just another way to do this someone may find useful.
 
IIRC Android synchronizes files with your Google account. Just use the browser to download files to your computer. In the case you missed Android is proprietary OS written to collect as many private information about you as possible so I have no idea what is the advantage in mounting mtpfs files system to your supposedly more secure FreeBSD desktop. Google, NSA and God knows who already have those files on their servers. It bothers me as a private citizen but since I really have nothing to hide if somebody in NSA finds the pictures of my kids of national security interests so be it. Thanks God my family photos are the biggest security problem.
 
I had noticed the following ports were added to FreeBSD:

devel/android-tools-adb-devel
devel/android-tools-fastboot
devel/android-tools-adb
devel/android-tools-simpleperf
devel/android-tools-fastboot-devel
sysutils/android-file-transfer-qt5
sysutils/android-file-transfer
sysutils/android-file-transfer-qt4

I had not tested any of them. But this means that now we can transfer files between Android to PC with the MTP protocol. And there is no need to enable USB debugging.
Also, with fastboot ported to FreeBSD, it is now possible to update Android without using Windows or Linux.
 
These days, I just use simple-mtpfs. (Not on FreeBSD as I type, so I forget the exact package name, might have fuse in it.)
Code:
kldload fuse
Plug in your phone, and make sure it's open--that is, not at the password protected screen, but open as if you're using it.

Code:
simple-mtpfs /mnt
And you should be able to see it under /mnt
If not, running simple-mtpfs -l should find it. (That's a lower case L as in list).



This works for a Barnes and Noble Nook as well, if anyone cares.
 
I've had luck with kdeconnect.

On the FreeBSD box
/usr/ports/deskutils/kdeconnect # make install
===> Installing for kdeconnect-kde-0.7.2_4
===> Checking if kdeconnect-kde already installed
===> Registering installation for kdeconnect-kde-0.7.2_4
Installing kdeconnect-kde-0.7.2_4...

Under System Settings - click on kdeconnect.

On the Android install:
# https://play.google.com/store/apps/details?id=org.kde.kdeconnect_tp

Start the application on both, and Pair them, and then they can send files either direction.

For me, right clicking on files in dolphin has a context menu item that says - send to phone with kdeconnect. - shows up in my downloads dir on the phone.

Similar action from Android kdeconnect/ file manager and the file shows up in my FreeBSD ~/Download folder.
 
I use net/syncthing to sync all of my computers and mobile devices.

Its similar to BitTorrent sync but its open source.
That's a good option, you can also use www/owncloud and do the same thing. Either way is probably quite a bit more efficient than anything other than a direct USB connection.

But, either way is nice because you can easily sync between more than just two places, so it makes backups a bit more convenient.
 
For those having problems with ADB to transfer files (device not detected), this is how I managed to get my Pixel 2 detected:

- Remove all saved fingerprint keys from developer mode. There's a bug with adb <--> pixel/nexus where once you saved the key, it will never prompt you again (which is fine) but will prevent the device from being recognized. So never save the key, always press accept manually on the device every time you connect.

- Run ADB as root. I know, it makes no sense, but it works.
sudo adb kill-server ; sudo adb devices

With the combination of those two, it works perfectly and no need for pesky third party software to transfer files.
 
Ssh is what I use to transfer files betwen Unixoid systems, when I can connect them with tcp/ip. Another problem is without it.

It is enough to have sshd in one and scp in the other computer for transfering in both directions.

Of course, to have sshd in android is better: then he uses scp with the comfortable keyboard in FreeBSD.

In FreeBSD is sshd and scp. He must search one of both for android.
 
Back
Top