2

When i do rmmod usb_storage and then dmesg i can see the output saying usb_storage deregistered. But when i attach a flash drive and then dmesg , it says

Initializing USB Mass Storage driver...
[16565.129239] scsi41 : usb-storage 1-1:1.0
[16565.130134] usbcore: registered new interface driver usb-storage
[16565.130172] USB Mass Storage support registered.

How do i manually insert/remove the module without it automatically getting loaded?

2 Answers 2

1

Just blacklist the kernel driver:

echo "blacklist usb-storage" | sudo tee -a /etc/modprobe.d/blacklist.conf

After that, nobody can use a USB flash drive in your system.

You'll have to manually "insmod" your driver with sudo to use USB devices again or if you want to restore the initial behaviour remove the module from the blacklist file.

0
0

To add to the above answer @Syivain Pineau, whenever a module is blacklisted , it can still be added and removed using insmod and rmmod respectively. But for insterting you need to be there in the source location for e.g. to insert usb-storage, after removing it, you should run insmod usb-storage atlinux/driver/usb/storage` .

You must log in to answer this question.

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