[General Questions and Answers] tuxstudio:
As a new Android user, it take me hours, if not days, to understand some very basic Android concepts. So here we are:

Welcome to the Android on GNU/Linux for complete Android dummies

Introduction

The first concept to understand is that Android, even if it is based on a Linux kernel, is not GNU/Linux, it is Android. That imply some huge differences, the first ones being the file hierarchy and what you can do or not do with that file hierarchy. :cyclops: :crying: :cyclops:

To illustrate that difference, on GNU/Linux, you can copy, move, modify or delete any file, the only condition for that is to have the corresponding access rights. As root, you can do whatever you want on the whole file hierarchy.. On Android, you cannot do that, because the device comes with built-in protections that can save your device if you make a wrong manipulation, but get in your way when you want to make a backup or restore it..

To make things worst on GNU/Linux, even if Android is reasonably well supported, the actual Android support of your installation will depend on your distribution, your WM/Desktop and what software is actually installed.

My distribution is Gentoo, my desktop FVWM-Crystal. That imply I will use generic solutions that should work in any combination of distribution/desktop. The way to install the software will differ, the main difference being that Gentoo use 'emerge' to install the software, when Debian use 'apt' and the rpm based distributions use 'rpm' (or Yast in Suse, etc.).

Note: The command that must be issued as root will be prefixed by '$ ', the command that must be issued as your normal user will be prefixed with '# '.

Android

The most important thing to understand is:

To make a full backup of an Android device, it must be rooted or have a Recovery mode with backup

That imply you must first unlock your phone and install a Recovery.

To make a full backup of an Android device, it must be rooted or have a Recovery mode with backup

That imply you must first unlock your phone and install a Recovery.

To make a full backup of an Android device, it must be rooted or have a Recovery mode with backup

That imply you must first unlock your phone and install a Recovery.

To make a full backup of an Android device, it must be rooted or have a Recovery mode with backup

That imply you must first unlock your phone and install a Recovery.

To make a full backup of an Android device, it must be rooted or have a Recovery mode with backup

That imply you must first unlock your phone and install a Recovery.

To be able to root your device, you must have a Recovery, which imply the device must be first unlocked.

As long your device is not unlocked and don't have a Recovery, what you will be able to backup is device dependent. It can vary from nothing to not much.

When you understand that, you can begun to work in an efficient manner.

MTP

Most recent Android devices use MTP to communicate via the USB bus. MTP mean Media Transport Protocol. What a given device will provide via MTP is device dependent. It will also vary if it is locked or not, and if it is rooted or not.

Android on GNU/Linux

It is 3 ways to communicate via MTP. The first one is using mtpfs, the second one via rsync, the third one via adb.

mtpfs

We will not use plain mtpfs, because it give unreliable results. Instead, it is several other tools that have a much better MTP support, and we will use them.

On Gentoo, it is a global USE flag 'mtp' that will enable MTP support in all programs that have optional MTP support. It is a good thing to add it in /etc/portage/make.conf and update your system as usual before continuing.

Also, for mtpfs to work, as with other pluggable devices, we need to be into the plugdev group:

To check it:

# groups
wheel audio cdrom video games usb users portage android vboxusers roccat plugdev dom

If you are not into the plugdev group:

$ gpasswd -a YOUR_USER plugdev

You can now logout and login.

KDE

kio-mtp is a slave for KDE's KIO framework. After installing it, your MTP devices appear e.g. in Dolphin. You may have to logout and login.

Gnome

I don't use Gnome at all (no systemd, *kit, udisks and the like here, which imply a Gnome free system :cool:). See XFCE as Gnome use gvfs, it should work with Nautilus too.

XFCE

PcManFM support MTP via gvfs. If it doesn't work, check your distribution documentation. On Gentoo, to have mtp as global USE flag will add MTP support in gvfs. Alternatively, you can add it for gnome-base/gvfs in /etc/portage/package.use. This should work for Thunar too.

On Debian, it is a package called gvfs-mtp.

gMTP

gMTP is a simple MTP client for Solaris and Linux based on GTK+.

After its installation, launch it, click on connect. A few seconds later, you will get the file hierarchy of your device. You can start to manipulate the files. It support features like Album, Artwork and play lists. The actual support of a given feature can depend on your device and on the libmtp version.

Media players

Many media players have built-in or optional MTP support. Those players include Amarok, Audacious, Rhythmbox and others. MTP support on these players can vary, as example with Audacious it depend on plain mtpfs and is completely buggy at that time of writing (April 2014). On the other hand, if you use another MTP file system implementation like gphotofs, simple-mtpfs or go-mtpfs, you can use any GNU/Linux software with your MTP devices.

gphotofs

gphotofs is a FUSE file system for interfacing with digital cameras using gphoto2. Most modern mobile phones are cameras at the same time, and gphotofs can be a good alternative to simple-mtpfs or go-mtpfs. gphotofs is used among other by professional cameras and is therefore very well tested and reliable.

You can also install software like gtkam, and your MTP device will appear automatically into them. That can be very useful if you take a lot of pictures with your phone.

After installation, to mount the device:

# mkdir ~/AndroidDevice
# gphotofs ~/AndroidDevice -o allow_other

To unmount the device:

# fusermount -u ~/AndroidDevice

I really prefer to manually mount the device. When done, you can use any file manager to browse its files, and any graphic or media software as well. Please be aware that, due to limitation with the MTP protocol (it can only deal with complete files), it is better to copy your files locally and to work on these copies.

simple-mtpfs

It work the same than gphotofs.

After installation, to mount the device:

# mkdir ~/AndroidDevice
# simple-mtpfs ~/AndroidDevice

To unmount the device:

# fusermount -u ~/AndroidDevice

go-mtpfs

Another MTP FUSE implementation.

On Gentoo, we need to unmask 2 packages in /etc/portage/package.keywords:

dev-libs/go-fuse **
sys-fs/go-mtpfs **

That will install these 2 packages directly from their source code repositories:

$ emerge --ask go-mtpfs

As usual, to mount the device:

# mkdir ~/AndroidDevice
# go-mtpfs ~/AndroidDevice &

To unmount the device:

# fusermount -u ~/AndroidDevice

rsync

rsync is a software mainly used to make professional backups and restores, or to synchronize websites. The main advantage of rsync is that it is possible with it to automatize the process of backup and restoration.

To use it, you need to install rsync.

$ emerge --ask rsync

In /etc/rsyncd.conf:

# /etc/rsyncd.conf

# Minimal configuration file for rsync daemon
# See rsync(1) and rsyncd.conf(5) man pages for help

# This line is required by the /etc/init.d/rsyncd script
pid file = /var/run/rsyncd.pid
use chroot = yes
read only = yes

# Simple example for enabling your own local rsync server
#[gentoo-portage]
#	path = /usr/portage
#	comment = Gentoo Portage tree
#	exclude = /distfiles /packages
[backup]
path = /home/dom/rsync
list = yes
comment = personnal backup
hosts allow = 192.168.178.*

The exact content of that file may be dependent on your distribution. You also have to adapt the variables 'path' and 'host allow' to your actual configuration. rsync will not use the USB but your WAN network (typically the wi-fi). In that example, the backup will be find in /home/dom/rsync and all the devices on your local home network will be allowed to access it via rsync. For testing purpose, you can comment the hosts allow line, this will allow any host.

When done:

$ /etc/init.d/sshd start

We also need to install rsync backup for Android by Michal Kowalczuk in the phone.

TODO: continue the rsync setup to the end and put some examples.

adb.

ADB mean mean Android Debug Bridge, and it is a part of the Android Software Development Kit (SDK). We will need it anyway to flash the Android devices.

To install it on Gentoo:

$ emerge --ask android-sdk-update-manager

This will install just an infrastructure. To actually install, manage and update the Android SDK, just run:

$ android

.

As emerge modify the PATH environmental variable, that for the Android SDK to work well, the best thing to do at that point is to reboot your computer. It doesn't append often on GNU/Linux, but that time it is best to do so.

On other distribution, if it doesn't provide a package to install it, you have to download the SDK from Get the Android SDK. It is several threads on the forum that deal with that:

[GUIDE/Linux] Install Android SDK the "Linux way"

[APP] Linux-on-Android project (Complete Linux Installer) (more for developers this one)

Now, we are ready to play with our phone.:good:

Operations on files

To be able to play with the files in your phone, you don't need to install all the above packages. The one that is really needed is adb. After that, all depend of what you want to do and what kind of integration you want into your GNU/Linux system.

Anyway, it is cool to be able to play with the phone with any file manager. This is why I would recommend to also install one of gphotofs, simple-mtpfs or go-mtpfs. If you also have a MTP camera, go for gphotofs, you will need it anyway. From my short experience, simple console based solution like gphotofs are more reliable than GUI solution (with the notable exception of gMTP and gphoto2 GUI like gtkam), and after mounting they allow the use of any file manager, player, etc.

Where we are now, what files you will be able to see and to operate on will depend on your device. We are not even unlocked.

If you still not believe me, read that: Solution Available for 4.x Devices: This solution will not back up and restore contact, SMS or calendar information :D

With my HTC One, I can copy the content of the whole sdcard. Most interesting are the Download, Movies, Music and DCIM folders.

It is just to plug the phone on the USB, mount it as explained above, and use any file manager to copy the files. We can also copy new files into the phone.

This must be enough to get you started. From here, you may want to continue with something like	[Tutorial] Root, Unlock, Recovery and flashing a Custom ROM . Choose the one that correspond to your device.

If you want to start developing for Android, you may be interested by [GUIDE][WIN/LINUX] A COMPLETE ANDROID DEVELOPMENT GUIDE FOR NEWBIES-SArnab©®.