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:
- Open a terminal window and become the root user by typing:
sudo su
- Open the
modprobe
configuration file/etc/modprobe.d/blacklist.conf
in a text editor:nano /etc/modprobe.d/blacklist.conf
- 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. - Save and exit the file.
- To make the change take effect immediately, unload the
usb-storage
module by typing:modprobe -r usb-storage
- 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
. - 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.