f you have multiple hard drives connected to your Mac, or maybe you have multiple partitions on a single hard drive, by default, OS-X will mount all those volumes at boot time.
In case you don’t want this to happen, and instead mount one only on-demand, when needed, maybe with Disk Utility, here is what you need to do.
Start by opening the Disk Utility app in your /Applications/Utilities folder. Select the drive or partition you don’t want to have auto mounted and click the info button. Now copy the Universal Unique Identifier string and open the terminal, edit or create the
/etc/fstab file and insert the following statement, replacing the UUID with yours of course:
sudo nano /etc/fstab UUID=12345678-1ABC-1CDE-1FGH-123456789012 none hfs rw,noauto
10 Replies to “Prevent automounting volumes in OS X”
Thank you for your suggestion, but I carried out the commands as per article (with my TM vol UUID), and simply exited Terminal. Restarted and the Toshiba vols still all mount.
sudo nano /etc/fstab
UUID=F92B9E9D-349F-3B57-810C-B241F93F2700 none hfs rw,noauto
I’m not familiar with Terminal, and didn’t see any way to “Save” the edited file, perhaps that was why nothing changed?
Do I now need to UNdo what I did?
CM, when you execute the first line (the line with “nano” in it (you should hit enter after typing that)), you will be brought into the nano text editor (inside the terminal program). At the bottom of that window you can see commands like “^G Get Help” and “^X Exit”. If you hit control+X, it will then prompt if you want to save the file to which you should type Y and hit enter.
As far as needing to undo anything, if you type that first line (with nano) and it brings up a blank document, then you didn’t actually do anything the first time and there is nothing to undo.
Saving in nano/pico is done using Contol+X, then [Y]es
If you jut quit terminal the file will not have been saved
I’ve got this `chmod +x` (executable) in my `~/bin/` directory.
I cannot save this file using sudo nano. I get “Error writing etc/fstab: No such file or directory” I am the only admin and should have full permissions. There is an existing file called etc/fstab.hd. Modifying that also will not let me save.
Will this will also stop automounting of drives that are plugged in while MacOS is already booted? (I have this problem when I plug in a certain phone to charge, which has a mophi space pack. Then when I unplug it without dismounting, I always get this annoying message.)
Thanks for posting this article.
Aah! I figured this out. I noticed that on my Mac, /etc/ is actually a symbolic link to /private/etc/. When I tried to save from nano, it was true that /etc/ didn’t exist. I changed this to /private/etc/ and it worked. And yes, it works to prevent automounting in all situations.
For some reason, editing / creating fstab with vi didn’t worked, the disk was still auto-mounted (MacOs 10.14.1 Mojave.
I’ve found this command on another site “sudo vifs” that edits fstab in safe mode and that did the trick.
You may wish to check this out for a more casual approach to preventing volumes from mounting : http://henri.shustak.org/tools/ejector
How does this work? I am trying to prevent the HD in aniMac from loading as it is corrupt and I am using an external disk now.
The ejector tool will un-mount a drive as soon as it is seen. If you know the drive you are not wanting to mount, then editing the fstab may be a better approach or using a tool like listed on the ejector github page. If you get stuck with ejector and really want to use it then open an issue via github.