Recently, I have decided to shift entirely from using iPhone to Android, especially after my Xperia Z5 Premium received Nougat update. This is because I have had couple issues with my iPhone lately. Including but not limited to i) connecting iOS 10+ to Linux, ii) Apple decided to use weaker encryption on mobile, iii) VOIP applications treated as phone applications, iv) cannot multi-task such as checking emails while video calling, or splitting screen on iPhone 5s…, v) contacts are not synchronized well with Google contacts. Nevertheless, I do appreciate iOS as it limits applications from controlling your mobile (e.g. apps cannot stop you from taking screenshots while using them).
Android 7.0, Nougat, has many interesting updates. The most important feature to me is the new security features introduced. The new encryption allows seamless updates, file-base encryption, and direct boot! If you have Android Nougat, I strongly recommend you to activate device and SD card encryption by resting your mobile to factory settings and enabling them from Settings -> Lock screen & security -> Encrypt device and Encrypt SD card.
After I have shifted to Android, I tried connecting it to my Linux desktop and it didn’t work! Nooo, not again the iPhone issue! I started searching online for various approaches to connect my Android to Debian, my Linux distro, and all of them either didn’t work or output weird errors. Based on what I understood, most of the libraries don’t handle latest mobiles (such as Xperia Z5) and Android 7 Nougat well, yet. After couple spending couple hours, I have finally found a simple working approach to connect my Android 7 to Linux.
Follow these instructions to connect your Android mobile to Linux:
1) Install the required libraries
To connect Android using MTP connectivity, we need to install libraries that implement and handle MTP protocol on Linux. I found the following libraries sufficient for the job. Install them by executing the following command:
sudo apt-get install mtp-tools jmtpfs
2) Restart your computer
It is recommended to restart your computer once you have installed new libraries. Restart it through the terminal by firing the following command:
3) Connect your mobile through USB and select MTP connectivity
Connect your Android through USB. You will be prompted to use USB as different modes. Select Transfer files, which is equivalent to MTP connectivity.
4) Check if your mobile is detected well
Once you have connected your mobile, you need to check that everything is working smoothly. This step is done once only, and you don’t need to perform it every time you connect your Android. To check the connectivity, run the following command:
The output of this command should look something similar to this:
Unable to open ~/.mtpz-data for reading, MTPZ disabled.
libmtp version: 1.1.8
Listing raw device(s)
Device 0 (VID=0fee and PID=01cb) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
Found 1 device(s):
0fee:01cb @ bus 1, dev 9
Attempting to connect device(s)
Android device detected, assigning default bug flags
[SOME DETAILS OMITED]
If you got such output, your Linux and your Android are connected and can communicate properly
5) Create a directory for mounting your Android
To eliminate any issues with permissions when mounting your Android, create a directory somewhere in your home folder, i.e. don’t mount it under /media/USER/. To create a folder in home directory, run:
6) Mount Android using JMTPfs
Now, the mounting part! All what you need to do, is execute jmtpfs followed by the folder you have created!
jmtpfs ~/SonyData # mount
Now use your faviourate file explorer and navigate to ~/SonyData. Also, you will see an icon underneath mounted devices on your file explorer.
7) Unmount, once you are done
To unmount your Android mobile, do not unplug your mobile without safely unmounting it. To do so, run the following in your terminal:
fusermount -u ~/SonyData # to unmount
BONUS: Assign aliases to facilitate connecting your mobile later
It is annoying to remember the mounting and unmounting commands and execute them every time you connect your mobile. Create an easy-to-remember aliases in ~/.bash_aliases. Here are my aliases:
alias android-mount="jmtpfs ~/SonyData"
alias android-unmount="fusermount -u ~/SonyData"