Some applications simulate a virtual USB or CD Rom drive as if a USB drive is attached to the computer.

Is there any configuration or application that provides a virtual USB drive, not for the the operating system itself, but for other equipments which accept USB drive, through a USB port.

So I'll have a virtual hard disk (e.g. a *.vdi file) in the computer, which is connected, through a USB socket, as a USB drive to some other equipment (e.g. a cell phone or a laptop).

6 Answers 6


Edit: While this answer was correct at the time (with a few rare exceptions), since then there's been more developments. We now have USB-C, for example, which supports both device and host modes. Many devices - especially SBCs - come with USB-C and a controller which can run in both modes. The main problem is still mostly on the Windows PC side, where there's a lack of any USB-C device mode drivers with the OS. Linux, however, does include USB-C device mode drivers (aka "USB Gadget" drivers - although you may need to compile a custom kernel if they haven't been included in your distribution.)

You would need to add a USB Device/Peripheral controller to the computer, as opposed to the USB Host Controller they tend to come with.

Something like this: https://www.maximintegrated.com/en/products/interface/controllers-expanders/MAX3420E.html

Unfortunately, you'd have to find a way to wire it onto your motherboard. Technically, it can be done. Practically, you'd have to redesign the motherboard to include it. You might be lucky enough to find an SPI or I2C bus exposed somewhere on your motherboard to allow you to add it, but they're usually wired directly into whatever they're being used for unless you're using a dev board or single-board computer with exposed GPIO and other ports such as a Raspberry Pi.

The other option would be a USB On-the-Go Controller. Motherboards designed for embedded and portable devices tend to have a USB OTG (On-the-go) contoller, which can function as either a Host or Device controller. For example, the aforementioned Raspberry Pi has an On-the-Go Controller, but on all models except the Pi Zero that gets rewired to a host port or an onboard USB hub denying the use of USB device functionality. The BeagleBone Black has an OTG port.

That's not all though - once you've got the hardware, you'd also need the software. Linux has some useful kernel USB Gadget drivers ("USB gadget" is another term for USB peripheral/device) such as g_serial and g_ethernet that allow you to plug your device into another computer and be visible as a serial or ethernet-over-USB device (there are others for exposing a device as mass storage, which allow you to use a file as a block device and expose the computer as a mass storage gadget). The BeagleBone Black tends to come with this enabled by default, so you can simply plug it into your PC over USB and see it as a networked device - and I believe it also appears as a mass storage device by using a composite driver (which allows it to appear as multiple USB device types over a single connection.) The Pi Zero can use these, but does not by default. For Windows or other OSes, you'd probably have to write that device driver yourself.

So, theoretically, you can do it. You can tear down your desktop PC, try and find an unused compatible bus on the motherboard somewhere (most likely some unused pins on a controller IC), or a way to extend an internal I2C or SPI bus, or something you can tear out and replace, and solder a USB OTG or device controller chip onto it. Then you can install Linux and use a gadget driver, or write your own for another OS. Practically, unless you're a top-notch electronics engineer, you're not going to be able to do it. At least, not until someone comes out with that elusive adapter with a device or OTG port on it that plugs into a USB port (theoretically, that could be done with a microcontroller such an Arduino wired to a pair of USB device controller ICs), and writes the drivers to run it.

  • 3
    great explanation, can you please update the answer if you (with your knowledge) see something new regards your sentence "until someone comes out with exclusive adapter...". There are laptops with usb-c in 2018, could they be a solution.? Commented Sep 10, 2018 at 16:41
  • 3
    Update since 2016: the RPi4 supports USB OTG via its USB-C port. Previous RPi versions did not support this. Doesn't answer the question directly (RPi is not a PC adapter), but might help someone who's dissuaded by the above, which was correct at the time. Commented Jan 15, 2021 at 16:00
  • A soldering iron should not be necessary to add a client-mode capable USB-C port to a computer. Any laptop that can charge from USB-C should be capable of client mode, that's required of USB-PD. I've seen some uses of USB ports that break all kinds of USB specifications so it's possible there are laptops that charge from USB-C in a nonstandard way. USB-C PCIe add-in cards could be dual-role capable. There's likely a list out there somewhere on the WWW that has all the dual role USB controllers, I just haven't found it yet.
    – MacGuffin
    Commented Jun 24, 2021 at 11:28
  • @MacGuffin indeed, as my edit at the top states, this answer predates USB-C being common in computers, and dates back to when the only thing physically on the board was a USB host controller that couldn't physically support gadget/device/peripheral mode. Commented Jun 24, 2021 at 13:00
  • Can this approach used to access the files simultaneously from 2 systems ? Commented Aug 17, 2021 at 18:17

I do wish people would stop repeating the erroneous claim that all personal computers lack the hardware to act as a USB device/slave/gadget/whatever. I can prove this is not the case. My first example of this is that all Apple Mac computers with a USB-C port have the capability of going into a USB-C slave mode. This is called "Target Disk Mode", and it is documented here: https://support.apple.com/en-us/HT201462

This is a function of temporarily turning your $2000 laptop into a $200 USB-C drive. Why do this? So that one can repair the drive on a non-booting Mac for one. How does this work? It works because Apple used a USB-C chip in their computers that is capable of acting as a USB slave/device/whatever, and installed some firmware to allow this function. This chip is not unique to Apple computers, this is also used by a number of other computer manufacturers.

There's more evidence to back up that most every laptop with USB-C ports also have the hardware needed to act as a USB slave/device. Take a laptop that uses USB-C for power and charging, get a USB-C to USB-C, get another computer with a USB-C port that is running Windows. Now, connect the laptop to the Windows computer with the USB-C cable and check the Device Manager for new devices. If the laptop is drawing power from the Windows computer then you should see in the Device Manager the laptop show as a "USB billboard device" in the list of devices. This is the laptop acting as a USB device. It has to appear as a device to a USB Power Delivery capable host, such as a USB-C power brick, to draw more than 5 watts of power. There's other ways of checking this so adjust the process for your preferred operating system or whatever.

Why don't more operating system publishers use this capability to do more than just charge batteries in laptops? That's a good question. That's a question I've been looking to answer for a long time.

There are some people working on expanding the capability of Linux systems to act as USB devices. It works right now for a wide range of USB virtual devices but it's not trivial to setup. I'm hoping that someday soon this capability becomes better supported, and is expected by users to work simply, easily, and with the high performance we expect from USB 3.x devices.

The hardware is already there for computers to act as a USB device in most every computer with USB-C ports, we just need more people working on writing the software to make this something the average user (or even slightly above average user) can set-up and use.

  • 1
    I think you're forgetting that the question was asked in 2014, which as of your answer is six years ago Commented Jun 20, 2020 at 11:16
  • 2
    Yes, but... USB 3.0 supported host to host connections since 2009 so this was possible in 2014. There's documents from at least as far back as 2012 on how to set up USB-A to USB-A connections on USB 3.0 ports for Windows 7 and 8 kernel and driver debugging. This was also done in Linux at that time. Apple had USB Target Disk mode capable laptops in early 2015, about the same time as one reply and years before the 2017 reply claiming this is impossible. So, my comments would be not all that helpful in 2014, only true for new Apple hardware in 2015, but quite relevant by 2017.
    – MacGuffin
    Commented Jun 20, 2020 at 12:08
  • 1
    “There are some people working on expanding the capability of Linux systems to act as USB devices. It works right now for a wide range of USB virtual devices but it's not trivial to setup.” Hi. Can you be more specific in describing what needs to be set up in LineageOS (Android)?
    – beroal
    Commented Feb 8, 2021 at 20:23
  • I can not be more specific as I have not used USB gadgets myself. I use Linux often but in virtual machines. I'd have to run Linux "on the metal" for gadgets to work. I've been meaning to experiment with this but I haven't set the time aside yet to do so. I made an order for a new hard drive and USB-C controller so I can dual boot a computer for this experimentation and I heard back that it could take weeks for the order to ship. Is the computer parts shortage really that bad?
    – MacGuffin
    Commented Jun 24, 2021 at 11:34
  • Apple may have had patents on the general concept of ‘Target Disk Mode’; not sure when/if they expired, but it may not have been until recently (i.e. the past 5-10 years, at most). Commented Dec 30, 2023 at 7:01

USB A/B (the old style with different plug shapes on each end, and where each end can only plugged in one way) is dissymmetric: one side is a host, the other side is a peripheral device. You can't make a peripheral device act as a host or vice versa. It is possible for a USB port to be able to act as either side; this is called USB on-the-go and is present on some mobile phones and tablets. The ports are physically device-type ports, not host-type ports. I've never seen a PC with a device port. This requires electronics on the controller, it isn't enough to make a cable that fits on both ends.

So no, you won't be able to make a PC into a USB device.

If you want to use a computer as a USB storage device, you can use a mobile phone or tablet with a USB connection instead of using a PC.

USB-C (the new style with symmetric plugs, the same on both ends) does allow plugging one computer into another. Unfortunately, it's not as simple as just plugging in the cable and getting a point-to-point network connection. See https://superuser.com/questions/1215710/is-it-possible-to-connect-two-pcs-via-usb-c

  • Can you elaborate a bit more, how using a mobile phone could help me turning my PC into a USB storage device / host, that I could plug to another compter, TV or device? I think, I'm missing this point, though I think I have a fair knowledge about USB OTG.
    – trejder
    Commented Mar 10, 2015 at 8:15
  • @trejder As I wrote, I've never seen a PC with a device port (“PC” excluding x86 tablets). Commented Mar 10, 2015 at 8:19
  • Yes, but I'm refferring to your last sentence: "If you want to make a computer into a USB storage device, you can use a mobile phone or tablet with a USB connection". Maybe I'm missing something, but I understand it as "You can use mobile phone or tablet to turn computer into USB storage device". If so, then the question is: How?
    – trejder
    Commented Mar 10, 2015 at 8:23
  • 1
    @trejder Ah, “computer” in that sentence is not “PC”, it's “computer”. A phone/tablet is a different kind of computer from a PC. Is that what's troubling you? Commented Mar 10, 2015 at 8:27
  • 2
    @trejder No. Usually your best bet is to establish a network connection one way or another. You can use Firewire as a network connection between any two PCs with a Firewire port, but many PCs don't have one. Most PCs have an Ethernet port, you can connect two PCs with an Ethernet cable (very old PCs require a crossover cable but modern ones can take an ordinary cable). To make a PC serve as a storage device for a mobile device, you typically need to get the PC onto wifi somehow. Commented Mar 10, 2015 at 8:35

As explained in the answer by by Matt Thomson, with the exception of some USB-C controllers it is not properly possible to make a physical USB port of a PC computer act as a USB slave device, because the USB slave controller part is missing.

But we can use an adapter board that provides slave-mode USB to the outside world. The simplest and smallest option for this might be the Raspberry Pi Zero.

Now the remaining task is to connect that RPi Zero adapter board to our host PC, which ultimately should store and serve our files. I have two different proposals for how to provide that connection over Ethernet cable:

(1) Expose the USB port over IP network.

Use software to expose the USB slave-mode port of the Raspberry Pi Zero as a virtual USB device to your PC. The USB/IP project provides this, by means of a driver that can transport USB over IP networks. Here is an example of using USB/IP to provide a simulated USB device to a computer – which would be your PC here.

What I don't know in this proposed solution is if the USB/IP software is already able to expose a USB slave port over IP network, or only a USB host port (which is by far the more common case).

But even if that works, you still have to set up or adapt device drivers on your PC in such a way that they (1) accept the incoming USB/IP connection as a USB connection, (2) provide USB slave-mode rather than USB host-mode, (3) simulate a USB mass storage device by serving the data from the assigned location (your .vdi file).

Overall, that's a rather complex way of doing it.

(2) Expose the file over IP network.

This is a much simpler way for how to set up an Ethernet connection between the Raspberry Pi Zero and your host PC: on the Raspberry Pi Zero, mount the data stored on your PC via a network file system. These files then appear logically as part of the RPi Zero's file system, and you can then serve them with the Linux USB gadget driver (the "slave mode" USB driver) to make the Raspberry Pi look like a USB mass storage device to connected devices.

  • Down voted as this does not answer the question. The concern was for a computer to act as a drive for a cell phone or laptop. A cell phone will not have USB/IP software to make this work.
    – MacGuffin
    Commented Jun 24, 2021 at 11:40
  • @MacGuffin You misunderstood. The cellphone will see a USB mass storage device as required in the question. The complete setup however consists of three devices: cellphone, RPi Zero and a PC. USB/IP connection is for between RPi Zero and PC, not cellphone and RPi zero.
    – tanius
    Commented Jun 25, 2021 at 12:29
  • You are correct, I misunderstood. Rereading it I still see it as not answering the question because it is making the Raspberry Pi appear as the USB device, not the computer. Perhaps a distinction without a difference to some but I see it as missing the intent of the question. The question specified a direct USB connection from one computer to another, not some intermediate device to do the translation.
    – MacGuffin
    Commented Jun 25, 2021 at 17:02

Technically this should be doable with http://www.bplus.com.tw/Adapter/PP3380-AB.html - PP3380-AB (USB3380-AB Evaluation Board) which appears to include a USB3.0 5gbps USB B port on a pci express card, and is built around a Linux USB Gadget supported PLX USB3380 chip. But it's not cheap (250$) and probably far from trivial (programmer not included...).

(Note: there's also http://www.bplus.com.tw/Adapter/USB3380EVB.html where a USB3380-AB EVK with ADP board gets you a microUSB port - but that's just a cable difference)

  • That requires use of a desktop system, or breakout box, with an open PCIe slot. Ever since the MacBook with USB-C in 2015 there's been a number of laptop computers with the same USB controller. This USB-C/USB-3 chip can go into device mode as demonstrated by the MacBook being capable of Target Disk Mode on it's single USB-C port ( en.wikipedia.org/wiki/Target_Disk_Mode ) Since this same USB controller chip is used in a large number of laptops there should be many to choose from to experiment with. It's possible that this same USB controller is used in some desktop systems as well.
    – MacGuffin
    Commented Aug 9, 2020 at 20:08
  • Sounds like that's the Intel® JHL6540 Thunderbolt™ 3 Controller (Alpine Ridge) or on 2018+ the newer Intel® JHL7540 Thunderbolt™ 3 Controller (Titan Ridge). I happen to have a Alpine Ridge (DSL6540) on my motherboard, but I can't figure out how to flip it into peripheral mode in Linux.
    – MaZe
    Commented Aug 11, 2020 at 1:32

You can consider using one of special "USB-USB bridged cables", sometimes called "USB networking cables". Like one mentioned in these articles:

They allow you to transfer files between two PCs. I've been using these kind of cables over ten years ago (in times of Windows XP) and in that times all such cables available to the market required a special driver and software. They let you transfer files only through special file commander, that shiped along with cable drivers on a installation disk and therefore did not allow one PC to act to another as pure USB external device.

I'm not sure, if anything has changed since then and if new solutions allow you only to transfer files using special software and -- if you can force one PC to act as an external device to another PC.

  • 3
    This does not answer the question as USB bridge cables will appear to both computers as a serial or network connection, not make one computer appear as a drive to the other.
    – MacGuffin
    Commented Jun 24, 2021 at 13:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .