Linux Disable USB Devices (Disable loading of USB Storage Driver)

To disable USB storage devices on a Linux system, you can prevent the usb-storage driver from loading. This will prevent USB mass storage devices (such as USB flash drives or external hard drives) from being recognized by the system. Here are the steps to do this:

  1. Open a terminal window and become the root user by typing:
    sudo su
  2. Open the modprobe configuration file /etc/modprobe.d/blacklist.conf in a text editor:
    nano /etc/modprobe.d/blacklist.conf
  3. Add the following line to the end of the file:
    blacklist usb-storage

    This will prevent the usb-storage driver from loading when the system starts up.

  4. Save and exit the file.
  5. To make the change take effect immediately, unload the usb-storage module by typing:
    modprobe -r usb-storage
  6. To prevent the usb-storage module from loading in the future, add it to the list of modules to be blacklisted in the file /etc/modprobe.d/blacklist.conf.
  7. To re-enable USB storage devices, remove the line containing blacklist usb-storage from the file /etc/modprobe.d/blacklist.conf, or comment it out by placing a # character at the beginning of the line.

That’s it! The usb-storage driver is now disabled, preventing USB storage devices from being recognized by the system. Note that other USB devices (such as keyboards and mice) will still work normally.

Leave a Comment