How to mount MTP devices independently of desktop environment
1
vote
1
answer
769
views
I'm using Ubuntu 22.04 with Gnome and **I want to create a bash script which copy files from my phone to my laptop**.
Seeing this answer , I installed gvfs-fuse , reboot and now the device is available at
/usr/run/$(id -u)/gvfs
.
The problem is that I want to mount MTP devices without needing gvfs
, since I want the script to be usable in any linux environment.
I tried using jmtpfs
but it yields errors related to GVFS:
- mtp-detect
gives the error:
Attempting to connect device(s)
libusb_claim_interface() reports device is busy, likely in use by GVFS or KDE MTP device handling alreadyLIBMTP PANIC: Unable to initialize device
Unable to open raw device 0
OK.
- Trying to mount with jmtpfs
yields (understandably) the same result:
libusb_claim_interface() reports device is busy, likely in use by GVFS or KDE MTP device handling alreadyLIBMTP PANIC: Unable to initialize device
terminate called after throwing an instance of 'MtpErrorCantOpenDevice'
what(): Can't open device
fish: Job 1, 'jmtpfs /media/santatra/mtp/' terminated by signal SIGABRT (Abort)
- but jmtpfs -l
see the MTP device:
Device 0 (VID=18d1 and PID=4ee1) is a Google Inc Nexus/Pixel (MTP).
Available devices (busLocation, devNum, productId, vendorId, product, vendor):
1, 36, 0x4ee1, 0x18d1, Nexus/Pixel (MTP), Google Inc
So it seems that the desktop environment is mounting the device automatically.
**QUESTION**: How can I mount MTP devices without needing GVfs in an environment with GNOME? And how can I tell Nautilus to release the MTP device?
## What I tried
- The *Unmount* button on Nautilus does indeed unmount the device but gives the same error.
- There's no option related to automatic mounting in gnome-control-center
## Environment
- Ubuntu 22.04
- Nautilus 42.2
## NOTE
I don't think I should ask on Ask Ubuntu because
- it can also occur in a KDE environment
- I want the script to be usable in any linux environment
Asked by glacier
(391 rep)
Feb 9, 2025, 08:52 AM
Last activity: Mar 27, 2025, 11:15 AM
Last activity: Mar 27, 2025, 11:15 AM