Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Control loading of kernel module automatically

Writer Andrew Mclaughlin

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

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

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` .

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy