trio.so
How-Tos

How to Disable USB Ports and Block USB Storage on Windows, Mac and Linux

How to disable USB ports or block USB storage on Windows, Mac and Linux: Group Policy, registry, MDM, BIOS and USBGuard, with keyboards still working.

Mountain landscape representing leadership perspective and vision
Written by
Atena Ladchartabi

Content writer, trio.so

Published on
Modified on

Most of the time you do not need to disable USB ports at all: you need to block USB storage, so flash drives and external disks stop working while keyboards, mice, headsets and security keys keep working. On Windows, turn on the Group Policy setting "All Removable Storage classes: Deny all access" (under Computer Configuration, Administrative Templates, System, Removable Storage Access) or push the same setting from an MDM. On a Mac there is no built-in switch; use an MDM restriction (the Disk Management setting on macOS 15 and later) or an endpoint security tool. On Linux, stop the usb-storage and uas kernel modules from loading, or use USBGuard to allow only approved devices. Turning ports off completely, in Device Manager, the BIOS or with physical locks, is for kiosks and high-security machines.

If one laptop needs locking down today, jump to your operating system below; if an audit asked you to stop data leaving through USB drives on every PC, the best practices and fleet sections are for you.

Why disable USB ports? Block storage, not everything

USB drives are one of the simplest ways for data to leave a company and for malware to come in. A file copied to a flash drive bypasses email filters and cloud sharing controls, and a drive found in a car park and plugged in by a curious employee is still a working attack. Preventing USB data exfiltration is a common audit finding, and a frequent reason teams look for this guide.

It helps to separate two jobs before you change anything:

  • Block USB storage. Flash drives, external disks, memory card readers and phones mounted as drives stop working. Keyboards, mice, webcams, headsets, docks and security keys keep working. This is what most organizations need.
  • Disable the ports. Nothing works through USB at all. This also breaks keyboards, mice, docks and USB security keys, and on many laptops charging. It suits kiosks, lab machines and locked-down terminals, not everyday laptops.

Both can be undone, but test on one machine first. The quickest way to cause a support ticket is to disable the ports on a desktop whose keyboard is USB.

How to disable USB storage on Windows

Method 1: Group Policy (Windows Pro, Enterprise and Education)

Group Policy is the cleanest way to block USB storage on Windows because it covers every removable storage class and leaves other USB devices alone.

  1. Press Windows + R, type gpedit.msc and press Enter (for a domain, edit a Group Policy Object in Group Policy Management instead).
  2. Go to Computer Configuration > Administrative Templates > System > Removable Storage Access.
  3. Open All Removable Storage classes: Deny all access, select Enabled and click OK.
  4. Run gpupdate /force, then unplug and reconnect any drive to check it is blocked.

The setting takes precedence over the individual removable storage settings in the same folder. If you want read-only instead of a full block, leave it off and enable Removable Disks: Deny write access instead, which lets users open files from a drive but not copy anything to it. The same settings exist under User Configuration if you want them to apply to certain users rather than the whole computer.

Windows Home has no Group Policy Editor. Use the registry method below or an MDM.

Method 2: The registry (USBSTOR)

The USB mass storage driver can be stopped from loading by changing its start value. Run this in an elevated Command Prompt or PowerShell:

reg add "HKLM\SYSTEM\CurrentControlSet\Services\USBSTOR" /v Start /t REG_DWORD /d 4 /f

4 disables the driver; set it back to 3 to allow USB storage again. Reconnect the drive or restart for it to take effect. Two limits to know: many newer fast USB drives use the USB Attached SCSI driver (UASPStor) instead of USBSTOR, so this method alone may not block them, and anyone with admin rights can change the value back. The Group Policy setting avoids the first problem, and taking local admin rights away from users avoids the second.

Method 3: Device Manager (disables the ports, not just storage)

In Device Manager (devmgmt.msc), expand Universal Serial Bus controllers, right-click a USB Root Hub or host controller and choose Disable device. Every device on that controller stops working, including keyboards and mice, and a Windows update or a driver reinstall can turn it back on. Use it only for a single machine where you want the ports dead and have another way to control it.

Method 4: Exceptions for approved drives

If some people must use USB drives, Windows can allow specific devices while blocking the rest. Under System > Device Installation > Device Installation Restrictions, the policies to prevent installation of devices not described by other settings, and to allow devices that match given device IDs, let you approve particular drive models. Endpoint security products with device control can go further and allow individual drives by serial number. Pair any exception with encrypted drives, for example BitLocker To Go.

How to disable USB storage on a Mac

macOS has no setting in System Settings that blocks USB drives. Your options:

  • An MDM restriction. On macOS 15 and later, Apple's Disk Management settings let an MDM set external storage to allowed, read-only or disallowed on supervised Macs. Disallowed stops the Mac from mounting USB drives at all; read-only lets users open files but not copy to the drive. Older macOS versions relied on configuration profile restrictions that Apple has been phasing out, so check what your MDM supports for each version.
  • An endpoint security or DLP tool. Several endpoint protection and data loss prevention products block or allow USB storage on Macs, often with per-device exceptions.
  • Accessory security on Apple silicon. On Apple silicon laptops running macOS Ventura or later, System Settings > Privacy & Security > Allow accessories to connect makes the Mac ask before a new USB or Thunderbolt accessory connects. It stops unknown devices connecting to a locked Mac, but it does not block a drive the user chooses to allow, so it is not a storage block.

The iPhone and iPad equivalent, which stops accessories connecting while the device is locked, is covered in USB Restricted Mode.

How to disable USB storage on Linux

Method 1: Stop the USB storage modules from loading

USB drives on Linux use the usb-storage kernel module, and many newer drives use uas. A blacklist line alone only stops automatic loading; an install line stops the module from loading at all. Create a file in /etc/modprobe.d/:

# /etc/modprobe.d/disable-usb-storage.conf
install usb-storage /bin/false
install uas /bin/false
blacklist usb-storage
blacklist uas

Then unload the modules if they are already loaded (unplug any drives first), and rebuild the initramfs so the rule applies at boot:

sudo modprobe -r uas usb-storage
sudo update-initramfs -u    # Debian and Ubuntu
sudo dracut -f              # Fedora and RHEL

Keyboards and mice use different modules, so they keep working. Remove the file and rebuild the initramfs to undo it.

Method 2: USBGuard, to allow only approved devices

USBGuard blocks every USB device that is not on its allow list, which makes it the Linux tool for "these devices only". Generate a policy from the devices plugged in now, so your keyboard and mouse are allowed, before you start the service:

sudo apt install usbguard          # or: sudo dnf install usbguard
sudo sh -c 'usbguard generate-policy > /etc/usbguard/rules.conf'
sudo systemctl enable --now usbguard
usbguard list-devices              # shows allowed and blocked devices

New devices are then blocked until you add a rule for them. Starting USBGuard without generating the policy first can lock out a USB keyboard.

Method 3: Turn off one port for now (sysfs)

For a quick, temporary block of one device or port, write 0 to its authorized file, for example echo 0 | sudo tee /sys/bus/usb/devices/2-1/authorized (find the path with lsusb -t). It does not survive a reboot, so it is for testing, not policy. For user management on the same machines, see Linux user management best practices.

Hardware methods: firmware settings and port locks

  • BIOS or UEFI. Most business PCs let you disable USB ports, or just booting from USB, in the firmware settings. Set a firmware password so users cannot turn them back on. Disabling USB boot is worth doing on almost every PC, because it stops someone booting another operating system to copy the disk.
  • Physical port blockers. Lockable plugs that need a key to remove. They suit kiosks, reception PCs and lab machines where you want ports visibly closed.
  • Locked enclosures. For public terminals, keep the computer in a cabinet with only the keyboard and screen reachable.

Best practices for USB restrictions

  1. Block storage, keep peripherals. Use the storage policies above rather than turning off ports, unless the device is a kiosk.
  2. Test with what people actually plug in. Keyboards, mice, docks, webcams, headsets, card readers and USB security keys such as YubiKeys.
  3. Give people another way to move files. Approved cloud sharing, or encrypted company drives for the few who need them. Without an alternative, people find workarounds.
  4. Remove local admin rights. Any user who is an administrator can undo a registry change or a module block.
  5. Write it down. Put the rule and the exception process in a policy, so the help desk can answer "why does my drive not work?" quickly.
  6. Treat it as one layer. USB control works alongside data loss prevention, disk encryption and broader endpoint hardening; it does not replace them.

How to enable USB ports blocked by an administrator

Reverse whichever method was used: set the Group Policy setting back to Not Configured, set the USBSTOR start value to 3, remove the Linux modprobe file, or re-enable the controller in Device Manager. If your company manages the device, the setting comes from IT and will come back after the next policy refresh, so ask IT for an exception rather than changing it yourself.

Managing this across many devices

Changing Group Policy on a domain works for PCs that reach a domain controller; laptops that never come to the office need the setting pushed another way. trio.so blocks USB drives and other removable storage on Windows PCs with a removable storage policy, and blocks USB storage on Linux devices with its restrictions policy, so one setting reaches every enrolled machine. See policy management.

The trio.so Create policy wizard for a Windows removable storage restriction policy named Block USB drives on office PCs, with Block all removable storage turned on.
In trio.so, one removable storage policy blocks USB drives on enrolled Windows PCs.

Related reading: enabling Remote Desktop with Group Policy and data loss prevention.

Ready-to-use Templates

Must-have Template Toolkit for IT Admins

Explore All
Template Toolkit

Block USB drives on every PC at once

trio.so blocks USB drives and other removable storage on Windows PCs with one policy.

Start free trial

Manage Every Device From One Console

trio.so brings device management, patching and security policies for Windows, macOS, Linux, iOS/iPadOS and Android into one console. Enroll a device and see it in the console within minutes.

14-day free trial. No credit card required.

trio.so brings device management, patching and security policies for Windows, macOS, Linux, iOS/iPadOS and Android into one console. Enroll a device and see it in the console within minutes.

Smiling womanAbstract geometric patternAbstract geometric patternSmiling womanSmiling woman

Frequently Asked Questions (FAQ)

Yes, in the BIOS or UEFI settings or in Device Manager, but that also stops USB keyboards, mice and docks. Usually it is better to block only USB storage with Group Policy, an MDM or, on Linux, by blocking the storage modules.

On Windows, enable "All Removable Storage classes: Deny all access" in Group Policy. On Linux, block the usb-storage and uas modules. On a Mac, use an MDM's external storage restriction. All three leave keyboards and mice working.

Open Group Policy, go to Computer Configuration, Administrative Templates, System, Removable Storage Access, and enable "All Removable Storage classes: Deny all access". Run gpupdate /force to apply it.

macOS has no built-in switch. Use an MDM restriction (the Disk Management setting on macOS 15 and later can set external storage to read-only or disallowed on supervised Macs) or an endpoint security tool that controls USB storage.

Undo the setting that blocked them (Group Policy, registry, Device Manager or BIOS). On a company-managed device, ask IT: the setting is enforced by policy and will return if you change it locally.

Related

From the blog

The related industry news, interviews, technologies, and resources.