Block USB completely

From Notes_Wiki
Revision as of 10:18, 8 November 2015 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb>Blocking USB ports in Linux</yambe:breadcrumb> =Block USB completely= ==Block by disabling kernel module usb_storage== To block USB by disabling kernel mod...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb>Blocking USB ports in Linux</yambe:breadcrumb>

Block USB completely

Block by disabling kernel module usb_storage

To block USB by disabling kernel module use following steps:

  1. See if any usb_storage device is already in use using: "lsmod | grep usb"
    The last number displayed should be 0 such as:
    usb_storage 49100 0
    Or there would be no output line, which is also perfectly fine.
  2. In case a line was displayed with non-zero number, umount devices till number is zero. Then remove kernel module using:
    rmmod usb_storage
    Do not worry we are not deleting the module, just removing it from current kernel temporarily.
  3. To disable auto insertion of usb_storage module use:
    echo 'install usb-storage :' > /etc/modprobe.conf
    Note that kernel module has hypen(-) in filename and underscore(_) when detected. Please type - or _ appropriately as suggested here.
    Ignore "WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/" warnings

Enable kernel-module manually as root

To enable kernel module manually as root use:

  1. insmod /lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko
  2. "lsmod | grep usb" and verify module is avialable
  3. Use the USB device and then umount / disconnect it
  4. "lsmod | grep usb" and verify that count of devices is 0 (Last number)
  5. rmmod usb_storage


Disabling USB in BIOS

USB can be disabled in BIOS, but then password-protect BIOS. Also remember this password properly as resetting BIOS password would require motherboard jumper configuration (or removal of CMOS battery)


Disable USB via GRUB

To disable USB via GRUB add parameter 'nousb' at end of kernel parameters. This requires reboot.

Many steps learned from http://www.cyberciti.biz/faq/linux-disable-modprobe-loading-of-usb-storage-driver/



<yambe:breadcrumb>Blocking USB ports in Linux</yambe:breadcrumb>