Prevent Automounting on macOS
With huge external drives being far more affordable these days I usually have one hooked up permanently to my laptop dock for Time Machine. But I don’t need all that space dedicated to backup, so it gets chopped up into a backup partition, an encrypted APFS storage container and a bunch of 20 GB partitions which hold a bootable macOS backup, plus a couple of recent macOS installers – just in case I end up having a really bad day.
However, in common with many Mac users I’m sure, I can’t be dealing with all that clutter on the desktop or Finder sidebar when so many partitions are mounted. What a mess! Luckily,
/etc/fstab is still a thing you can use in macOS Mojave, so there’s a quick and easy way to prevent these emergency-use volumes from mounting automatically.
First of all, plug in the drive and let everything mount, then fire off a
diskutil list in Terminal. You’ll see all of your drives and their identifiers. In my example the external drive shows up as disk2 with various partitions being disk2s1, disk2s2, etc.