MacOS – Need to disable USB Mass Storage devices on macOS Sierra +

high sierramacosterminalusb

All the way through El Capitan, the way this used to work, in the Terminal, was:

sudo kextunload /System/Library/Extensions/IOUSBMassStorageClass.kext
sudo mv /System/Library/Extensions/IOUSBMassStorageClass.kext ~/backup
sudo touch /System/Library/Extensions/
sudo reboot

In Sierra and High Sierra, it appears that the IOUSBMassStorageClass kernel extension is no longer loaded, and instead, the IOUSBMassStorageDriver is loaded. Running kextstat | grep USBMass reveals this. If I try to unload the IOUSBMassStorageClass kernel extension, I get the following error:

(kernel) Can't remove kext com.apple.iokit.IOUSBMassStorageDriver; services failed to terminate - 0xdc008018.
Failed to unload com.apple.iokit.IOUSBMassStorageDriver - (libkern/kext) kext is in use or retained (cannot unload).

Some additional pieces of information:

  1. This workstation is a standalone machine, and is not part of a macOS Server-managed installation. As such, I do not have access to Profile Manager. However, if I can install server somewhere else, export a profile, and load it to this workstation in the Terminal, that is an acceptable solution.

  2. Use of a third-party endpoint manager application is prohibited.

  3. This workstation is remote, and so physical access to it is not an option. The preferred method of configuration is in Terminal through ssh. Remote Desktop is available, if need be.

  4. I have verified that System Integrity Protection has been disabled on this workstation.

Thanks in advance!

Best Answer

According to this thread it seems like is an Apple problem since MacOS Sierra. Several users reported this problem and even a bug report has been generated.

Hope this can help you.