Summary note: to bind and unbind use the following commands – unbinding will hide the device from “cat /proc/partitions” and the system. The system normally binds the devices automatically, however you can manually unbind the driver from a device (thus making it disappear from “cat /proc/partitions” and the rest of the system), you can make it reappear by binding the driver again.
Kossboss Note: the article shows several methods to find the device ID,.Another way to get that id, that I found is simpler: dmesg | egrep -i “usb” if your looking for usb storage devices – also another note they used a device called “ub” however it could also be “usb-storage” like this, or any other device for that matter
# TO GET ID: dmesg | grep "usb" # TO BIND (attach device to driver - unhide from system): echo -n "1-1:1.0" > /sys/bus/usb/drivers/usb-storage/bind # TO UNBIND (unattach device from driver - hide from system): echo -n "1-1:1.0" > /sys/bus/usb/drivers/usb-storage/unbind # Examples of other drives in /sys/bus/usb/drivers location: # hub, usb, usbfs, usbhid, usblp, usb-storage # the usb-storage driver is the one we need for USB storage lots of the time # All of which are directories which contain files "bind" and "unbind" (Also a bunch of other driver specific files)
When unbinding/hiding: all partitions and devices associated with the device/driver will now be invisible in cat /proc/partitions and the system. When binding/unhiding: all partitions and devices associated with the device/driver will be visible in cat /proc/partitions and the system immediately (also your system might automatically mount the device, depending on udev rules)
This Article below is not written by me (infotinks), I take 0, zero, credit for it. But it is an excellent article I would like to share (just incase their site is down, I have a copy here along with the link)
Here is the link: http://lwn.net/Articles/143397/
Thanks to: Greg Kroah-Hartman for writting this on lwn.net
If the site is down here is the copy of the article as of 1/13/2014:
Manual driver binding and unbinding July 12, 2005 One new feature in the 2.6.13-rc3 kernel release, is the ability to bind and unbind drivers from devices manually from user space. Previously, the only way to disconnect a driver from a device was usually to unload the whole driver from memory, using rmmod. In the sysfs tree, every driver now has bind and unbind files associated with it: $ tree /sys/bus/usb/drivers/ub/ /sys/bus/usb/drivers/ub/ |– 1-1:1.0 -> ../../../../devices/pci0000:00/0000:00:1d.7/usb1/1-1/1-1:1.0 |– bind |– module -> ../../../../module/ub `– unbind In order to unbind a device from a driver, simply write the bus id of the device to the unbind file: and the device will no longer be bound to the driver: $ tree /sys/bus/usb/drivers/ub/ /sys/bus/usb/drivers/ub/ |– bind |– module -> ../../../../module/ub `– unbind To bind a device to a driver, the device must first not be controlled by any other driver. To ensure this, look for the “driver” symlink in the device directory: $ tree /sys/bus/usb/devices/1-1:1.0 /sys/bus/usb/devices/1-1:1.0 |– bAlternateSetting |– bInterfaceClass |– bInterfaceNumber |– bInterfaceProtocol |– bInterfaceSubClass |– bNumEndpoints |– bus -> ../../../../../../bus/usb |– modalias `– power `– state Then, simply write the bus id of the device you wish to bind, into the bind file for that driver: echo -n “1-1:1.0” > /sys/bus/usb/drivers/usb-storage/bind (infotinks note: all partitions and devices associated with it, will now be visisble in cat /proc/partitions) And check that the binding was successful: $ tree /sys/bus/usb/devices/1-1:1.0 /sys/bus/usb/devices/1-1:1.0 |– bAlternateSetting |– bInterfaceClass |– bInterfaceNumber |– bInterfaceProtocol |– bInterfaceSubClass |– bNumEndpoints |– bus -> ../../../../../../bus/usb |– driver -> ../../../../../../bus/usb/drivers/usb-storage |– host2 | `– power | `– state |– modalias `– power `– state As the example above shows, this capability is very useful for switching devices between drivers which handle the same type of device (both the ub and usb-storage drivers handle USB mass storage devices, like flash drives.) A number of “enterprise” Linux distributions offer multiple drivers of different version levels in their kernel packages. This manual binding feature will allow configuration tools to pick and choose which devices should be bound to which drivers, allowing users to upgrade only specific devices if they wish to. In order for a device to bind successfully with a driver, that driver must already support that device. This is why you can not just arbitrarily bind any device to any driver. To help with the issue of adding new devices support to drivers after they are built, the PCI system offers a dynamic_id file in sysfs so that user space can write in new device ids that the driver should bind too. In the future, this ability to add new driver IDs to a running kernel will be moved into the driver core to make it available for all buses. |