How to disable USB Storage Devices on CentOS/RHEL 7?
How to disable USB Storage Devices on CentOS/RHEL 7 ?
The USB storage drive automatically detects USB flash or hard drives. You can easily force and disable USB storage devices under any Linux distribution. The modprobe program used for automatic kernel module loading and can be configured to not load the USB storage driver upon demand. This will prevent the modprobe program from loading the usb-storage module, but will not prevent root (or another program) from using the insmod program to load the module manually.
There are total four ways to do it,
1. Disable by BIOS
Disable USB from system BIOS configuration option. Make sure BIOS is password protected.
2. Type the following command:
# echo 'install usb-storage /bin/true' >> disable-usb-storage.conf
You can also remove USB Storage driver, enter:
# ls /lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko
# mv /lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko /root
3. Create a block list file and add below entry:
# vi /etc/modprobe.d/blacklist.conf
blacklist usb-storage
4. By Grub option
You can get rid of all USB devices by disabling kernel support for USB via GRUB. Open grub.conf or menu.lst (Under Debian / Ubuntu Linux) and append "nousb" to the kernel line as follows:
# vi //boot/grub2/grub.cfg
linux16 /vmlinuz-3.10.0-957.10.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_IN.UTF-8 nousb
Save and close the file. Once done just reboot the system:
# reboot
The USB storage drive automatically detects USB flash or hard drives. You can easily force and disable USB storage devices under any Linux distribution. The modprobe program used for automatic kernel module loading and can be configured to not load the USB storage driver upon demand. This will prevent the modprobe program from loading the usb-storage module, but will not prevent root (or another program) from using the insmod program to load the module manually.
There are total four ways to do it,
1. Disable by BIOS
Disable USB from system BIOS configuration option. Make sure BIOS is password protected.
2. Type the following command:
# echo 'install usb-storage /bin/true' >> disable-usb-storage.conf
You can also remove USB Storage driver, enter:
# ls /lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko
# mv /lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko /root
3. Create a block list file and add below entry:
# vi /etc/modprobe.d/blacklist.conf
blacklist usb-storage
4. By Grub option
You can get rid of all USB devices by disabling kernel support for USB via GRUB. Open grub.conf or menu.lst (Under Debian / Ubuntu Linux) and append "nousb" to the kernel line as follows:
# vi //boot/grub2/grub.cfg
linux16 /vmlinuz-3.10.0-957.10.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_IN.UTF-8 nousb
Save and close the file. Once done just reboot the system:
# reboot
interesting sharing. Thanks this information is very useful me.
ReplyDeletehard drive data recovery hardware