Is USB-to-USB data transfer between two Linux OSes possible?

30,247

Solution 1

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.

Solution 2

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.

Solution 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)

Solution 4

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.

Share:
30,247

Related videos on Youtube

the_Strider
Author by

the_Strider

DevOps engineer wannabe kernel programmer.

Updated on September 18, 2022

Comments

  • the_Strider
    the_Strider over 1 year

    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?

    • goldilocks
      goldilocks about 9 years
      "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
      goldilocks about 9 years
      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.
    • the_Strider
      the_Strider about 9 years
      can you explain the part on which you are saying host-to-host cable ? Does you mean these type of cables?
    • zhongfu
      zhongfu about 9 years
      That will definitely not work, and is the kind of cable that can fry your computer if you connect it to another computer directly.
    • goldilocks
      goldilocks about 9 years
      @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).
    • Skaperen
      Skaperen about 9 years
      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
    Skaperen about 9 years
    do not connect USB ports directly
  • Skaperen
    Skaperen about 9 years
    this may be specific to Windows
  • goldilocks
    goldilocks about 9 years
    I would be very wary of the "no driver needed" bit. AFAIK they do, in fact, need drivers. linux-usb.org/usbnet/#t-host
  • DaleHarris541
    DaleHarris541 about 9 years
    @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.
  • Lesto
    Lesto about 9 years
    @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.
  • Cole Tobin
    Cole Tobin about 9 years
    "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
  • Anthon
    Anthon about 9 years
    @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.
  • Cole Tobin
    Cole Tobin about 9 years
    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)
  • tcoolspy
    tcoolspy about 9 years
    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.
  • phk
    phk almost 8 years
    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.
  • grochmal
    grochmal almost 8 years
    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
  • mpapis
    mpapis about 7 years
    any setup needed for this cable to work? will it be mounting or network simulation?
  • Malvineous
    Malvineous about 7 years
    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.
  • Aquarius Power
    Aquarius Power over 6 years
    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.
  • Luciano
    Luciano over 4 years
    I believe this is also called Dual Role Data. Some newer motherboards have support for this function - see for example this page. It's documented in the chipset datasheet, but necessarily enabled on all motherboards.
  • dirkt
    dirkt over 4 years
    I've never seen a working setup with this. Care to share any details?