LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   How to disable USB automount? (https://www.linuxquestions.org/questions/red-hat-31/how-to-disable-usb-automount-4175460592/)

PeterSteele 05-03-2013 11:03 AM

How to disable USB automount?
 
I've search for an answer to this question but haven't had much luck. I am running CentOS 6.4 and am doing a lot with USB sticks. CentOS conveniently mounts a USB stick that it detects has a formatted file system on it, except that I don't want it to do this. How can I turn off this feature?

Janus_Hyperion 05-03-2013 12:00 PM

If you are using GNOME (which is what I know in)

System --> Preferences --> Removable Drives and Media.

Here, you can change all the automount settings.

Hope that helps! :)

PeterSteele 05-03-2013 01:08 PM

I use Gnome as well, but there is no "Removable Drives and Media" entry under System Preferences, and nothing that even looks close. Are you using CentOS?

Janus_Hyperion 05-03-2013 01:16 PM

I have a Centos VM in the workplace which is what I checked. If you do not have the menu entry, can you try this in a terminal?

Code:

$ gnome-volume-properties

PeterSteele 05-03-2013 01:48 PM

Hmmm, the closest thing I have is gnome-volume-control, but that's for setting the speaker volume. Are these commands available through a yum package? I did a quick look but nothing seemed to match.

Madhu Desai 05-03-2013 04:31 PM

If you want to mount usb device, but don’t want to open nautilus automatically every time usb device is inserted, then:

In nautilus,
  1. Edit->Preferences = Media (tab)
  2. Check “Never prompt or start programs on media insertion”
  3. Uncheck “Browse media when inserted”
If want to disable device mount itself, then try this:

Disable GNOME Automounting

Janus_Hyperion 05-03-2013 04:37 PM

I am extremely sorry about this - I missed Centos 6.4! :o

Alternatively, you can potentially use gconf-editor (if I am not mistaken, this time).

PeterSteele 05-04-2013 10:25 AM

So that's an improvement. After making these changes in nautilus, the file browser no longer opens when I insert USB stick. The drives do continue to auto-mount though, under /media/<id>, just like before. I think this is controlled through something outside of nautilus, a system setting somewhere.

Janus_Hyperion 05-04-2013 12:58 PM

Take a look at this link - http://unix.stackexchange.com/questi...-6/74127#74127

PeterSteele 05-05-2013 01:40 PM

Hmmm. This talks about how to make something automount that isn't. I need to opposite. It does describe how to configure a new rules.d config to do this, so I might be able to use this same file for disable the automounting. Right now I don't have the rules.d file they describe here, so something else is actually doing the automounting.

JollyRogers 05-15-2013 09:13 AM

Is this what you want? To fully disable the gnome automounter?

# gconftool-2 --direct \
--config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type bool \
--set /apps/nautilus/preferences/media_automount false
# gconftool-2 --direct \
--config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory \
--type bool \
--set /apps/nautilus/preferences/media_autorun_never true

PeterSteele 05-15-2013 09:42 AM

I've run these commands and my USB sticks are still automounting. Are these settings intended to take place immediately or do I need to log out/in? I have too much stuff up and running right now to logout, but I'll hopefully be able to do that soonish...

JollyRogers 05-15-2013 10:07 AM

I tested with a DVD/CDROM without logging out/in or rebooting, and they are not automounting. Unfortunately, in the enviroment I am in, I cannot test with a usb stick, plus I have the usb-storage module disabled. It should however work.

ETA: I also have autofs off.
#chkconfig autofs off

Another option would be to add noauto to /etc/fstab for the devices being automounted...

alpo85 05-18-2013 08:57 PM

Sir/Ma'am,

Have you considered throwing a line in /etc/fstab?

Code:

/dev/sdc  /mnt/sdc  ext4  noauto,ro,nouser,noexec  1 2
Of course, replace "/dev/sdc" with your USB Drive and the "noauto,ro..." options, as required. Seemed to work for me on RHEL 6.4.

Hope it helps.


alpo

PeterSteele 05-20-2013 08:12 AM

I finally rebooted my PC and it appears the gconftool commands suggested by JollyRogers did the trick. My USB sticks no longer automount when I insert them. Not exactly an intuitive operation, or at least not well documented, but at least there is a way.

I will mark this thread as SOLVED.

Thanks for all the responses.

Peter


All times are GMT -5. The time now is 07:55 PM.