skcasb
Posts: 20
Joined: Wed Jul 11, 2018 12:46 pm

Auto-mounting external USB devices on /mnt/mydir

Wed Jul 08, 2020 3:23 pm

Hi all,

It is possible to mount a generic USB stick in a folder other than /media/pi/ (for example to /mnt/mydir) and disabling the windows popup shown on display when the usb stick is inserted ?

Is it possible to use an udev rule without modifying fstab?

Do you have any examples that can help me?

Thank you.

Regards.

GlowInTheDark
Posts: 1101
Joined: Sat Nov 09, 2019 12:14 pm

Re: Auto-mounting external USB devices on /mnt/mydir

Wed Jul 08, 2020 3:55 pm

The straightforward way to do this is to find the settings dialog in PCMANFM (aka, "The File Manager in Raspbian") and figure out how to disable automounting.

After you do this, then things will no longer automount (you may have to reboot for this to take effect - I am not sure). Now, you can do all your own mounting and unmounting. Fun, fun, fun!

Another way, that I've been playing with lately, is to use mount's --bind option, to create an "alias" of the original mount (the one in /media/pi). I do this:

$ cd
$ mkdir MyDrive
$ sudo mount --bind /media/pi/whatever-it-is MyDrive

Now, ~/MyDrive is mounted to the same underlying device as the thing under /media/pi. This works quite well for me.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Loves Linux; loves to dance.

GlowInTheDark
Posts: 1101
Joined: Sat Nov 09, 2019 12:14 pm

Re: Auto-mounting external USB devices on /mnt/mydir

Wed Jul 08, 2020 4:35 pm

Oh, and a couple other comments, regarding annoying things that come with the automount facility.

1) As far as I can tell, there's no way to disable the popup.

2) According to "jojopi" (I hope I spelled that right), it is possible to disable the annoying "You have not properly ejected it" message - by commenting out a certain stanza in one of the config files. I have not been able to verify this yet (because of a series of things - that boil down to "It is a pain to reboot the machine in question, so I'd rather not reboot it just to test this thing").
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Loves Linux; loves to dance.

bjtheone
Posts: 963
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: Auto-mounting external USB devices on /mnt/mydir

Wed Jul 08, 2020 7:14 pm

Another possible approach would be to punt pcmanfm and switch to a different file/desktop manager, if you really hate the pop up dialog. I am not sure if it is coming from pcmanfm or is part of the Desktop Manager (ie LXDE).

I am running Raspbian Lite + Mate, and using Caja as a file manager. I still get automounting without the popup dialogs.

Return to “Troubleshooting”