3

I have two computers, a Debian laptop and windows PC.

I have data available in my Debian machine which I want to use in windows machine. I'm aware of NFS and network file sharing, but is it possible to use USB to solve this issue?

Making Debian to act like USB device, I can connect it to windows PC to share some of my data stored on Debian Machine using USB male-to-male cable.

Is it possible to accomplish it using USB?

4

Both the laptop and the PC are USB hosts with female type A connectors. You cannot directly connect two USB hosts with a Male-Male cable. One of the device's would need to act as a peripheral, which wouldn't be supported by the USB chipset on the motherboard.

Some devices support acting as a host or peripheral with USB on-the-go, but I don't think any personal computers would support this.

There are active cables that act as two peripheral's (one for each host), but you would have to make sure they were supported by the OS.

2

There are ways to connect devices using USB, such as http://www.linux-usb.org/usbnet/. This however simulates an ethernet network, which you are probably trying to avoid. I'm pretty sure it's not possible to connect a computer as a USB drive.

Your best bet is probably the regular network way, or you can write the USB interconnect driver yourself.

1
  • I'm pretty sure it's not possible to connect a computer - I don't believe that. But if you did do something you would probably have to present the storage to the remote computer as a block device. Since USB storage is not a network file sharing protocol, it most likely expects to have exclusive direct access to the filesystem. – Zoredache Jul 22 '15 at 19:07
2

The issue with using USB in this manner is that USB is a Master-Slave protocol, and most computers only come with Master or Host capable USB ports.

If you were to find a way to add a Slave (or Device) port to your laptop, then you could use the Mass Storage Gadget implementation found here to make your laptop show up as a mass storage device.

If you can't find a way to add a Slave port to your laptop, you can go with the Ethernet(or similar)-over-USB method using a host-to-host network cable; this requires a special USB bridge cable, not a straight USB A to A cable. If you use a straight USB A to A cable, you can burn up your power supplies! This will create a USB based network connection between the machines, one that you can even bridge to your Ethernet network. You'll also need the appropriate drivers for the cable for each system.

0

I can think of one solution: clone the laptop HDD to a USB. Change the BIOS settings in the Windows box to boot USB first and then you boot your Debian system on the Win computer like a USB. If the Windows partition is not encrypted, you will be able to mount it from your portable Debian system and can exchange files as you wish.

You might need a USB with 64 or 128 GB depending on how much info there's in your Debian system. And I believe that you were not looking for a way to migrate your entire laptop to a USB, but nevertheless, this is a solution to the problem you want to solve:

"Make Debian act as a USB device which I can plug into another machine."

0

I found this web page that describes some of the process of setting up a Debian system to make a virtual USB mass storage device: https://docs.embeddedarm.com/USB_Gadget_Mass_Storage

Is that helpful? I'm guessing that by setting up two block devices, mounted on both systems but each one set-up to be read only by one system, that way a person can have two way file transfer and not worry about either computer trying to write something at the same time. To move a file from Debian to Windows you can copy a file to the virtual drive it can write to, then go to the Windows computer and you should see that file appear and then copy it from there. To move a file the other way copy a file to the Windows read/write virtual drive and then copy it out of the read only virtual drive on Debian.

The hardware setup on Debian should be fairly trivial so long as it has a free USB-C port. Configure the "gadget" on that port and connect the port to the Windows computer by a USB-C to USB-C cable or USB-C to USB-A cable as appropriate. If the Debian computer does not have any USB-C ports then the USB connection is not so trivial.

From what I've seen many newer computers with USB-A ports use the same chips as those that have USB-C ports, so the port should support a slave mode like most any USB-C port would. What I don't know is if there is a requirement for the cable to signal a switch to slave/device/gadget/whatever mode like the old USB-OTG ports did. If there is a means to set a USB-A port to device mode in software then this likely will mean the port cannot recognize the presence of a device being plugged in, such as a mouse or flash drive.

Cables to safely connect USB 3.x type-A ports together do exist. Here's one example: https://www.datapro.net/products/usb-3-0-super-speed-a-a-debugging-cable.html In the product description is a link to a Microsoft document on how to set this up on Windows so a USB-A port can look like a device port to another computer. This is not likely all that helpful but it proves this is possible, and shows some of the pitfalls and caveats on making this work. One caveat is that the port needs to have a USB 3.x controller that supports debugging. Again, this appears to be relatively common now since computer makers are using the same chips behind their USB-A ports as they use for USB-C ports that are capable of entering a device mode (required for things like USB Power Delivery to charge a laptop battery).

Using an active USB-A to USB-A "bridge" or "file transfer" cable might not get what you want. This kind of cable will look to both computers as an Ethernet or serial device. This would allow for sharing of files but would mean limiting data transfer speeds to that of the chip in the middle. A quality passive USB cable should give 10 Gbps (with USB 3.x and USB-A port) or even 20 Gbps (USB 3.2 and USB-C) transfer speeds. With the right kind of "gadget" settings the Debian computer could appear as a multifunction dock with attached drives and an Ethernet port to the Windows computer.

Your Answer

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