# Usb passthrough to iocage jail



## vambier (Dec 7, 2019)

I'm using freenas and also posted this question on the freenas forums, but it also applies to freebsd itself so I also wanted to post it here.

I am trying to get a Aeotec Z-Stick Gen5 stick to work on Domoticz in an iocage jail.

The device is recognized in freenas as `/dev/cuaU0`, but is not visible in the jail.

If I understand correctly I have to unhide the device in `/etc/devfs.rules`. Since this file gets overwritten after each reboot I added the following script which runs at postinit:



```
#!/bin/sh


cat >>/etc/devfs.rules << 'EOF'


[devfsrules_common=44]

add include $devfsrules_hide_all

add include $devfsrules_unhide_basic

add include $devfsrules_unhide_login

add include $devfsrules_jail

add path 'cua*' unhide


EOF


service devfs restart
```


When I run `devfs rule -s 44 show` I get the following output:



```
100 include 1

200 include 2

300 include 3

400 include 4

500 path cua* unhide
```


This indicates that the rules are set correctly.


In the freenas GUI I set the `devfs_ruleset` to 44, this is the id of my custom ruleset. I also enabled `mount_devfs`, `allow_mount` and `allow_mount_devfs`.


When I start the jail from the commandline I get the warning `Domoticz is not using the devfs_ruleset of 4, not generating a ruleset for the jail, DHCP may not work.`

The device is not visible so it seems that my custom rules are not being used. Some say that you have to add the following to `/etc/rc.conf` :



```
devfs_enable="YES"

devfs_system_ruleset="devfsrules_common"
```


But this also doesn't work, I also added it to my init script so that it is always added after reboot, but it still doesn't work.


The strange thing is, when I set the `devfs_ruleset` to 3 (1 to 4 are default rules defined in `/etc/defaults/devfs.rules`) which exposes all devices to the jail I can see my device just fine and can use it in Domoticz, but now all other devices are visible too in my jail.


Does anyone have an idea why this doesn't work? All the documentation shows that this is the way it should work, add a custom ruleset and make sure the jail uses that ruleset. But it seems that my custom rules are unknown to the iocage jail.


----------



## SirDice (Dec 9, 2019)

vambier said:


> Since this file gets overwritten after each reboot


This doesn't happen on FreeBSD, so it's specific to FreeNAS.


----------



## vambier (Dec 9, 2019)

SirDice said:


> This doesn't happen on FreeBSD, so it's specific to FreeNAS.



Well that part maybe FreeNAS specific, but when I make those changes on the commandline and restart the devfs service myself it doesn't work either.


----------

