Walker News

How To Load And Remove Linux USB Mass Storage Driver?

On Linux, the modprobe command allows user dynamically loads and unloads Linux kernel modules, i.e. one can easily add and remove Linux device driver (e.g. USB mass storage driver) without having to reboot the system.

What’s a Linux kernel module? Simply put, it’s a program (e.g. driver) that can be added to and removed from Linux kernel upon demand to extend the kernel functionality. These programs are usually kept in /lib/modules/$(uname -r) folder and ended with .ko file extension.

Now, let’s say you’ve previously disabled or turned off Linux mass storage device and now you desperately need to use an USB drive for file transfer. So, how can you load the Linux USB mass storage driver without reboot the server or disrupt connecting users?
On RHEL 5.2, the Linux kernel automatically detects and mounts an USB drive upon plug in, just like Windows, unless the driver is disabled.

Here is the trick:

1. Login as root and undo the change made to disable USB mass storage driver, i.e. edit /etc/modprobe.d/no-usb file and use “#” to remark (comment out) the “install usb-storage” line, e.g.:
#install usb-storage /bin/true

2. Execute this command to load usb-storage.ko into kernel:
modprobe usb-storage

To confirm the kernel module has loaded successfully, you can use these commands to check:
[walker@test] tail /var/log/messages
May 9 00:16:38 test kernel: Initializing USB Mass Storage driver...
May 9 00:16:38 test kernel: usbcore: registered new driver usb-storage
May 9 00:16:38 test kernel: USB Mass Storage support registered.
[walker@test] lsmod | grep -i usb
usb_storage            76577  0
scsi_mod              134605  11 usb_storage,megaraid

Now, plug in the USB drive to do file transfer. When it’s done, you can unload / remove USB mass storage driver using this command:
modprobe -r usb-storage

Next, remove the “#” character that’s used (step-1) to comment out the line in /etc/modprobe.d/no-usb file, if the driver has to be disabled.

Custom Search

2018  •  Privacy Policy