2

I am working on a project, and for this I need to disable the aumounting of hard-drives in Ubuntu both at startup and when I plug an hard-drive.

I tried one solution with "edit-conf" disabling automount at org.gnome.desktop.media-handling but when I plug a hardrive ubuntu still mounts it an open a window even when I restart the computer in between.

There is also the fstab solution but the thing is I don't know in advance the UUID of the drive I don't want to mount automatically.

From want I understand there is the solution of editing an udev rule, but i'm not a specialist of that.

3

Run these two commands:
gsettings set org.gnome.desktop.media-handling automount 'false'
gsettings set org.gnome.desktop.media-handling automount-open 'false'

Or you can try it with a udev rule:
sudo nano /etc/udev/rules.d/85-no-automount.rule
Paste this line SUBSYSTEM=="usb", ENV{UDISKS_AUTO}="0" and save the file.
Reboot the system.

  • It didn't work, I executed the two command then reboote, and when i plugged my hard-drive, ubuntu stills mount it. – Didier Chavaroche Jul 16 '14 at 9:33
  • You can try the udev rule I added above. – Pabi Jul 16 '14 at 9:37
  • I didn't try the rule, but I have a question before, I plug the hard drives directly onto the SATA ports of my computer, How should I translate the rule? SUBSYSTEM=="sata"? – Didier Chavaroche Jul 25 '14 at 9:35
1

You can try to add the module to the blacklist:

sudo gedit /etc/modprobe.d/blacklist.conf

add:

blacklist usb-storage

or

echo "blacklist usb-storage" | sudo tee -a /etc/modprobe.d/blacklist.conf

Enabling it later should just be:

sudo modprobe usb-storage

0

As Pabi wrote in his answer, run this command:

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

BUT: this will probably not be effective until the next reboot.

Lack of a reboot caused me to doubt the effectiveness of gsettings initially. I found it when being very thorough in preparation for filing a bug, which I found I didn't need to do. I've only tried this under sudo, however, so if you still have trouble, try doing it that way. I want this effective system-wide and found this does the job.

You do not need to touch automount-open because it only applies when an automount happens, and you will have disabled that.

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.