Prevent volumes auto-mounting on Mac OS X


Pretty sure this isn't the most elegant way to do it, but setting the /Volumes directory immutable prevents volumes from auto-mounting:

% sudo chflags uchg /Volumes

Then to revert back:

% sudo chflags nouchg /Volumes% echo The Bird is The Word

Despite being an OS X user since the first 10.0 betas, I know surprisingly little about how Macs handle volumes. Put me in front of a [purely!] FreeBSD, NetBSD or Linux box and I'm set, but Mac has its own way of doing things. Of course ;).

Author bio and support


Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.