5

I'm trying to disable the USB automount in GNOME 3.14.1 (debian Jessie). I've modified the gnome media handling using dconf-editor, my configuration looks like this:

enter image description here

I'm not sure of what proces or services is mounting the devices, I have no entry in /etc/fstab refering to the USB devices. I thought it was gnome automount who was mounting the devices.

Any ideas?

2

3 Answers 3

9

For the record, the following works with gnome 3.28 (tested on archlinux and fedora).


In dconf-editor go to org > gnome > desktop > media-handling and turn off both
automount and automount-open.

enter image description here

If you prefer the terminal, run

gsettings set org.gnome.desktop.media-handling automount false
gsettings set org.gnome.desktop.media-handling automount-open false 

These will disable auto-mounting, however, when you insert the drive, it will still appear in the file manager right pane. If you hover your mouse over the icon you'll get a tooltip saying "mount and open drive" meaning you'll still be able to mount and open the drive with a single mouse click.

enter image description here


To disable the auto-mounting of USB devices for all users and also hide the devices from the users, you could use a udev rule. As root, run

cat <<\IN >/etc/udev/rules.d/99-disable-automount.rules
DRIVERS=="usb-storage", SUBSYSTEMS=="usb", ENV{UDISKS_AUTO}="0", ENV{UDISKS_IGNORE}="1"
IN

If any of these doesn't work for you then it's most likely a bug specific to your distro and I recommend you report it.

1
  • The dconf settings did not work for me on Arch Linux (5.8.7 kernel with Gnome 3.36) but the udev rule did. Thanks
    – Bujiraso
    Sep 16, 2020 at 22:02
0

If you are running jessie which runs systemd init systen, then autofs is causing the automount of your USB device.

You can possibly use systemctl disable autofs but this is not recommended if you are using autofs functionallity like in an ldap/nfs environment.

Also have a look at gnome-volume-manager.

2
  • I don't have neither autofs nor usbmount packages installed :( , It must be something else
    – Nuria
    Apr 2, 2016 at 15:29
  • After a lot of researching I think that disabling usb automounting using gnome3 is imposible for a random device. Take a look at this [ling] (unix.stackexchange.com/questions/119853/…) 'post' If I'm not mistaken is udisk2 who is mounting the usb devices it calls udev in order to know the configuration it should use and after the device is mounted is GVFS which notifies nautilus I add this entry to my udev rules in a attempt to at least mount usbs in only read but it has no efect: KERNEL=="sd*", SUBSYSTEMS=="block", MODE="0555"
    – Nuria
    Apr 2, 2016 at 18:14
0

It is indeed possible to disable USB automount for a random device, and it is separate from calls to udev (which do not of themselves open the device). An earlier answer had the correct answer - there are two parts to this, automount, and automount-open.

I use a simple script, which I call "usb_dis_en_able" (USB disable or enable), which requires one parameter, either "disable" or "enable". Here is the script - you can copy it to a directory on your path and use chmod +x to make it usable:

#!/bin/sh

# Disable or enable USB auto-mounting.  Note: while disabled, if a key is
# inserted it will still appear in the file manager right pane, but hover over it
# and it will say "mount and open drive" - as it is not yet mounted.
#

if [ "$1" = "" ] ; then
    echo ""
    echo "Disable and/or re-enable USB key auto-mounting temporarily."
    echo "Usage: $0 [ disable | enable ]"

    exit 0
fi

case $1 in
    "disable" )  gsettings set org.gnome.desktop.media-handling automount false;
             gsettings set org.gnome.desktop.media-handling automount-open false
             ;;

    "enable" )   gsettings set org.gnome.desktop.media-handling automount true;
             gsettings set org.gnome.desktop.media-handling automount-open true
             ;;

    * ) echo "Must specify either disable or enable (of USB auto-mount)" ;;
esac

I use this script whenever I use a key with a system not my own, to reduce the chance of a key-borne virus. For example, when I take photos to a store for high-quality printing, I put them on a clean USB key. After I get home from the store, I disable USB auto-mount, insert the key, re-format it (plus erase) for next time, and then re-enable USB auto-mount. Works like a charm (under Gnome 3).

You must log in to answer this question.

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