cmc/cleberg.net

My personal web garden & blog.

clone: git clone https://gitbay.org/cmc/cleberg.net.git

main: content/blog/2022-10-04-mtp-linux.org · raw

 1#+date:        [2022-10-04 Tue 00:00:00]
 2#+title:       MTP on Linux: Mount Your Phone Without a File Manager
 3#+description: Mounting Android phones on Fedora Linux with jmtpfs.
 4#+slug:        mtp-linux
 5#+filetags:    :linux:
 6
 7I recently ran into trouble attempting to mount my GrapheneOS phone to my laptop
 8running Fedora Linux via the [[https://en.wikipedia.org/wiki/Media_transfer_protocol][Media Transfer Protocol]] (MTP) and discovered a
 9simple and effective solution.
10
11* Use a Universal Serial Bus (USB) 3.0 Port
12
13First, ensure that the device was plugged in to the laptop through a USB 3.0
14port, if possible. From a brief glance online, it seems that USB 2.0 ports may
15cause issues with dropped connections over MTP. This is purely anecdotal since I
16don't have any evidence to link showing that USB 2.0 causes issues, but I can
17confirm that switching to a USB 3.0 port seemed to cut out most of my issues.
18
19* Switch USB Preferences to MTP
20
21Secondly, you need to ensure that the phone's USB preferences/mode is changed to
22MTP or File Transfer once the phone is plugged in. Other modes will not allow
23you to access the phone's file system.
24
25* Install =jmtpfs=
26
27Next, I used the =jmtpfs= package to mount my phone to my laptop. There are
28other packages that exist, but this one worked perfectly for me. On Fedora
29Linux, you can install it like this:
30
31#+begin_src sh
32sudo dnf install jmtpfs -y
33#+end_src
34
35* Create a Mount Point
36
37Once you have the package installed, you just need to create a folder for the
38device to use as a mount point. In my case, I used =/mnt/pixel=:
39
40#+begin_src sh
41sudo mkdir /mnt/pixel
42sudo chown -R $USER:$USER /mnt/pixel
43#+end_src
44
45* Mount & Access the Phone's File System
46
47Finally, plug-in and mount the device, and you should be able to see all storage
48(internal and external) inside your new folder!
49
50#+begin_src sh
51jmtpfs /mnt/pixel
52#+end_src
53
54The output should look something like this:
55
56#+begin_src sh
57Device 0 (VID=18d1 and PID=4ee1) is a Google Inc Nexus/Pixel (MTP).
58Android device detected, assigning default bug flags
59#+end_src
60
61Now you are mounted and can do anything you'd like with the device's files:
62
63#+begin_src sh
64cd /mnt/pixel
65ls -lha
66#+end_src
67
68From here, you will be able to see any internal or external storage available on
69the device:
70
71#+begin_src sh
72total 0
73drwxr-xr-x.  3 user user  0 Jan  1  1970  .
74drwxr-xr-x.  1 root root 10 Oct  4 13:29  ..
75drwxr-xr-x. 16 user user  0 Apr 21  4426383 'Internal shared storage'
76#+end_src