Page 1 of 1

Virtualbox in Jail

Posted: 21 Oct 2014 15:38
by squiggie
I'm trying to install virtualbox inside a Jail. I'm hitting a lot of roadblocks preventing the virtualbox-ose port from compiling. Is this even possible anymore and if so, can someone point me toward a tutorial?

Re: Virtualbox in Jail

Posted: 21 Oct 2014 15:56
by fumantsu
I tried also and wasn't successful with main issue the kernel modules. I don't think that you will able to install it inside a jail.

Re: Virtualbox in Jail

Posted: 21 Oct 2014 16:28
by squiggie
Well I was running into an issue compiling it where it was failing on the soap builds. I did make config and disabled the webserivce part and it built successfully, but then when I created a VM and tried to start it, I kept getting errors about the kernel modules not being loaded as well.

Anyone with experience making this work that has some advice would be much appreciated.

Re: Virtualbox in Jail

Posted: 21 Oct 2014 21:40
by dreamcat4
It's not very easy to run virtualbox on nas4free and you are recommended to probably use the extension in the Extensions Sub-Forum instead.

If your builds are failing whilst compiling SOAP then there are 2 possible reasons:

1) Blocked CPU fan - your processor is overheating (past it's limit) and your computer is thermally shutting down. If it's that reason, the computer will physically shut down / power off.

2) You have run out of memory. Probably because you do not have any swap file. Then you need to create a swap file. Or upgrade (try to max out) your system RAM because RAM should be cheap enough these days. It is recommended to do both of those things.

If you run 'uname -a' you will see a SVN build revision number of the Kernel. To build a compatible kernel module(s) you should svn checkout -r that same SVN revision number of the kernel sources.

If you create a jail, you can 'kldload' the virtualbox kernel modules outside the jail and then "chroot" into the jail to have proper access to the networking devices... but if your vbox kernel modules aren't full compatible with the kernel then there is a large chance that the networking aspect will crash either virtualbox else panic (crash) the the whole system.

BTW: options VIMAGE is desirable / necessary for running virtualbox actually in a jail (as opposed to a chroot). To access network interfaces properly. However in 9.X (at least until 10) then options VIMAGE (for VNET jails) is now known not to work in combination with iSCSI (which is of course enabled in NAS4Free). So that is why I did not see the point in trying to add VBOX support in the multi-platform finch tool. That and because pfsense platform does not support options VIMAGE either.

Your best bet on nas4free platform is either use the virtualbox extension, which is still *recommended*. Else you can try to install in a jail but inevitably will be kldload'ing kernel modules, and running virtualbox from inside a chroot session instead (of the same jail folder).

Re: Virtualbox in Jail

Posted: 21 Oct 2014 22:37
by squiggie
dreamcat4 wrote: 2) You have run out of memory. Probably because you do not have any swap file. Then you need to create a swap file. Or upgrade (try to max out) your system RAM because RAM should be cheap enough these days. It is recommended to do both of those things.
I was thinking this might be the case so I'm going to explore this option. I'm having some issues creating a swapfile though. Not to diverge too much from the topic but when I follow https://www.freebsd.org/doc/handbook/ad ... space.html to create a swapfile and use it, I get an error:

Code: Select all

mdconfig: ioctl(/dev/mdctl): Device busy
Now when looking at mdconfig -l I see that md0 and md1 are already used. So if I do this

Code: Select all

mdconfig -a -t vnode -f /usr/swap0 -u 2 && swapon /dev/md2
I get swapon: /dev/md2: Operation not permitted. Any help on creating a swapfile? Do I create the swap within the jail or on the host system?

Re: Virtualbox in Jail

Posted: 22 Oct 2014 10:05
by dreamcat4
# To create a zfs swapfile as it's own zfs dataset
#https://forums.freebsd.org/viewtopic.php?&t=31861
# as root, on a zfs pool
zfs create -o org.freebsd:swap=on -o checksum=off -V 2G pool0/swap
swapon /dev/zvol/pool0/swap

# To create conventional swapfile regular file (as a real file)
swapfile=/mnt/pool0/var/.swap0
dd if=/dev/zero of=$swapfile bs=1M count=2048
chmod 0600 $swapfile
cat > /mnt/pool0/sbin/swap-postinit <<- "EOF"
#!/bin/sh
swapfile=/mnt/pool0/var/.swap0
mdconfig -a -t vnode -f $swapfile -u 9 && swapon /dev/md9
EOF

Re: Virtualbox in Jail

Posted: 27 Jan 2015 07:43
by fsbruva
The reason you can't run or build it in a jail is because the jail is already a paravirtualized environment. That's like trying to run a Windows virtual machine, and then trying to run virtualbox inside that VM! It's like dividing by zero... you'll end up tearing a hole in the universe.

Seriously: Jails, by design, have significant limits placed on them and their processes, especially with regard to kernel access. Virtualbox, by design, needs to have nearly unrestricted kernel access so that it can load the modules necessary to create the virtual machine abstraction layer.

TL,DR; Use the extension - VirtualBox is jail incompatible!