I am trying to use
jmtpfs
to mount my GoPro to transfer files when I plug it into my computer.
I have a script that works outside a udev rule. However, when run inside the udev rule the script fails and disconnects my USB device.
A minimal working example is given here:
**script**
#!/usr/bin/env bash
jmtpfs /media/GoPro > /tmp/gopro.log 2> /tmp/gopro.err
**udev rule**
SUBSYSTEM=="usb", ATTR{idVendor}=="2672", ATTR{idProduct}=="004b", ACTION=="add", RUN+="/bin/bash -c /home/matt/Projects/GoProScraping/scripts/grab_go_pro_files.sh"
---
The output of the file /tmp/gopro.err
is:
Device 0 (VID=2672 and PID=004b) is UNKNOWN in libmtp v1.1.19.
Please report this VID/PID and the device model to the libmtp development team
fusermount: mount failed: Operation not permitted
The output of journalctl -f
is:
Sep 29 09:45:31 nina kernel: usb 1-4: new high-speed USB device number 16 using xhci_hcd
Sep 29 09:45:31 nina kernel: usb 1-4: New USB device found, idVendor=2672, idProduct=004b, bcdDevice= 0.01
Sep 29 09:45:31 nina kernel: usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 29 09:45:31 nina kernel: usb 1-4: Product: GoPro MAX
Sep 29 09:45:31 nina kernel: usb 1-4: Manufacturer: GoPro
Sep 29 09:45:31 nina kernel: usb 1-4: SerialNumber: C3351325091705
Sep 29 09:45:31 nina sudo: root : PWD=/ ; USER=root ; COMMAND=/usr/bin/jmtpfs /media/GoPro
Sep 29 09:45:31 nina sudo: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Sep 29 09:45:34 nina sudo: pam_unix(sudo:session): session closed for user root
Sep 29 09:45:34 nina kernel: usb 1-4: USB disconnect, device number 16
Sep 29 09:45:34 nina systemd-udevd: 1-4: Process '/bin/bash -c /home/matt/Projects/GoProScraping/scripts/grab_go_pro_files.sh' failed with exit code 1.
It looks like I plug the GoPro in, udev picks up that it's connected, then there's a permission error and the error causes the USB to be disconnected and then udev picks it up again.
However, if I try running the command: jmtpfs /media/GoPro
as the root user it mounts well and I can access files manually.
I thought udev rules run as root, what am I missing?
Asked by Matt Ellis
(3 rep)
Sep 29, 2024, 09:51 AM
Last activity: Sep 29, 2024, 02:04 PM
Last activity: Sep 29, 2024, 02:04 PM