Working solution for USB pass-through to VM, jail, plugin...

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
Hello !
I've been looking for a way to somehow "forward" a USB dongle plugged in my FreeNAS Box to a VM created from the WebUI.
Having read lots of posts here and there, I was starting to think it would be impossible. (for various reasons, software not available on FreeBSD, mandtory kernel recompiling, overpriced solutions...)

But I found a working solution, that you can test easily for free, and that is not so expensive. It is the VirtualHere project. https://virtualhere.com/home

In a few words: it consists of a server software, a client software, both of them are free to download, need no installation at all, and have no dependancies.
They will basically forward the USB device over the IP network. Once you launch the server, the USB devices on the server are shared. Then you launch a client app and shared devices are auto detected.
The limitation of the trial version is that you cannot launch everything as daemon services (even if there's a workaround if you want to test it in deep using interactive console mode : https://virtualhere.com/node/590)

Anyway, if you choose to buy the full version, it's under USD 50 for one server box. (It runs on Linux-flavored systems, Windows systems, MacOs... in graphical or console mode)

At this time, I'm using it to run a Z-Wave controller software inside a Debian VM on my FreeNAS. A Z-Wave USB Dongle is plugged in my old Netgear ReadyNas, on which I installed the server software.
I then get access to the dongle from my VM using the client app. The dongle is detected without any problem by the Z-Wave controller software.

I hope it will help some of you.

(Disclaimer: I have non personnal acquaintance with VirtualHere and earn no benefit from this post)
 

tprelog

Patron
Joined
Mar 2, 2016
Messages
297
run a Z-Wave controller
I have a USB Z-Wave controller I use with a jail running Home-Assistant. It does not require anything special software for the Jail to see the Z-Wave device.
 

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
It does not require anything special software for the Jail to see the Z-Wave device.

I use Jeedom in a VM, for it runs under Debian. In my case, the usb z-wave dongle was not detected by Jeedom, nor did it appear in the available usb device from the ssh console. But it was correctly detected by the FreeNAS OS.

Maybe the kind of usb dongle matters...
 

tprelog

Patron
Joined
Mar 2, 2016
Messages
297
I got you. I also wonder if it's the difference is between a jail and a VM. I don't use VMs on FreeNAS but I do remember in the past having to enable some sort of pass-through for usb in VMs I ran on Linux.
 

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
I also wonder if it's the difference is between a jail and a VM. I don't use VMs on FreeNAS but I do remember in the past having to enable some sort of pass-through for usb in VMs I ran on Linux.
It might be an explanation to consider. I only use VM when I'm forced to use specific OS for a specific use. I find jails much easier to use when possible.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Just to clarify, a VM is an entire and independent operating system (you mentioned Debian) running in an emulated BIOS environment, meaning that bhyve (the hypervisor in FreeNAS/FreeBSD) is in total control of what the guest VM can do with the hardware.

Since bhyve isn't a class 1 hypervisor, it's not really great at handling passthrough of devices (although the similarity between linux and FreeBSD unix can help with that sometimes).

I dabbled with it a little for similar reasons of a home automation VM and passing trhough a usb controller device (RFXCom), but wound up too frustrated to persist and just split out to a bare-metal host for Debian in that case.

I have seen threads of folks trying to pass through PCI graphics cards with a couple reporting success as far as I recall, but I have more important things to do with my time that mess around trying to make square pegs fit in round holes.

FreeNAS is at its best if the function you want to run on it can be put in a jail (hence runs in a lightly emulated linux or native unix environment).
 

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
I completely agree with you, and to be honest, I only used a VM in that case because I wanted to perform some testing before going to a separate dedicated box.
Your explanations about VMs and hypervisor make it perfectly clear why things work with jails and not with VM in that precise case.
Thank you for your knowledge ;)
 

Rand0mUser

Dabbler
Joined
Jun 1, 2019
Messages
22
Hello,

I have just the same need, I'm looking for a way to use a USB Z-Wave device plugged into my FreeNAS from a Debian virtual machine running on it. My target is to run my Jeedom domotic using my FreeNAS so I don't have to add a Raspberry PI to all my network stuff.

I tried using virtualhere server but it doesn't seem to work. The fact is they stated that "The virtualhere server wont run on FreeNAS " as written here: VirtualHere and FreeNAS. I also noticed they have several NAS builds here, but nothing for FreeNAS nor FreeBSD.

So from what I understand, unless the server is installed on some other device on the network with the Z-Wave device plugged into it, there's no way to share a USB device plugged into the FreeNAS with a VM hosted in the FreeNAS?
 

kingc

Dabbler
Joined
Jul 2, 2019
Messages
17

liquidpower

Cadet
Joined
Mar 15, 2018
Messages
5
I have a USB Z-Wave controller I use with a jail running Home-Assistant. It does not require anything special software for the Jail to see the Z-Wave device.
Im tring to flash a esp for the first time using the esphome plug in jail but its not seeing the esp

i also tried setting

- allow_mount
- allow_mount_devfs
- enforce_statfs - set to 0 or 1
- mount_devfs
 

tprelog

Patron
Joined
Mar 2, 2016
Messages
297
There is currently no USB detection for device flashing on FreeNAS. You can create, compile and download the initial firmware using ESPHome on FreeNAS. You will need to use esphomeflasher on a seperate computer for the initial flash. After the initial flash and your device is connected to your network, you will be able to manage and flash future firmwares using the ESPHome OTA process.

It might technically be possible but it is not practical... The steps for passing a USB device to a jail/plugin are here but keep in mind you must restart the jail for the device to be detected.-- This is not an ideal solution in this case
 

liquidpower

Cadet
Joined
Mar 15, 2018
Messages
5
Cool im def ok with just downloading the file and flashing my self esp since they make over the air so easy after the first one thanks!
 
Top