Apple - How to Disable USB Auto-mount
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.
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.
,
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