Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to be able to serve a section of my box's file system over USB to another computer. For example, if the files are on box A and I am reading from box B, then B would mount A, see those files, and mount them as a file system device (ie., like a thumb drive).

Ideally the solution would work for any Linux distro, but I will most likely be running this on Debian variants.

Please let me know if you need any more info. Cheers.

share|improve this question
3  
You can't just connect two computers with a USB cable — the USB electrical protocol is not symmetric and requires a computer at one end and a peripheral device at the other end (that's why the plugs aren't the same). Do you already have a specific hardware gadget you want to use? Otherwise Ethernet (or Firewire) would be better adapted, to create a network between the two computers. –  Gilles Oct 3 '10 at 23:09
1  
@Gilles - Thanks for the reply. From your answer, I guess my question is really how to make my computer look and/or act like a peripheral device over its USB connection/hub. What separates a peripheral device and a host machine? Cheers. –  Sam Bisbee Oct 3 '10 at 23:15
add comment

4 Answers 4

From the information you've given, I surmise that:

  1. You have a black box device which you can communicate with only by plugging a USB mass storage device into it.
  2. Physically plugging and unplugging a USB drive is not acceptable, you won't have physical access after deployment.

If any of these assumptions is false, you'll have an easier time.

What you're looking for is a way to make a computer appear as a USB storage device. In principle, this shouldn't require much electronics — I think the right gadget could be mass produced for no more than a couple USD plus shipping. But I can't find a reference to the right gadget existing.

Merely using a USB computer-to-computer cable won't do the trick: these simulate an Ethernet network, and the black box doesn't speak Ethernet. And USB-storage-to-LAN converters won't help, they go the wrong way round.

  1. You could design a robot arm that unplugs a USB stick from the black box and plugs it into a computer. Now that the obvious but impractical suggestion has been made...

  2. You could have the gadget designed, and write a driver for it. But this might be out of your price range, especially if you don't need millions of units.

  3. There may be a sophisticated NAS device that can talk to several computers over iSCSI and USB (those last two words are the difficult part).

  4. Some mobile phones and PDAs can act as a USB storage device, and additionally have a GSM, wifi or Ethernet connection. But they often act as storage devices only when switched off, so I don't know if there is one that could be used as a bridge or server.

  5. Here's a discussion about a somewhat similar requirement. The only possible solution it suggests is this USB-storage-to-wifi bridge, which looks like it would be suitable — but it's expensive.

  6. There are USB switches (a.k.a. sharing hubs) that allow you to share a USB device between two computers. You could use one to share a storage device between the black box and a computer. The problem is that they usually require the user to press a button to switch between the two devices — but if you find one where the switch can be controlled remotely, you have a solution.

share|improve this answer
    
Thank you for your very thoughtful response Gilles. You are correct in your assumptions. The PDA/mobile bridge is a very cool idea that I will have to put some more thought into. The other ideas, which seem to be mostly LAN or robot focused, are out of the question because there is no LAN in the environment. I am going to try putting together some POCs and will report back in a day or two. Thanks again! –  Sam Bisbee Oct 5 '10 at 15:34
add comment

I think this can be accomplished with a host-to-host USB cable and the Linux usbnet driver. Hardware compatibility and details on how to set this up in Linux are given at: http://www.linux-usb.org/usbnet/

share|improve this answer
2  
That's Ethernet over USB, which is fine if the device supports it... but I get the impression it doesn't. –  Gilles Oct 4 '10 at 18:37
    
@Gilles - You are correct, I do not think the black box speaks Ethernet. That being said, the black box might still pick up and work some magic if it simply detects that there's a USB connection (via the A-to-A cable). Will be finding out in a day or two. Cheers. –  Sam Bisbee Oct 5 '10 at 15:36
    
Well, I guess that at least the devices listed on the driver page should support it... –  Riccardo Murri Oct 5 '10 at 15:40
add comment

I don't really see how USB fits in here? Why don't you use SAMBA or NFS to share the files between those machines? Maybe that doesn't work for some reason, so you should probably add a little more explanation...

share|improve this answer
    
Those protocols won't work, because the reader machine isn't networking enabled. The only I/O point that I have to it is USB, which it watches and reads files off of. In the final, non-test environment I won't be able to control the reader machine (I don't even know its software), but it will take my files. Thanks! –  Sam Bisbee Oct 3 '10 at 22:59
add comment

Even if you solve the USB specific issues like making a USB host look like a USB device, you'll run into problems mounting the filesystem on two different devices at the same time.

If Box A has a drive (let's say /dev/sdb1) and it's mounted and using the files on /dev/sdb1, what happens when Box B mounts wants access to those files? At the lowest level, USB is going to want to expect to deal with a device, not a filesystem.

share|improve this answer
2  
If the hardware issue is solved, there's probably a way to put an access lock so that only one side can write at a time and that read accesses get a consistent view. Some solutions will only allow one computer to access the storage anyway. So yes, this is a concern, but not an overwhelming one. –  Gilles Oct 4 '10 at 20:34
    
It's going to be awfully tough to do this without mounting and unmounting the filesystem on Box A while accessing it on Box B (and vice-versa). Most normal (non-cluster aware) filesystems have every right to assume that the on disk bits they have mounted do not change underneath them. A bunch of in-memory structures will be out of sync. You either need to mount/unmount when switching between A and B, or get the cooperation of (i.e. write a new filesystem) the filesystem driver on Boxes A and B. –  kbyrd Oct 11 '10 at 2:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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