8

When I plug a USB stick or a mobile phone into my laptop, I don't want the operating system to automatically mount the device.
In Ubuntu 14.04 I could run the below command and this would disable automounting of block devices, e.g.

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

In 16.04 this command now seems to have no effect, what is the equivalent command in 16.04?

  • Have you tried it with dconf-editor? – garethTheRed May 13 '16 at 6:48
  • @garethTheRed thanks for the comment, per your suggestion, I have now installed dconf-edittor . If I try the gsettings ... command - dconf-editor recognises the change. I'm not sure if the settings are taking effect at the OS level , testing now... – the_velour_fog May 13 '16 at 7:14
  • Same for me on 16.04 running XFCE. gsettings get org.gnome.desktop.media-handling automount returned true. After your command it returns false but automount still happens. :-( – Stéphane Gourichon Aug 8 '16 at 8:35
  • On Xubuntu 16.04 (xfce) the equivalent command is xfconf-query -c thunar-volman -n -p "/automount-drives/enabled" -t string -s false ; xfconf-query -c thunar-volman -n -p "/automount-media/enabled" -t string -s false . This is what xfce4-settings-manager does in the "Removal drives and media" section. – Stéphane Gourichon Aug 8 '16 at 9:14
  • @don_crissti that sounds right. IIRC in the time since asking this question I think I discivered the problem was with the environment vars not being set - so the command is likely fine after all. good point checking for mount-ness with lsblk too. – the_velour_fog Sep 28 '16 at 9:19
5

and for mate desktop its slightly different

gsettings set org.mate.media-handling automount false

its also important to keep in mind that this is a per user setting.
So it is valid only for the current desktop user....

check with:

gsettings list-recursively  org.mate.media-handling

and

gsettings list-recursively  org.gnome.desktop.media-handling 

Due to the mixed nature of the mate desktop (there are always some gnome apps I use) there seem to be some gnome settings leaking into the desktop configuration.
So I always set both parts to make sure.....

  • You saved my day! This solution also works on FreeBSD. I was looking for some daemon that would be automounting my devices, but it was the mate desktop! +1 – Giorgio Aug 25 '18 at 7:11
3

After further investigation, which is backed up by several comments on this post, it seems the command

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

does work as it had previously.
The reason it failed on this occasion seemed to be caused by the lack of environment variables being set, notably $DBUS_SESSION_BUS_ADDRESS.
To re-iterate, the command does work for Ubuntu 16.04 as it had done on 14.04.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.