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?
3 Answers
go to Dash Home > System Settings -> Removable Media
and check "Never prompt or start programs on media insertion"
-
3
-
1in Ubuntu 14.04, it is
Dash Home > System Settings > Details > Removable Media
. More info at superuser.com/questions/556674/… Mar 27, 2014 at 20:04 -
@BrallanAguilar someone at least ‘solved’ this by id-speficic unmount scripts...– Frank NFeb 25, 2017 at 7:18
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/sda4...
/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
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 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.
-
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.)– cdaddrSep 24, 2018 at 17:39
-
1Hi @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.– tlwhitecSep 25, 2018 at 7:35