0

I have a custom NAS built from a CentOS 6.5 baseline. I need the storage of this NAS to be accessible via its USB port. I cannot use the network connection. My cell phone can do this, there has to be a way to make a Linux box do this. I found the following similar question: Can I make a USB port on my Linux computer look like a mass storage device? which essentially says you can't do this, claiming that the USB device would have to be in client mode. This does not make sense, the request is actually for a different implementation/handling of server mode. Clearly driver modification of some sort is required, and I am guessing that there are External Drive bays out there using BusyBox or something similar that already do this, but I am not finding explicitly what is required to get this done.

closed as unclear what you're asking by jasonwryan, Rui F Ribeiro, Kiwy, slm Apr 12 '18 at 18:21

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Could you please try to explain simply your goal and what you've try and what is not working as expected ? Also could you try to rephrase because it's clear what you're asking for ... – Kiwy Apr 12 '18 at 12:30
2

USB was originally designed with a star-like topology: at the center, there is a host controller that manages the whole bus. From there, connections go outward to devices and hubs, and both of those will need the host controller to manage them or no traffic will happen. Essentially, the host controller is the master and all the other things on the bus are slaves.

Changing just the software is not enough: the host controller has a different kind of USB interface chip than any of the slave devices, and a host controller would need hardware changes to act as a slave device.

With the advent of smartphones and other mobile devices, this was found problematic, and USB-On-The-Go specification was developed. With it, a concept of dual-role devices was introduced: this required modified host controller chips that could support both master and slave roles, and a new sub-protocol to negotiate switching the master role from one device to another.

Unfortunately, the host controller chips with the USB-On-The-Go features tend to be used only in smartphones, tablets and other mobile devices, not on desktop and server motherboards.

If your NAS had the USB port hardware that had the capability to act as a slave device, then the matter would be fairly simple: the Linux kernel already has support for device-side USB too (as opposed to the more usual host-side support). However I don't think CentOS 6.x has these features enabled, so you might have to compile a custom kernel with the "USB Gadget Support" subsystem enabled. Within that subsystem, you would have to enable the specific driver for your device-side USB hardware, and the device-side driver for the USB Mass Storage protocol.

Unfortunately there seem to be no interface standards like UHCI/OHCI/EHCI/XHCI on the device side: all device-side controller chip designs seem to be unique snowflakes and you'd have to know exactly which chip is used in your NAS.

Once the driver issue was resolved, there is one more technical problem: the USB mass storage access is a low level protocol accessing individual blocks on the storage device, much like SATA; not at the level of files like NFS. As a result, the NAS device would have to stop sharing and unmount any storage it presents over USB, since the system accessing it would assume it has full control of the filesystem of the USB storage, and would treat any changes made by the NAS device itself or by any other devices accessing the NAS over the network at the same time as filesystem corruption.

One way to overcome this problem would be to run a cluster filesystem on the USB-shared storage. A cluster filesystem (like GFS or OCFS2) is designed for this kind of multiple access, but it requires all participating systems to cooperate and communicate with each other. This adds quite a bit of extra complexity. Another way would be to not use the USB Mass Storage protocol, but instead use USB MTP (Media Transfer Protocol) or its simpler version, PTP (Picture Transfer Protocol) - both of those work at the file level, not at the block level like USB Mass Storage. That would allow the NAS to maintain overall control of the shared filesystem while the USB sharing is active, and so would allow it to keep sharing the filesystem over the network at the same time.

0

If the USB hardware of your NAS supports working in USB client mode, you could use the Linux-USB Gadget API Framework (or something based on it).

Not the answer you're looking for? Browse other questions tagged or ask your own question.