0

Something changed recently in my ubuntu 20.04 desktop regarding how it mounts removeable media (like USB storage drives).

Previously such devices would appear under location /media/$USER/....

But now that directory is empty when usb storage devices are attached.

The devices still appear in the launcher and operate OK from the GUI for nonroot users.

But I need to be able to reference them from command-line and scripts, as this has worked for years since ubuntu 16.04 and above, until some recent change.

For example, when I use the launcher to open my walkman and then use its 'Open in Terminal', I can see that the path for my walkman is now:

/run/user/1000/gvfs/mtp:host=SONY_WALKMAN_104316F6127986/Storage Media

whereas previously it was instead: /media/$USER/WALKMAN

How can I revert to the previous behaviour?

Edit 1: with a walkman connected, the output of lsusb as nonroot user is:

Bus 002 Device 002: ID 8087:8002 Intel Corp. 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:800a Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 04f2:0939 Chicony Electronics Co., Ltd USB Optical Mouse
Bus 003 Device 003: ID 413c:2113 Dell Computer Corp. Dell KB216 Wired Keyboard
Bus 003 Device 074: ID 054c:0882 Sony Corp. WALKMAN
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Edit 2: with the /etc/udev/rules.d/90-sony.rules contents:

ATTR{idVendor}=="054c", ATTR{idProduct}=="0882",  ENV{ID_MTP_DEVICE}="0", ENV{ID_MEDIA_PLAYER}="1"

Note that it is not only the walkman that is impacted, but even USB3 spinning drives that I used for backups.

Attaching the walkman after root runs udevadm control -R, does not change the symptom (/media/$USER is still empty), and dmesg shows the following:

[665818.085033] usb 3-1: new high-speed USB device number 75 using xhci_hcd
[665818.233352] usb 3-1: New USB device found, idVendor=054c, idProduct=0882, bcdDevice= 0.01
[665818.233361] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=5
[665818.233366] usb 3-1: Product: WALKMAN
[665818.233369] usb 3-1: Manufacturer: SONY
[665818.233372] usb 3-1: SerialNumber: ...
[665818.234208] usb-storage 3-1:1.0: USB Mass Storage device detected
[665818.234550] scsi host4: usb-storage 3-1:1.0`
5
  • Can you show lsusb with your device connected?
    – nobody
    Jul 12, 2021 at 9:55
  • create /etc/ude/rules.d/90-sony.rules with content ATTR{idVendor}=="054c", ATTR{idProduct}=="0882", ENV{ID_MTP_DEVICE}="0", ENV{ID_MEDIA_PLAYER}="1" let udev read the rule sudo udevadm control -R Plug in your device.If something gets odd remove the file. I have another sony walkman so I can not test it.
    – nobody
    Jul 12, 2021 at 10:59
  • @nobody did not change the symptom, see updates
    – mao
    Jul 12, 2021 at 11:15
  • Oh unplug every usb storage device important!!! sudo rm /media/$USER Remove the created file after that sudo udevadm control -R plugin something usb-stick or your media player. Please test it also on an usb2 port.
    – nobody
    Jul 12, 2021 at 11:34
  • Makes no difference to symptom when I disconnect the storage devices, or use usb2 ports, or remove the 90-sony.rules, or remove /media/$USER directory (and udevadm conrtol -R) .I need to study udev stuff and try some different approach. Will also compare a different workstation with 18.04 ubuntu with same devices.
    – mao
    Jul 12, 2021 at 12:01

1 Answer 1

0

Your device is now mounted using the mtp protocol. That leaves actual control on reading and writing to the storage media to the device itself when mounted, and strongly decreases the chance that the drive system of the device may be corrupted. libmtp is installed by default on more recent Ubuntu versions.

Formerly, your device would be mounted as a USB drive. Then it is Ubuntu that directly accesses the storage of the medium. You however report that an ordinary USB drive also mounts like this. Please double check this.

I did and will not test, but removing the mtp libraries will probably revert to the old behaviour for your particular device. However, you will not be able to mount more recent Android phones anymore. These nowadays can be accessed only using mtp, and do not support "traditional" mounting anymore.

Alternatively, you probably will still be able to mount your walkman fully manually. Its partition will likely appear in the output of lsblk or sudo fdisk -l.

1
  • Thanks for the information, which I must research further. I am ok with changes as long as my aims are not frustrated. My true requirement is that I be able to script writing and reading to these devices, because it is insufferable to be forced to use a gui. I'm happy to change my scripts, but won't accept a GUI only solution.
    – mao
    Jul 12, 2021 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .