How to configure the default automount location?

In Ubuntu 13.04 you can tell udisks2 to automount in /media/ instead of /media/[username]/ by adding a udev rule that sets the environment var UDISKS_FILESYSTEM_SHARED. You can do this by adding a file called (eg) /etc/udev/rules.d/99-udisks2.rules that contains:

ENV{ID_FS_USAGE}=="filesystem", ENV{UDISKS_FILESYSTEM_SHARED}="1"

I think udev monitors the /etc/udev/rules.d folder to detect changes, but if not, you can force it to reload its rules with sudo udevadm control --reload. Note though that the new mount location doesn't seem to take effect until you physically remove and plug the external drive back in.

This doesn't work in Ubuntu 12.10 because it uses udisks version 2.0.0, and support for the above didn't appear until version 2.0.91.


For your convenience, you can paste the following into the terminal

echo 'ENV{ID_FS_USAGE}=="filesystem", ENV{UDISKS_FILESYSTEM_SHARED}="1"' | \
sudo tee -a /etc/udev/rules.d/99-udisks2.rules

Now anyone accessing your machine can access the removable disks you plug into it. So be careful. Tested on 14.04, but as pointed out above, it should work on 13.04 and later.


It's not the kernel but udisks2 where the automount location is hardcoded. You can't configure it.

The original udisks2 uses /run/media/username but Ubuntu patched it to use /media/username/.

I guess Mint 12 like Ubuntu 12.04 comes with udisks1 which uses just /media/.

If you really need the automount disks to be mounted in /media/ you could try to replace /media/your_username with a symlink pointing to /media:

sudo rmdir /media/your_username
sudo ln -s /media /media/your_username

You can remove media directory, create a soft link by name media under / which points to your desirable location. Make sure nothing is mounted under media when you do this. Plug your pen-drive and it gets mounted under your desired path. Worked for me.

Tags:

Usb

Automount