# FreeBSD to act as USB Storage Device



## romeor (Apr 1, 2014)

Hi,

Could not find anything useful by keywords "usb gadget" so I decided to ask myself  :stud 
If FreeBSD is able to act as USB Mass storage device for my home cinema system?
My idea is to have a host, which runs FreeBSD that is acting as router, NAS and USB mass storage device . May be there is a way to export a block device as USB  or something similar ? I know, that I will have to use USB direct link cable.


----------



## Hewitson (Apr 2, 2014)

I also have a need for this feature. I have no idea if it's possible or not.


----------



## wblock@ (Apr 2, 2014)

I'm interested in this also, but had the impression that custom hardware was needed.  I don't know where USB target mode is documented.

The alternate method is to use Ethernet, which is more versatile and probably faster.  FreeBSD can easily be an NFS or Samba server.


----------



## romeor (Apr 2, 2014)

Yes, some kind of media center could be used instead like Plex, but it requires additional configuration like to transcode or not and if yes, than streaming parameters, devices profiles etc. Too much headache for simple solution as for me .
But well, seems like got to play with this. It is not simple task to serve files via USB from host.


----------



## SirDice (Apr 2, 2014)

You can't use USB for this, as @@wblock noted, you need specific hardware for it. There is a firewire "target" mode though, sbp_targ(4).


----------



## romeor (Apr 2, 2014)

Well, on Windows systems with direct link cable you can. Today I've tested the Plex on my Debian laptop, seems like it has grown up pretty well. Seems useful. Now its time to buy some tower, quiet PU and other moving parts and install FreeBSD on it with Plex, PF and Samba and it should make my life a lot easier in nowadays media.


----------



## ralphbsz (Apr 2, 2014)

Some USB hardware is capable of acting as a USB target or device, others is not.  Clearly, the USB interfaces installed on embedded systems (like USB to SATA converters or cell phones) are capable of being targets, and can even change roles between target (device) and initiator (host) mode.  I think some ARM-based embedded systems can do that too (the Raspberry PI or Arduino come to mind).

Whether the standard *HCI interfaces on PC motherboards are capable of being target/device: no idea.  Never seen it done, but that's probably just because I haven't looked hard enough.

Clearly, doing this via Ethernet (TCP/IP, NAS, Samba, NFS, and so on) is a much more sane solution.  Getting it to work via USB (and to some extent even via FireWare target mode) is a medium or large development project.


----------



## SirDice (Apr 3, 2014)

romeor said:
			
		

> Well, on Windows systems with direct link cable you can.


This works differently and isn't a true USB client-server setup. Both sides are USB Host and use some sort of (non-standard) protocol to talk to each other. It's this protocol that makes the transfer possible. It's not a "traditional" USB host and client as you would get with a PC and an external harddrive for example. It may appear to work the same but it certainly isn't.


----------

