Whenever I insert a flash drive, a new Nautilus window opens showing its contents. Is there a way to deactivate "auto-open" option for a specific USB unit?

  • PD.: I want to use it FOR A SPECIFIC USB DEVICE! – Brallan Aguilar Jan 20 '12 at 19:12
  • 1
    Use Case: I'd like to do this for my phone so I can charge it off my computer without it mounting. – flickerfly Jan 4 '17 at 21:12

go to Dash Home > System Settings -> Removable Media and check "Never prompt or start programs on media insertion"

enter image description here

| improve this answer | |

Figure out its uuid:

Let's start with the current id (not yet uuid)

mount | grep ^/dev

You should somewhere should recognize its actual name here,

/dev/sda5 on /boot ...
/dev/sdc1 on /media/frank/FancyBackupDrive FX1... <-- assume, its this
/dev/sdc2 on /media/frank/some other Drive ...

Now, say, it's sdc1. Let's figure out its truly unique uuid:

$> ll /dev/disk/by-uuid/ | grep sdc1

Should get you a fairly long string (often hex, sometimes with dashes) that symbolically links somewhere (well, to above sdc1)

lrwxrwxrwx [...]  366A2F886A2F003A -> ../../sdc1

Enter into /etc/fstab to never mount

Backup before sounds like a good idea to me.

sudo cp /etc/fstab /etc/fstab.bak

Then open for edit (i.e. sudo pluma /etc/fstab), enter this to the file (the comment is optional, your uuid and file system may differ)

# Auto-Mount prevents UUID=366A2F446A2F006B none ntfs ro,noauto

Works for me, with an external, two-partition drive!

If you do develop a desire to use that drive:

manual mount

directory must pre-exist, not taken care of. so generate it (only once, ever):

sudo mkdir /media/myFx

And here we go

mount /dev/disk/by-uuid/366A2F886A2F003A /media/myFX

manual unmount

sudo umount /dev/disk/by-uuid/366A2F886A2F003A

Depending on your specifics, your mount resp. your fstab entry might need additional parameters with your preferred user rights, a ‘rare’ drive format and all that stuff:

sudo mount -t ntfs -o umask=007,gid=046,uid=0,nls=utf8 /dev/disk/by-uuid/366A2F886A2F003A /media/myFX
| improve this answer | |

These times the unity/gnome-based desktop environments have the gnome-disks utility which you can use for this specific purpose.

Just select your device in the column on the left, then select the partition you don't want to mount (one might expect only one on a common USB disk) and click the button with cogs below the partition bar. Then select Edit Mount Options... and set there whatever you want. I suppose you are looking for disabling the Mount at startup option (which is a default on Ubuntu 16.04, but still e.g. not on CentOS 7).

After clicking OK you'll be prompted for sudo password and the results will get written into /etc/fstab where you can see what actually happened.

| improve this answer | |
  • This looked really promising as a 'softer' way to handle the original question without editing system files directly, but unfortunately gnome-disks doesn't seem to see a mounted Android phone. (16.04, LG Nexus 5X phone.) – cdaddr Sep 24 '18 at 17:39
  • 1
    Hi @cdaddr! It's a whole different story with MTP devices. MTP is a data transfer protocol, not a way to introduce a disk device to the system. These "soft" devices usually go via gvfs and seem to be quite harder to tame. It seems to be possible, though. – tlwhitec Sep 25 '18 at 7:35

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.