# Enable sound inside jail



## captobvious (Apr 21, 2011)

I am running xfce4 from a jail and accessing it with xnest. Is there a way to get audio working from inside the jail?


----------



## Nukama (Apr 21, 2011)

If your jail is on the same host, you could allow access to audio devices (i.e. desktop.local) with 
/etc/devfs.rules:

```
# Devices usually found in a desktop jail.
#
[devfsrules_desktop_jail=5]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add path 'mixer*' unhide
add path 'dsp*' unhide
add path 'dri' unhide
add path 'dri/card0' unhide
```

and add following to your jail setup in /etc/rc.conf or /usr/local/etc/ezjail/desktop_local:

```
export jail_desktop_local_devfs_ruleset="devfsrules_desktop_jail"
```


----------



## SirDice (Apr 21, 2011)

Nukama said:
			
		

> and add following to your jail setup in /etc/rc.conf or /usr/local/etc/ezjail/desktop_local:
> 
> ```
> export jail_desktop_local_devfs_ruleset="devfsrules_desktop_jail"
> ```


Or simply use 
	
	



```
jail_<name>_devfs_ruleset="devfsrules_desktop_jail"
```
 in /etc/rc.conf when you don't use sysutils/ezjail.

No need to export anything, it's all taken care of by the jail rc script.


----------



## captobvious (Apr 25, 2011)

Thanks, I now have flash running inside a jail!


----------



## chrbr (Oct 8, 2017)

This thread is a few years old but one of the first hits seeking "freebsd jail audio" with a popular search engine. Therefore it might be helpful for somebody else using FreeBSD-11.1 to have an example what works for myself nowadays. Only details have changed with repect to 2011. /etc/devfs.rules is a copy of the jails section in /etc/defaults/devfs.rules with two lines added. This is copied from the excellent howtodo https://forums.freebsd.org/threads/53362/. The content of /etc/devfs.rules is

```
# Devices usually found in a desktop jail for sound.
#
[devfsrules_desktop_jail=5]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add path zfs unhide
add path 'mixer*' unhide
add path 'dsp*' unhide
```
This file is activated by a line in /etc/rc.conf as

```
jail_fox_devfs_ruleset=5
```
In contrast to the 2011 syntax the index and not the name is specified. I hope this is a useful update.
Kind regards,
Christoph


----------

