Score:3

How to automount removable usb drives?

nl flag

When I plug in a flash drive in my PC (Ubuntu 20.04.2 LTS), it does not automount. I have to open the Disks Tool and mount the drive manually. The automount setting is enabled:

$ gsettings list-recursively org.gnome.desktop.media-handling 
org.gnome.desktop.media-handling autorun-never false
org.gnome.desktop.media-handling autorun-x-content-open-folder @as []
org.gnome.desktop.media-handling automount-open true
org.gnome.desktop.media-handling autorun-x-content-ignore @as []
org.gnome.desktop.media-handling automount true
org.gnome.desktop.media-handling autorun-x-content-start-app ['x-content/unix-software']

Creating fstab entries is not a good solution for me, because I also want to automount new devices.

Something somewhere must be disabled, but I have no idea where. If anyone has a clue, kindly let me know :-)

Update: As requested in the comments, here's a the log of journalctl -xe after attaching a USB device.

Aug 26 16:46:18 PC kernel: usb 1-6: new high-speed USB device number 3 using ehci-pci
Aug 26 16:46:18 PC kernel: usb 1-6: New USB device found, idVendor=0bc2, idProduct=2323, bcdDevice= 0.00
Aug 26 16:46:18 PC kernel: usb 1-6: New USB device strings: Mfr=2, Product=3, SerialNumber=1
Aug 26 16:46:18 PC kernel: usb 1-6: Product: Expansion+
Aug 26 16:46:18 PC kernel: usb 1-6: Manufacturer: Seagate
Aug 26 16:46:18 PC kernel: usb 1-6: SerialNumber: NA8L5XB9
Aug 26 16:46:18 PC kernel: scsi host4: uas
Aug 26 16:46:18 PC kernel: scsi 4:0:0:0: Direct-Access     Seagate  Expansion+       9300 PQ: 0 ANSI: 6
Aug 26 16:46:18 PC kernel: sd 4:0:0:0: Attached scsi generic sg3 type 0
Aug 26 16:46:18 PC kernel: sd 4:0:0:0: [sdc] Spinning up disk...
Aug 26 16:46:18 PC mtp-probe[17138]: checking bus 1, device 3: "/sys/devices/pci0000:00/0000:00:1a.7/usb1/1-6"
Aug 26 16:46:18 PC mtp-probe[17138]: bus: 1, device: 3 was not an MTP device
Aug 26 16:46:18 PC mtp-probe[17157]: checking bus 1, device 3: "/sys/devices/pci0000:00/0000:00:1a.7/usb1/1-6"
Aug 26 16:46:18 PC mtp-probe[17157]: bus: 1, device: 3 was not an MTP device
Aug 26 16:46:22 PC kernel: ....ready
Aug 26 16:46:22 PC kernel: sd 4:0:0:0: [sdc] 3907029167 512-byte logical blocks: (2.00 TB/1.82 TiB)
Aug 26 16:46:22 PC kernel: sd 4:0:0:0: [sdc] Write Protect is off
Aug 26 16:46:22 PC kernel: sd 4:0:0:0: [sdc] Mode Sense: 4f 00 00 00
Aug 26 16:46:22 PC kernel: sd 4:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Aug 26 16:46:22 PC kernel: sd 4:0:0:0: [sdc] Optimal transfer size 33553920 bytes
Aug 26 16:46:22 PC kernel:  sdc: sdc1
Aug 26 16:46:22 PC kernel: sd 4:0:0:0: [sdc] Attached SCSI disk

Also, permissions seem to be correct:

getfacl /media/<username>

# file: media/<username>
# owner: root
# group: root
user::rwx
user:<username>:r-x
group::---
mask::r-x
other::---
Terrance avatar
id flag
https://help.ubuntu.com/community/Mount/USB covers a lot of what you have here, but do you have the `/media/<username>` directory that is needed for automounting?
abeciaj avatar
us flag
This might help. https://www.linuxbabe.com/desktop-linux/how-to-automount-file-systems-on-linux Note: I can't comment yet, so I added this to answer C:
KrawallKurt avatar
nl flag
Yes, that exists
KrawallKurt avatar
nl flag
As already stated, creating fstab entries is not a good solution for me
Terrance avatar
id flag
When you plug in a USB device does `journalctl -xe` output anything about trying to automount the USB? Your settings in your question look correct, but I am wondering if the `/media/username` folder special permission might be wrong. One way to check is `getfacl /media/<username>` and make sure you see a line that says `user:<username>:r-x` As far as `/media/<username>` goes, the owner and group of it should be root for proper mounting.
KrawallKurt avatar
nl flag
@Terrance, thanks for your help. I provided the information you asked for in the question above.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.