24

I want to create a USB-to-USB data transfer system in Linux (preferably Ubuntu). For this I want to use no external hardware or switch (except this cable). It's going to be like mounting a USB drive to a system, but in this scenario one of the Linux systems is going to be mounted on the other. How can I create this?

Are there any kernel modules available, given my experience with kernel programming is very basic?

  • 6
    "For this I want to use no external hardware or switch." You cannot do this on any system period, if you mean you want to use a plain USB cable for the connection. USB is not a symmetrical relationship. You can in fact physically damage either machine by connecting them this way, since there is voltage involved. – goldilocks Apr 12 '15 at 10:18
  • 2
    You can, however, use a special host-to-host cable, in which case, yes there are kernel drivers, so if you are going to buy one, make sure you check around whether there are drivers for that particular cable. – goldilocks Apr 12 '15 at 10:28
  • 4
    That will definitely not work, and is the kind of cable that can fry your computer if you connect it to another computer directly. – zhongfu Apr 12 '15 at 10:36
  • 2
    @Thorongil No, that is not what I mean. It looks like there are not any on that Amazon site that I could find -- they are kind of unusual things. Here's one. Do not confuse this with an OTG ("on-the-go") cable, which are much more common. Basically this is just not worth pursuing -- notice that is a 2.0 cable meaning you would have faster transfers using an ethernet cable if they both have gigabit ethernet (and you could use normal software). – goldilocks Apr 12 '15 at 10:55
  • 2
    i just do networking ... my computers so i know i already have it ... a LAN-over-USB to LAN-over-USB would what i would look for – Skaperen Apr 12 '15 at 12:10
23

Yes this is possible, but it is not possible by cutting two USB cables with USB-A connectors (what is normally going into the USB on your motherboard) and cross connecting the data cables. If you connect the USB power lines on such a self made cable, you are likely to end up frying your on-board USB handling chip. Don't try this at home!

On most computer boards the chips handling USB are host only. Not only that but, it also handles a lot of the low level communication to speed things up and reduce the load on the CPU. It is not as if you could program your computer to handle the pins on the USB port to act as if a non-host. The devices capable, on the chip level, of switching between acting as a host and connecting to a host are few, as this requires a much more expensive chip¹. This is e.g. why intelligent devices like my smart-phone, GPS and ebook, although they all run Linux or something similar, do not allow me to use ssh to communicate when connected via a normal USB cable.

Those devices go into some dumb mode when connected, where the host (my desktop system) can use its storage as a USB disc. After disconnecting the device uses the same interface as a host as to get to the data (although no cable connection is required, this happens internally). With that kind of devices even if Linux runs on both, there is no communication between the systems, i.e. the linuxes. This independent of a normal micro or mini USB cable connecting them to my desktop.

Between two desktop PCs the above is normally impossible to do as you would require a USB-A to USB-A cable, which is is not common (as it would not work with the normal chips that are driving the connections anyway).

Any solution doing USB to USB with two USB-A connectors that I have seen, is based on a cable that has some electronics in between. (much like a USB → Serial plugged into a Serial → USB cable, but then all in one piece). These normally require drivers to do the transfer, although you might be able to use UUCP or something else over such a cable, like you would over a "normal" serial port. This probably requires inetd and proper configuration to login on the other computer as well.

¹ The only device I have that is software changeable in this way is a Arduino board with exactly such a special chip. Just this chip made the board twice as expensive as a normal Arduino board.

  • "do not allow me to use ssh to communicate when connected via a normal USB cable" I may be misunderstanding you, but I can ssh into my jailbroken iPhone – Cole Johnson Apr 13 '15 at 2:57
  • @ColeJohnson I am not familiar with iphone. Does that allow you to see the internal memory as a USB drive on any host computer with USB? If it can it should run a full emulation of the non-host side. If it cannot then it probably requires a dedicated program to load data onto the phone. – Anthon Apr 13 '15 at 5:11
  • If you install openssh on the device, you can ssh in (over Wi-Fi), and if you install afc2 (Apple File Conduit) on the device, you should be able to browse the file system over USB (without it, you're "jailed" to /var/mobile) – Cole Johnson Apr 13 '15 at 14:44
  • 1
    This is all fine except the bit about phones. The fact that many devices restrict what can be done doesn't negate the fact that the USB chips used in all but a handful of devices can run in client mode, some also being able to run in host mode. – Caleb Apr 13 '15 at 19:20
5

Yes, USB 3.0 makes full duplex data transfer possible, with 3.0 cabling. The specs are in section 5.5.2 of the USB specs. The link to those specs is given earlier in another answer. http://www.gaw.ru/pdf/interface/usb/USB%203%200_english.pdf

Cables are becoming easier to find- they can be bought on Amazon, for example, for under $8.00. be sure to buy DATA TRANSFER, male A to male A cables. Newer versions of Linux support the transfer.

I hope that helps someone- I searched for the answer for quite a while myself.

  • any setup needed for this cable to work? will it be mounting or network simulation? – mpapis Feb 22 '17 at 20:28
  • interesting, I have a simple usb 3.0 cable (just male ends and a simple cable between), and I wonder if I wont fry my usb 2.0 notebook port by connecting it to my desktop usb 3.0 port? I connected for a few seconds and nothing happened on dmesg, so I promptly disconnected as I usually do with anything that does not promptly work. – Aquarius Power Oct 29 '17 at 23:22
  • 1
    Section 5.5.2 "USB 3.0 Standard-A to USB 3.0 Standard-A Cable Assembly" of the Specifications only defines cable and says "cable assembly is defined for operating system debugging and other host-to-host connection applications". Are you sure that usb3 a-to-a cable allows not only debugging (kernel.org/doc/html/v4.16/driver-api/usb/usb3-debug-port.html - needs xHCI debug capability DbC, which is optional for xHCI usb3 host controllers), but also file transfer? For file transfer there are active cables (with controller in middle), some listed at: ghisler.com/cables – osgx Apr 8 '18 at 13:29
3

you could use a USB bridge device which is available in a cable form-factor like this ... http://www.usbgear.com/link/ (auto-play video warning)

  • 2
    do not connect USB ports directly – Skaperen Apr 12 '15 at 10:37
  • this may be specific to Windows – Skaperen Apr 12 '15 at 10:43
  • 3
    I would be very wary of the "no driver needed" bit. AFAIK they do, in fact, need drivers. linux-usb.org/usbnet/#t-host – goldilocks Apr 12 '15 at 10:58
  • @goldilocks yeah that board probably has some kind of windows code ... no driver needs to be installed from a cd by the user – Skaperen Apr 12 '15 at 12:05
0

It is technically possible if one of the device supports USB OTG, in which a port may act as master or as slave. You may set up the OTG device as slave, and let it act as an USB hard disk drive (so you don't even need special driver on the master).

This is what a lot of phones and some cameras do. If you connect them to a printer they become master; if connected to a PC they become slave.

  • 1
    USB OTG just switches between USB host and USB device mode. While common for phones, I do not know any PC with this feature. Do these PCs actually exist? – Lekensteyn Apr 12 '15 at 19:49
  • @Lekensteyn: It's not uncommon for tablets, and some tablets really are full PCs. There's probably high correlation between host-only USB ports and full PC, however. – Ben Voigt Apr 12 '15 at 19:55
  • @lekensteyn edited the answer as only one of the two device, it's not important if sender or receiver. Still lacking otg on PC side, I think. That's a shame. – Lesto Apr 12 '15 at 20:27
0

The way I would do it is use 2 usb-serial cables and a null connection between. Then u can use xmodem, zmodem, kermit etc to transfer files, or use ppp or slip for a network between two machines. Old fashioned but will work.

Thad

  • 1
    With "usb-serial cables" you mean cables that convert from USB to some serial plug and standard like RS232 over DE-9? So it's basically two converters and a cable for the serial communication? Also, it would have been nice with a bit more information on how to use these protocols or where to find good help on them. – phk Jul 28 '16 at 17:08
  • phk is correct, you shall explain what a null connection is. An answer shall be self contained. Also, please use "you" instead of "u", again an answer should be a self contained example not a forum post – grochmal Jul 28 '16 at 17:29
  • This would take your USB 3 transfer speed (5-10Gbps) and reduce it down to some 0.001Gbps, about 1000 times slower than standard gigabit Ethernet. Hardly worth the effort! Especially if like the OP you're looking to share disks over the connection. – Malvineous Mar 16 '17 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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