Technology, Ubuntu, Ubuntu Touch

Log notes from my MTP android ubuntu learning day

Before you read this. Big disclaimer. This post is written in super crappy style and is nothing more than my personal notes as I tried to figure out MTP. The only reason I’m even putting this post online is because a few of the things I learned below seem like they will be relevant for future ubuntu touch / android porting things. Even skimming over the process I went through seems useful. However, if you are looking for a good tutorial about how to actually do something with MTP / android / ubuntu, this is not that. Hopefully it will provide some value to someone though.

With that out of the way, here comes the crap:

I went down a long road installing ‘MTP://’ mount thing with sudo apt install mtp-tools (very few tutorials on this one) but after it was all said and done, I don’t think it was required because it seemed that all the entries for the ‘udev/rules.d’ files were already complete.

I had assumed you need to plug in the device and clone the internal hard drive (EMMC) via USB, but after some chats with some software communities it seems that ‘it doesn’t work like that’ and the situation is as follows (feel free to comment below otherwise to help me and other readers):

  • Everything nowadays is related to the SD card
  • You have to clone the SD card
  • You have to do forensics / file carving on the cloned drive image

I still feel there has to be a way to carve stuff from the EMMC via MTP, but that perhaps is for another tutorial blog. If you want to look into this, I will provide my learning here, but if you have an Android device with the userdata on the SD card (this is probably the case), then skip on to the following section:

  • How to ‘mount’ an Android device? With MTP
  • What is MTP? It’s this
  • If you are on ubuntu and try lsusb and can see something like this, you are probably already set up well with MTP:
    “Samsung Electronics Co., Ltd Galaxy (MTP)”

Un-mounting android.
un-plugging android.
lsusb
good. I now get “Samsung Electronics Co., Ltd Galaxy (MTP)”

Now to figure out how to find that drive… how does one mount via mtp-tools?
It seems like most stuff is from circa 2014 which is possibly old and scary at this point.
man mtp-tools

nice. tools… manly tools.

wow. bad tool page. looks like MTP tools don’t really ‘mount’ the drive as a drive but just help you communicate with the drive. Not what we’re trying to do here. Jumping up a level.

This guy seems to have figured it out in this video I watched it, felt scared, then read the following code in his notes and this seemed to make the fear go away. Now, we already have mtp-tools installed from above so I’m going to assume that we don’t need to do all of it however, commments on YT from a week ago show ‘thanks man, it worked’ so… yeah. Maybe I’ll just follow it to a tee:

sudo apt-get install libmtp-common mtp-tools libmtp-dev libmtp-runtime libmtp9

sudo apt-get dist-upgrade

sudo nano /etc/fuse.conf

lsusb

sudo nano /lib/udev/rules.d/69-mtp.rules

# Device
ATTR{idVendor}=="XXXX", ATTR{idProduct}=="YYYY", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

sudo nano /etc/udev/rules.d/51-android.rules

ATTR{idVendor}==”XXXX”, ATTR{idProduct}==”YYYY”, MODE=”0666″

sudo service udev restart

sudo reboot

I’m going to walk through these commands one at a time and freshen them up if they need freshining.

sudo apt install libmtp-common <– not needed. shows current
sudo apt install libmtp-dev <– yes, required, not currently installed
sudo apt install libmtp-runtime <– no, not required, showing current
sudo apt install libmtp9 <– no, not required, shows current.

Therefore, the first line could be:

sudo apt install libmtp-dev

I’m a little concerned about running sudo apt dist-upgrade because I think that upgrades your entire current distro from, say 18.04 to 18.10… that seems a bit intense so I’m going to try to skip that one. Instead I did:

sudo apt update and sudo apt upgrade

Since we already have mtp-tools installed and we know that lsusb is showing the right stuff “Bus 002 Device 036: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP)” i think we can move on to adding the rules

blast. it looks like this one rule location might be out of date sudo nano /etc/udev/rules.d/51-android.rules

cd /etc/udev/rules.d/ to search for it…

not there… maybe needs reboot. Rebooting….

sudo nano /etc/fuse.conf
remove comment (#) ‘user_allow_other’
control x to save changes

sudo nano /lib/udev/rules.d/69-libmtp.rules <– note, this is different from tutorial, couldn’t find his file name and assumed this is updated name
1m15s video is useful to watch as he pastes

connect phone
do an lsusb in one terminal
open new terminal window so you can see both together

take this, and update the XXXX to your device things as listed in lsusb in the other window

# Device
ATTR{idVendor}=="XXXX", ATTR{idProduct}=="YYYY", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

mine will become, for example AS DEMONSTRACTED at 1m44s in video with blue and red arrows (great visual, by the way!)
idVendor is the first 4 characters before the colon
idProduct are the second 4 characters after the colon.

# SAMSUNG GALAXY 7
ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

I like to do stuff in text editors and make sure it’s good before pasting into terminals but up to you.

Oh CRAZY. it waslready in this sudo nano /lib/udev/rules.d/69-libmtp.rules

now what… hmm

well I guess we can say that was ‘step 1 to make sure that your device is recognized by MTP’. Now that is good we must do next stuff

sudo nano /etc/udev/rules.d/51-android.rules

not there. but foudn it here:

sudo /lib/udev/rules.d

so:

`/lib/udev/rules.d/51-

well that was all a waste of time, kind of. Turns out that the SD card is the mount point of the EMMC memory anyways (apparently) so I discovered there was an SD card in device and may work….

Tagged , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *