Can I disable auto-mounting of *all* external USB-connected storage media? [duplicate]

I use VirtualBox on my MBP and often need to mount my USB flash drive inside the guest. The problem I'm running into is that the host OS (OS X Mavericks) immediately mounts the USB flash drive when I insert it. When I try to unmount it (gracefully, through Finder), OS X complains that the device is in use. Further research into lsof reveals that Spotlight and AVG are doing their thing with the flash drive.

Rather than fiddling with individual app settings, I'd like to just modify the host OS behavior so that the USB device doesn't auto-mount. Any suggestions?


According to Topher Kessler article on CNET, you can add an entry to /etc/fstab, specifying the noauto option.

Such an entry might look like this:

UUID=791E37B4-82A3-37E7-9F15-3C39359126B4   none  hfs  rw,noauto

The UUID may be obtained by looking for the Volume UUID line that is printed when you run diskutil info /Volumes/volume name.


OS X has a mechanism, called the Disk Arbitration framework, through which programs can control what happens when disks are inserted or ejected. It also provides an opportunity to intercept a disk insertion event and prevent the usual automatic mounting behaviour.

To change the behaviour, though, requires a third-party utility, since the Disk Arbitration framework is just a programming interface. One good utility is Disk Arbitrator, a free (BSD-licensed) tool by Aaron Burghardt.

Screenshot of Disk Arbitrator

While Disk Arbitrator is running, you can choose to either veto the mounting of newly inserted disks, mount them read-only, or just let the normal automatic mounting happen. After Disk Arbitrator exits, the normal mounting behaviour is restored.


I think that modifying fstab to turn off automount is a bit excessive for what you are trying to do. It's sort of like removing the doors on your car because every now and then you need to get in or out.

For this, I would use VirtualBox's built in USB Filters. This allows you to automatically mount a particular USB device upon insertion. You can find the USB filters under the "Settings" menu of the particualr VM you wish to assign it to.

For instance, my USB devices are are listed below that are available if I want to automatically attach it to my Windows 10 Pro VM. I can attach my Seagate FreeAgent Go, or my SanDisk Cruzer or any of the attached USB devices. However, attaching the Logitech USB receiver would ultimately make the mouse inoperable on the host, so be careful what you attach.

enter image description here,

How do I know this works? Well, I accidentally attached a FreeAgent Go drive and it wouldn't (as I perceived) mount in OS X. See my original "problem": USB Drive Will Not Mount, Not Listed in Disk Utilities, but Found In System Profiler

It does it by serial number or by UUID (I haven't investigated enough to figure out which) but I had several FreeAgent Go drives of the exact same model and size and only one was auto attaching to the VM. At the time, I thought my drive had gone bad.

The bottom line is that automount still worked, and I was able to attach a USB device directly to a VM without having to go through the trouble of unmounting it first


This is how I disable auto mounting of APFS volumes on macOS Catalina.

For macOS volumes, both Macintosh HD - Data and Macintosh HD type volumes need to be referenced in /etc/fstab.

Find volume(s) using diskutil list and set VOLUME_PATH accordingly.

# Disable auto mounting of "macOS - Data" volume
VOLUME_PATH="/Volumes/macOS - Data"
VOLUME_UUID=`diskutil info "$VOLUME_PATH" | awk '/Volume UUID:/ { print $3 }'`
cat << EOF | sudo tee -a /etc/fstab
UUID=$VOLUME_UUID none apfs rw,noauto
EOF

# Disable auto mounting of "macOS" volume
VOLUME_PATH="/Volumes/macOS"
VOLUME_UUID=`diskutil info "$VOLUME_PATH" | awk '/Volume UUID:/ { print $3 }'`
cat << EOF | sudo tee -a /etc/fstab
UUID=$VOLUME_UUID none apfs rw,noauto
EOF

Here is what is going when running above commands:

Set VOLUME_PATH variable to /Volumes/macOS - Data

VOLUME_PATH="/Volumes/macOS - Data"

Set VOLUME_UUID variable to volume UUID of /Volumes/macOS - Data volume

Running diskutil info "$VOLUME_PATH" outputs volume details of /Volumes/macOS - Data (which includes its UUID).

Piping (|) these details to awk '/Volume UUID:/ { print $3 }' extracts the UUID.

VOLUME_UUID=`diskutil info "$VOLUME_PATH" | awk '/Volume UUID:/ { print $3 }'`

Append UUID=$VOLUME_UUID none apfs rw,noauto to /etc/fstab and output to console (see tee)

cat << EOF | sudo tee -a /etc/fstab
UUID=$VOLUME_UUID none apfs rw,noauto
EOF