0

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?

1
  • This sounds like an X-Y Problem. What are you actually trying to achieve? If you want to ban specific device ID for its security impact an attacker could always use a different device with the same functionality. Dec 24, 2017 at 0:33

3 Answers 3

1

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
1
  • 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..
    – akshay
    Mar 6, 2014 at 9:09
0

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.

0

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.

7
  • 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!
    – akshay
    Mar 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*"
    – fede.evol
    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
    – akshay
    Mar 6, 2014 at 8:30
  • oh and btw, when i try to insmod g_mass_storage, it says "unknown symbol in module"
    – akshay
    Mar 6, 2014 at 9:07
  • g_mass_storage is for "usb gadget" which is something totally different sorry.
    – fede.evol
    Mar 6, 2014 at 10:02

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