I want to disable a particular USB storage device (a sandisk flash drive). I read somewhere that you can use the .config file. How do i use it to disable that?
3 Answers
First :
You can disable it from Bios setting and make bios password protected .
Second:
You can get rid of all USB devices by disabling kernel support for USB via GRUB.
kernel /vmlinuz-2.6.18-128.1.1.el5 ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 nousb
-
the thing is i'm learning things.. so i want to see how this .config file and grub.cfg file work.. thats why i wanted to know how can i use that file to do stuff.. and i am unable to access my flash drive now..– akshayMar 6, 2014 at 9:09
Simply blacklist the kernel driver:
sudo echo "blacklist usb-storage" >> /etc/modprobe.d/blacklist.conf
After that, nobody can use a USB memory stick in that computer, but still allows the administrator(s) to manually load the module and use it.
To enable again simply remove the line from the blacklist file.
The best way is to use udev blacklisting (using the authorized feature in sysfs) so you can be very selective (since you want a specific device). You can find a very interesting article about this here
With .config you could totally disable usbstorage module but this would then make any usb storage not work anymore.
-
Actually there's been a problem. I'm not able to access any flash drive i'm insterting. When i tried insmod/modprobe usb-storage, it said FATAL: usb-storage not found! I dont even remember "rmmod"ing it!– akshayMar 6, 2014 at 6:06
-
That sounds strange. Did you recompile the kernel maybe and not install it or configure it? Well try anyway to see if there is: find /lib/modules/`uname -r`/kernel/drivers/ -name "*storage*" Mar 6, 2014 at 6:22
-
yea.. just to learn, i customized the kernel and recompiled.. i even checked in the make menuconfig.. the usb-storage is marked "m"! and for he above command its showing g_mass_storage.ko– akshayMar 6, 2014 at 8:30
-
oh and btw, when i try to insmod g_mass_storage, it says "unknown symbol in module"– akshayMar 6, 2014 at 9:07
-
g_mass_storage is for "usb gadget" which is something totally different sorry. Mar 6, 2014 at 10:02