14

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?

  • If someone has a modification, awesome, but in the mean time you can use terminal to force an unmount. diskutil unmount force disk1s2 Also, if you choose a filesystem that spotlight won't index or set that drive to be excluded in Spotlight preferences, you can reduce that delay and overhead with a quick setting change. – bmike Feb 12 '14 at 18:01
  • 1
    I advise you to test Disk Arbitrator: apple.stackexchange.com/a/39360/22003 . This will protect you against Spotlight, anti-viruses and attacks. – dan Jan 29 '15 at 10:03
  • See also: apple.stackexchange.com/a/164976/22003 . – dan Jan 29 '15 at 10:11
7

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.

6

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.

1

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

0

I found a official guide at https://discussions.apple.com/docs/DOC-7942 "Prevent a volume from mounting at startup"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .