# Kernel sources within a jail



## captobvious (Mar 10, 2011)

I am setting up a jail for desktop use and I want to install x11/nvidia-driver inside the jail.

The jail was created with ezjail.

Within the jail I attempt to install the nvidia driver from ports:


```
c_desktop# make install clean
===> Building for nvidia-driver-256.53_1
===> src (all)
"/usr/share/mk/bsd.kmod.mk", line 12: "can't find kernel source tree"
*** Error code 1

Stop in var/ports/basejail/usr/ports/x11/nvidia-driver/work/NVIDIA-FreeBSD-x86_64-256.53.
*** Error code 1

Stop in /basejail/usr/ports/x11/nvidia-driver.
*** Error code 1

Stop in /basejail/usr/ports/x11/nvidia-driver.
```

I tried to copy /usr/src to /jails/c_desktop/usr/src and got:

```
file or directory does not exist
```

I tried to copy /usr/src to /jails/c_desktop/basejail/usr/src and got:

```
Read-only file system
```

how do I install the drivers? Should I make /jails/c_desktop/basejail/usr/src read/write to install the drivers then remove the sources once the driver is installed? Thanks!


----------



## expl (Mar 10, 2011)

You should install kernel modules only on the main host. I am also sure that xorg server can not run inside a jail due to kernel imposed restrictions. What you want is to install/run Xorg server on the host and install xorg libs on the jail and rest of gui applications, then just refer your DISPLAY to the host.

Edit:
I just remembered that you probably want to install OGL libs in your jail from the NVidia driver package to get 3d rendering support, but only those (exclude kernel module and X11 driver).


----------



## SirDice (Mar 10, 2011)

captobvious said:
			
		

> I tried to copy /usr/src to /jails/c_desktop/usr/src and got:
> 
> ```
> file or directory does not exist
> ```


Why copy at all?
`# mount -t nullfs /usr/src /jails/c_desktop/usr/src/`

Having said that, expl is absolutely correct. You cannot load kernel modules inside a jail.


----------



## captobvious (Mar 12, 2011)

I should have stated this earlier: I want to run my desktop in a jail. Does anyone know a good guide for this? I am guessing what needs to be done:

1) Install x11/nvidia-driver on the host
2) Install x11/xorg on the host
3) Install x11/Xnest in the jail
4) Enter the jail via ssh
5) Install/run wm/kde in the jail, as a client of Xnest

Am I mistaken (probably am)?


----------

