The officially official Devuan Forum!

You are not logged in.

#1 2018-02-27 21:35:08

GNUser
Member
Registered: 2017-03-16
Posts: 570  

mtp device shown twice when plugged into ascii laptop

I've been on ASCII with MATE for a few days, and am very impressed and happy with it. Everything is working beautifully!

The last little thing I'd like to fix is this issue: When I plug in my android phone (an MTP device), the system mounts/shows it twice. See screenshot of my desktop:

doubled.png

These are the gvfs packages installed:

bruno@thinkpad:~$ dpkg -l | grep gvfs
ii  gvfs:amd64        1.30.4-1   amd64        userspace virtual filesystem - GIO module
ii  gvfs-backends    1.30.4-1   amd64        userspace virtual filesystem - backends
ii  gvfs-bin              1.30.4-1   amd64        userspace virtual filesystem - binaries
ii  gvfs-common      1.30.4-1   all          userspace virtual filesystem - common data files
ii  gvfs-daemons     1.30.4-1   amd64        userspace virtual filesystem - servers
ii  gvfs-libs:amd64  1.30.4-1   amd64        userspace virtual filesystem - private libraries

I'd like to fix this so that the phone is mounted only once, but I have no idea how to do it. Can someone please point me in the right direction?

Last edited by GNUser (2018-02-28 00:59:27)

Offline

#2 2018-02-27 22:35:25

golinux
Administrator
Registered: 2016-11-25
Posts: 3,340  

Re: mtp device shown twice when plugged into ascii laptop

Maybe that's related to your other duplicate icon post?

https://dev1galaxy.org/viewtopic.php?id=1910

Have you duplicated a config file somewhere?  Maybe fire up a vm and if it doesn't duplicate icons, start comparing directories/files

Offline

#3 2018-02-27 22:49:23

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: mtp device shown twice when plugged into ascii laptop

I really don't think the two are related, as one involves mate-panel and the other involves caja/gvfs.

Regarding the current issue, it does not affect thumbdrives and external hard drives, only my phone (which is unique in that it's my only mtp device).

Offline

#4 2018-02-28 03:14:49

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: mtp device shown twice when plugged into ascii laptop

I did some snooping around and discovered some things:

a) A process called /usr/lib/gvfs/gvfs-mtp-volume-monitor is normally running in the background

b) If I kill the above process, my phone gets mounted/shown 0 times when I plug it in

c) If I then run /usr/lib/gvfs/gvfs-mtp-volume-monitor in the background again--or if I reboot--then we're back to "normal" behavior where my phone gets mounted/shown 2 times when I plug it in

I'm after the Goldilocks behavior where my phone gets mounted/shown 1 time when it is plugged in. I'm not sure what to try next.

Last edited by GNUser (2018-02-28 03:31:31)

Offline

#5 2018-02-28 04:42:32

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,268  

Re: mtp device shown twice when plugged into ascii laptop

Maybe the phone has two partitions? E.g. internal and external sd cards?

Offline

#6 2018-02-28 12:29:08

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: mtp device shown twice when plugged into ascii laptop

That's a good thought, but it only has an internal/simulated sd card. Also, Devuan Jessie only shows it once.

I have an old Arch Linux machine I've kept updated. Will try plugging into that and will update this thread with result.

Last edited by GNUser (2018-02-28 13:55:44)

Offline

#7 2018-02-28 14:13:54

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: mtp device shown twice when plugged into ascii laptop

Devuan Jessie and an updated Arch Linux only show the phone once when it's plugged in.

I tried re-installing all packages with gvfs in the name. Also, in caja's media preferences I unchecked "Browse media when inserted" and checked "Never prompt or start programs on media insertion". Still, two desktop icons show up on the desktop when the phone is connected--the only difference now is that two caja windows do not automatically pop up when I plug in the phone.

Therefore, the issue here is not that caja is detecting the device twice: gvfs is the one that's detecting the device twice. Alas, I think I have the right diagnosis but still have no clue regarding the proper treatment.

Last edited by GNUser (2018-03-12 19:41:30)

Offline

#8 2018-02-28 20:00:34

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: mtp device shown twice when plugged into ascii laptop

Gvfs-mtp-volume-monitor seems to be a buggy mess. There only consistent thing about it is that it always detects my phone twice. Otherwise, it is pretty unpredictable: It occasionally detects the phone and shows the two desktop icons, but doesn't actually mount the device. Occasionally the caja windows that pop up do not contain any files or directories, so I need to close the two windows then double-click on one of the two desktop icons. Occasionally, the device is detected but an error box pops up saying the device is unavailable. I give up on using gvfs for mounting my phone.

Here is my graybearded workaround:

1. sudo apt-get install jmtpfs

2. sudo chmod a-x /usr/lib/gvfs/gvfs-mtp-volume-monitor

3. Create /etc/udev/rules.d/80-mtp-mount.rules with this in it:

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", RUN+="/bin/su bruno -c /opt/scripts/mtp-mount"

4. Create /opt/scripts/mtp-mount with this in it, then make it executable:

#!/bin/sh

# mount the device
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/scripts
export DISPLAY=:0.0
mkdir $HOME/Phone && jmtpfs $HOME/Phone && caja $HOME/Phone

# create a .desktop file to unmount the device
desktop_file=$HOME/Desktop/Phone-unmounter.desktop
cat << EOF > $desktop_file
[Desktop Entry]
Comment=Phone Unmounter
Exec=sh -c "fusermount -u ~/Phone; rm -r ~/Phone; rm $desktop_file"
Icon=media-eject
Terminal=false
Type=Application
Name[en_US]=Eject Phone
EOF
sleep 0.5 # to make sure .desktop exists
sudo chmod a+x $desktop_file

The above is as reliable as a faithful old dog, with never any surprises.

Folks experiencing flaky mounting of their Android phones (or other mtp device) can recycle the above workaround with only minimal modifications:
  - change "bruno" to your username in the udev rule
  - change the idVendor attribute in the udev rule to match your device's manufacturer

Last edited by GNUser (2018-03-12 19:43:55)

Offline

#9 2018-03-12 19:13:01

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: mtp device shown twice when plugged into ascii laptop

A quick follow-up:

When my Android phone is mounted by jmtpfs, I can perform all these operations from within the file manager (caja) on my Devuan laptop without any problems:
  - copy and paste files in either direction (phone <-> laptop)
  - cut and paste files in either direction (phone <-> laptop)
  - create new files on the phone
  - delete files from the phone
  - open and view files on the phone

However, jmtpfs mounts the phone in such a way that GUI applications such as pluma cannot modify files on the phone--I am able to start editing files that are on the phone, but I get an I/O error when I try to save the modified file. I did some duck-ducking and it seems this a known mtp limitation (https://askubuntu.com/questions/284762/ … why/421503).

Interestingly, gvfs (when it works) mounts my phone in such a way that pluma and other GUI applications can modify and save files on the phone. How does gvfs-mtp-volume-monitor magically work around an mtp limitation? I'd love to learn the trick so that I can implement it in my workaround. Anybody know?

Last edited by GNUser (2018-03-12 19:46:08)

Offline

#10 2018-04-25 13:18:44

Max_B
Member
From: Ancona, Marche, Italy
Registered: 2017-04-17
Posts: 16  

Re: mtp device shown twice when plugged into ascii laptop

Sorry for resurrecting an old post, but I'm experiencing the double item issue on Caja (1.16.6), too. My phone is a Motorola Moto-G (first model I think - don't know if this is relevant -... it shows as "XT1032" on file managers), and when I plug it in, almost always a double icon appears under "Devices", the "almost" is because sometimes the phone shows once. When it shows twice, both of the "devices" are fully functional, e.g. I can browse, cut/copy etc. files from/to both of them. I'm on ASCII fully updated.

Offline

Board footer