Script to unmount the smart phone

Since I connect my phone so much to my computer, I would like to speed things up to un mount it.

Will this work?

sudo umount mtp://SAMSUNG_SAMSUNG_Android_R5CX91KVE3W/

Thanks for you help. I am very happy and doing good. :slight_smile:

1 Like

On my system (MATE 24.04.1), it's not as straightforward because the devices are mounted as virtual file systems via gvfsd.

It's possible to unbind the USB device - but I've yet to find a way (from command line) that I like. You could start looking here: how to disable USB devices based on vendor id in Linux environment? - Unix & Linux Stack Exchange

2 Likes

Sorry, that link isn't all that helpful. Perhaps start looking on google for "unbind USB using vendor and product linux".

No, but this will

gio mount -u mtp://SAMSUNG_SAMSUNG_Android_R5CX91KVE3W/

This because GNOME/GIO doesn't mount it on the filesystem at all.

EDIT: As a matter of fact, it kind of virtually mounts it on /run/user/$UID/gvfs so you can do some basic file actions but that is about it.

For all file actions to mtp:// use the gio command, and that includes copy, mkdir, move, rename, etc. In short, it duplicates all the standard commands.
It is ridiculous but that's the GNOME way.

You don't need sudo to unmount because it is a user mount, not a systemwide mount.

B.T.W. The fuse userspace filesystem service is not even used for mtp in GTK/GNOME/MATE based ubuntu.

4 Likes

How do I find or list the path that mtp assigns for mounting the device? When I enter

ps -ef | grep mtp

the report is as follows:

ericthe+    2372    1849  0 12:51 ?        00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
ericthe+    4743    2108  0 13:10 ?        00:00:00 /usr/libexec/gvfsd-mtp --spawner :1.10 /org/gtk/gvfs/exec_spaw/5

I don't see anything there that looks like the quoted path. :frowning:

gio mount -l

only makes reference to the last previous "recognized" USB mount performed by udev automount:

Volume(0): VERB_R_F1
  Type: GUnixVolume

which is reporting on the previously mounted (currently not mounted !!!) USB stick, and doesn't even list the SONY Walkman that is plugged in via the process

ericthe+    4743    2108  0 13:10 ?        00:00:00 /usr/libexec/gvfsd-mtp --spawner :1.10 /org/gtk/gvfs/exec_spaw/5

In a non-UNIX non-standard and very awkward way:

gio mount -l | grep mtp

If you disconnect a device without gio unmounting it first, it might think it is still connected, just like the networkfolder-icons to remote computers which stay around until "disconnected".

On my computer it lists it correctly but the whole gio/gnome way of doing this is procedural errorprone.

Make sure that the walkman itself is at least able to be mounted as a filesystem.

Know that SONYβ„’ loves DRM (Digital-Restrictions-Management) and because of this they often implemented music-transfer protocols in a non-documented proprietary closed format, only to be used with their proprietary DRM infested malware (just like Apple's horrible iTunes.)

I don't know if your walkman also had the DRM treat but this is quite common.

Correct, gio is 100% non-transparent

The mounted device will be available in a directory that begins with mtp:host= and is located under /run/user/$UID/gvfs/

2 Likes

That command doesn't seem to work. The result for the first part is:

Volume(0): VERB_R_F1
  Type: GUnixVolume

which, as mentionned previously, only shows a device previously mounted by automounter under the /media/username directory (standard MSDOS filesystem USB stick).

Caja, on the other hand, does show the correct path, but nothing else:

So, how is it that Caja can see it ... but not gio ???

Report from my custom "pt.sh" script (only reference to "mtp"):

  2094   1836    ?  ericthered              | | /usr/libexec/gvfsd
  2300   2094    ?  ericthered              | | | /usr/libexec/gvfsd-trash --spawner :1.10 /org/gtk/gvfs/exec_spaw/0
  2605   2094    ?  ericthered              | | | /usr/libexec/gvfsd-http --spawner :1.10 /org/gtk/gvfs/exec_spaw/1
  2612   2605    ?  ericthered              | | | | sh -c /usr/lib/x86_64-linux-gnu/libproxy/0.4.17/pxgsettings org.gnome.system.proxy org.gnome.system.proxy.http org.gnome.system.proxy.https org.gnome.system.proxy.ftp org.gnome.system.proxy.socks
  2613   2612    ?  ericthered              | | | | | /usr/lib/x86_64-linux-gnu/libproxy/0.4.17/pxgsettings org.gnome.system.proxy org.gnome.system.proxy.http org.gnome.system.proxy.https org.gnome.system.proxy.ftp org.gnome.system.proxy.socks
  4703   2094    ?  ericthered              | | | /usr/libexec/gvfsd-mtp --spawner :1.10 /org/gtk/gvfs/exec_spaw/2
  4914   2094    ?  ericthered              | | | /usr/libexec/gvfsd-network --spawner :1.10 /org/gtk/gvfs/exec_spaw/3
  4931   2094    ?  ericthered              | | | /usr/libexec/gvfsd-dnssd --spawner :1.10 /org/gtk/gvfs/exec_spaw/5
  2099   1836    ?  ericthered              | | /usr/libexec/gvfsd-fuse /run/user/1000/gvfs -f

(.... pause while editing ...)

EUREKA !!!

I just discovered that the responses from "gio" are VERY DEPENDENT on user performing the command.

"root" does NOT have full visibility !!! (first time I have personally hit this condition, in private of professional practice :frowning: )

I have been doing almost everything as root, as I usually do. As my basic user, "gio mount -l" on my computer gives the following:

Drive(0): WDC WD20EZRX-00DC0B0
  Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
Drive(1): WDC WD5000AAKS-00V1A0
  Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
Drive(2): ASUS    DRW-24F1ST   c
  Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
Volume(0): WALKMAN
  Type: GProxyVolume (GProxyVolumeMonitorMTP)
  Mount(0): WALKMAN -> mtp://Sony_WALKMAN_10FEAAF5343634/
    Type: GProxyShadowMount (GProxyVolumeMonitorMTP)
Mount(1): mtp -> mtp://Sony_WALKMAN_10FEAAF5343634/
  Type: GDaemonMount

(Comment: Given the purpose/focus of "gio", not sure why the non-mtp items would be evaluated or listed!)

... and as you pointed out,

ls -l /run/user/1000/gvfs

is showing that mount as

dr-x------ 1 ericthered ericthered 0 Dec 31  1969 'mtp:host=Sony_WALKMAN_10FEAAF5343634'

Thank you, Thom!

Old dogs can learn new tricks!


Food for thought:
I wonder what the underpinnings of gio involve that it would block root from visibility of user content!!! Or is this the result of some ongoing "security" coding to enforce generalized "compartmentalized" access based on "effective user ID" ?

4 Likes

You might find this of interest:

2 Likes

Do not get cocky.

Humility is a good thing.

This streamlines the efficient use of Linux and it's occasional paranoia with security.

echo "your pasword" | sudo -S thunar /home/andy/ &>/dev/null

Some boards have edited out my suggestion. :slight_smile: