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?
Asked
Active
Viewed 1,575 times
0
-
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. – David Foerster Dec 24 '17 at 00:33
3 Answers
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

nux
- 38,017
- 35
- 118
- 131
-
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 06 '14 at 09:09
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.

fede.evol
- 121
- 2
-
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 06 '14 at 06: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 06 '14 at 06: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 06 '14 at 08:30
-
oh and btw, when i try to insmod g_mass_storage, it says "unknown symbol in module" – akshay Mar 06 '14 at 09:07
-
g_mass_storage is for "usb gadget" which is something totally different sorry. – fede.evol Mar 06 '14 at 10:02
-
-
i used "make-kpkg clean fakeroot make-kpkg --initrd --append-to-version=-QD kernel-image kernel-headers" – akshay Mar 07 '14 at 04:36
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.

Maythux
- 84,289