Headless Virtualbox with phpVirtualbox

Discussion in 'Hacking' started by jneusteter, May 29, 2011.

  1. Offline

    jneusteter

    Member Since:
    May 29, 2011
    Messages:
    1
    Message Count:
    1
    Likes Received:
    0
    Trophy Points:
    0
    jneusteter, May 29, 2011

    I made an attempt setting this up but I will need help with this.

    First, installing Virtualbox:

    There is a port for FreeBSD, but its not available with "pkg_add -r virtualbox". Looks like ports needs to be installed and configured.

    Second, installing phpVirtualbox:

    Doing a "pkg_add -r phpvirtualbox" installs it. But it looks like it does not resolve the php dependencies. I would assume a "pkg_add -r php" would take care of that.

    Third, using the existing lighttpd for phpvirtualbox:

    I would like to just use the existing webserver by putting the files in a sub-directory. e.g 192.168.1.2/phpvirualbox. Also lighttpd would most likely need to be configured for php, seeing that FreeNAS uses python.

    So to summarize the questions:
    What is the best way to install/configure ports?
    Would pkg_add -r php install the php dependencies?
    Would using the existing lighttpd be the best way to serve the phpvirtualbox files?

    BTW, I am a complete BSD noob. I am more useful with a linux machine.:cool:
  2. Offline

    sjieke FreeNAS Aware

    Member Since:
    Jun 7, 2011
    Messages:
    100
    Message Count:
    100
    Likes Received:
    0
    Trophy Points:
    16
    sjieke, Jun 7, 2011

    Hey,

    I'm also planning on running VirtualBox Headless using phpVirtualBox inside my FreeNAS, but I'm still waiting for my ordered components to arrive. In the meantime I'm doing some research on how to do it and I am very interrested in your progress and possible tips and tricks if you succeed.

    I'm an experienced linux user, but this will be my first BSD experience.
    Maybe I can give you a hint on installing virtualbox. If I remember correctly the package/port name isn't 'virtualbox' but 'virtualbox-ose'. Maybe if you try that you will be able to install virtualbox.
    If you didn't know already, there is a website where you can search for ports/packages: freshports.org/
  3. Offline

    Anonymous

    Member Since:
    Jun 5, 2011
    Messages:
    4
    Message Count:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Anonymous, Jun 7, 2011

    Hello,
    running phpvirtualbox isn't very simple, since you have to modify many files in the base system. The result will be a custom system which is hard to upgrade. For example modifying lighty and some system configurations.
    To get sufficient results you need to recompile the kernel/modules. Since jailing phpvirtualbox isn't very easy a chroot should help you to provide necessary stuff.
    Setting up phpvirtualbox wasn't a big deal on my FreeNAS, the biggest work is to fix some build problems with 32bit combatibility on my amd64 FreeNAS for virtualbox-ose 4.x, to get a easy to share system.

    Anonymous
  4. Offline

    seer_tenedos

    Member Since:
    Sep 12, 2011
    Messages:
    27
    Message Count:
    27
    Likes Received:
    0
    Trophy Points:
    1
    seer_tenedos, Sep 12, 2011

    Any chance you could share those steps? I am new to freebsd/freenas but would really love to get virtualbox installed on my freenas 8.0.1 box so i can shut down one of my other boxes. Just want to run a reverse proxy and a few other things until they become available as part of freenas.

    Seer
  5. Offline

    James FreeNAS Core Team

    Member Since:
    May 24, 2011
    Messages:
    298
    Message Count:
    298
    Likes Received:
    21
    Trophy Points:
    18
    Occupation:
    iXsystems, Inc.
    Location:
    San Jose, CA
    Home page:
    James, Sep 13, 2011

  6. Offline

    seer_tenedos

    Member Since:
    Sep 12, 2011
    Messages:
    27
    Message Count:
    27
    Likes Received:
    0
    Trophy Points:
    1
    seer_tenedos, Sep 13, 2011

    Thanks. I know that most of the software i want will be available in 8.1 as plugins but the issue i have is there is no set release date for 8.1, i don't think the current 8.1 daily snapshots have plugin support or work correctly and i really need something to fill the gap between now and the release of 8.1.

    I have all the download software installed and working correctly following other guides so I am sort of hoping to find a similar way to get virtual box working especially since others are saying they did it easily

    I am sure others would happily use this option till the plugins are properly implemented as well.
  7. Offline

    wookie

    Member Since:
    Mar 23, 2012
    Messages:
    13
    Message Count:
    13
    Likes Received:
    0
    Trophy Points:
    0
    wookie, Mar 25, 2012

    Virtualbox-OSE and phpvirtualbox in the PBI Jail (Near Success)

    I am getting close to running a headless Virtualbox-OSE and phpvirtualbox in the PBI Jail
    in FreeNAS 8.2.0-BETA2 (amd64).

    It has not been so straight forward...

    1. Set up your PBI Jail ala the manual:
    http://doc.freenas.org/index.php/Plugins#Compiling_FreeBSD_Ports_with_make
    And login to your jail:
    Code (text):
    1.  
    2. jexec 1 /bin/tcsh
    3.  
    2. Install the ports tree:
    Code (text):
    1.  
    2. portsnap fetch
    3. portsnap extract
    4. portsnap update
    5.  
    3. To get it to build you will need AISL however there will be a slight problem because FreeNAS is built WITHOUT_ACPI.
    So you need to find yourself a copy of /usr/sbin/aisl from some other vanilla FreeBSD 8.2 install and place it into the
    equivalent directory in your jail.

    4. You will also need some kernel sources.
    I installed subversion from ports in the jail so I could do this:
    Code (text):
    1.  
    2. svn checkout svn://svn.freebsd.org/base/releng/8.2/sys /usr/src/sys
    3.  
    5. OK time for the port build of virtualbox.
    Code (text):
    1.  
    2. cd /usr/ports/emulators/virtualbox-ose
    3. make config
    4.  
    Here is what i configured:
    vbox_config.jpg

    Now build and install:
    Code (text):
    1.  
    2. make install
    3.  
    Virtualbox should now be *nearly* installed.

    Virtualbox needs its kernel module to be installed in the host.
    So in the host (NOT the jail) load the module:
    Code (text):
    1.  
    2. kldload /mnt/<yourjailpath>/boot/modules/vboxdrv.ko
    3.  
    Then you need to enable this device in the jail.
    I did this also from the host via devfs:
    Code (text):
    1.  
    2. mount -t devfs devfs /mnt/<yourjailpath>/dev
    3.  
    6. Installing phpvirtualbox in the jail should be no problems**:
    Code (text):
    1.  
    2. cd /usr/ports/www/phpvirtualbox
    3. make install
    4.  
    ** You will probably need some further configuration to get phpvirtualbox, PHP and a webserver working in the jail together.
    However I am sure you can figure all that part from here. Once you get it configured, point your browser to your phpvirtualbox install.


    --
    Anyway I do have a test VM working though I have some issues with getting a bridged adapter to work in a Virtual Machine
    There are some other modules that need to be loaded in the kernel; vboxnetflt.ko and vboxnetadp.ko
    However I am getting a dependency error in the host with netgraph and vboxnetflt.

    To tell you the truth I am not a wizard at any of this stuff, I am just playing around.
    Though I would love if someone else would try this out.

    My general thoughts are making me believe that turning this into a working PBI plugin in a jailed environment is going to be tricky.
    Kernel modules cannot be loaded from within a jail and some host dependencies need to be resolved.
    Though as I said I am no expert, I have never made a PBI before.

    If anybody else gets this to go further please post here..
  8. Offline

    rglover666

    Member Since:
    May 7, 2012
    Messages:
    2
    Message Count:
    2
    Likes Received:
    0
    Trophy Points:
    1
    rglover666, Jul 7, 2012

    I was able to get past the netgraph dependency by fetching the kernel source and building netgraph.ko, but I still have not been able to get the bridged adapter to work. Have you made any progress with this yourself?
  9. Offline

    wookie

    Member Since:
    Mar 23, 2012
    Messages:
    13
    Message Count:
    13
    Likes Received:
    0
    Trophy Points:
    0
    wookie, Jul 8, 2012

    Unfortunately I have been locked down in work + personal life to find the extra time to pursue this, though I still intend to push with it when I see some light. As I said before, I have a funny feeling that running it in a jail is not so easy. We might have to create a modified FreeNAS build.
  10. Offline

    johnstonjs

    Member Since:
    Apr 15, 2012
    Messages:
    6
    Message Count:
    6
    Likes Received:
    0
    Trophy Points:
    0
    johnstonjs, Jul 29, 2012

    First Attempt

    I made an initial attempt this morning at getting this to work by simply installing the BSD ports, but that's not an option as the virtualbox-ose package is built without webservice enabled. I will try again and follow wookie's steps, and report on results.

    I am running into a significant issue which is that the jail bridge network adapter screws up my AFP service. I'm able to browse my AFP shares, but loading a file is excruciatingly slow, making the NAS effectively unusable while the jail is running. This may be due to the link aggregation I'm using, so I'll see if disabling and just using one network adapter makes the issue go away.

    It seems that there have been others who have successfully run virtualbox within a jail.

    Some updates:
    I tried installing subversion from the freshports package:
    Code (text):
    1. pkg_add -r subversion
    This results in an error message due to a shared library revision issue:
    Code (text):
    1. ld-elf.so.1: Shared object "libgdbm.so.3" not found, required by "svn"
    You can correct this by creating a symbolic link:
    Code (text):
    1. ln -s /usr/local/lib/libgdbm.so.4 /usr/local/lib/libgdbm.so.3
    When building virtual box I get a package version mismatch error, which I haven't resolved yet:
    Code (text):
    1.  
    2. ===>  Installing for pkgconf-0.8.3_1
    3.  
    4. ===>  pkgconf-0.8.3_1 conflicts with installed package(s):
    5.       pkg-config-0.25_1
    6.  
    7.       They install files into the same place.
    8.       Please remove them first with pkg_delete(1).
    9. *** Error code 1
    10.  
    11. Stop in /usr/ports/devel/pkgconf.
    12. *** Error code 1
    13.  
    14. Stop in /usr/ports/textproc/libxslt.
    15. *** Error code 1
    16.  
    17. Stop in /usr/ports/textproc/libxslt.
    18. *** Error code 1
    19.  
    20. Stop in /usr/ports/emulators/virtualbox-ose.
    21. *** Error code 1
    22.  
    23. Stop in /usr/ports/emulators/virtualbox-ose.
    24.  
    Maybe it would be easier to build FreeNAS from source with Virtualbox built-in...
  11. Offline

    bleckers

    Member Since:
    Nov 11, 2012
    Messages:
    3
    Message Count:
    3
    Likes Received:
    0
    Trophy Points:
    0
    bleckers, Nov 11, 2012

    Do the following then make again:

    pkg-add -r -f pkg-config

    There are a few more errors along the way, but it should be pretty straight forward.
  12. Offline

    bleckers

    Member Since:
    Nov 11, 2012
    Messages:
    3
    Message Count:
    3
    Likes Received:
    0
    Trophy Points:
    0
    bleckers, Nov 12, 2012

    I have managed to get this all up and running (including remote vnc console initialisation through the php gui) with 8.3 release apart from the bridged adapter. Unfortunately I get "Exec format error" when trying to load vboxnetflt.ko (vboxdev.ko works fine). I will try to work this out unless there are some suggestions. As soon as I have done that I will release a guide on how to do this all.
  13. Offline

    bleckers

    Member Since:
    Nov 11, 2012
    Messages:
    3
    Message Count:
    3
    Likes Received:
    0
    Trophy Points:
    0
    bleckers, Nov 12, 2012

    As it turns out, this is the netgraph dependency issue. If you copy the netgraph.ko from the 8.3 64bit DVD and load that (or compile from source), then you can load vboxnetflt and then vboxnetadp in that order.

    Just to confirm with the other findings. NAT networking is fine, bridged isn't working. This is probably due to the fact the jail uses a different adapter than freenas. We need to somehow pass this network interface through?

    Edit: NAT will be fine for me honestly. I have configure new ports through the web GUI as needed. If anyone has any ideas about bridged networking then I'm all ears. I shall update this sometime next week with instructions expanding on the knowledge in this thread.
  14. Offline

    crom

    Member Since:
    Oct 31, 2013
    Messages:
    10
    Message Count:
    10
    Likes Received:
    0
    Trophy Points:
    1
    crom, Nov 20, 2013

    There is a PBI for PCBsd now, would it be possible to use it with FreeNAS?
  15. Online

    dlavigne FreeNAS Core Team

    Member Since:
    May 24, 2011
    Messages:
    2,143
    Message Count:
    2,143
    Likes Received:
    72
    Trophy Points:
    48
    dlavigne, Nov 20, 2013

    If you try it, let us know what luck you have with it.
  16. Offline

    ndboost Newbie

    Member Since:
    Mar 17, 2013
    Messages:
    54
    Message Count:
    54
    Likes Received:
    0
    Trophy Points:
    6
    ndboost, Dec 26, 2013

    I am in the process of testing the pc bsd PBI of virtualbox right now

    edit: Downloaded the 4.2.12 pbi and installed it via the Plugins UI on 9.2.0 RELEASE.
    First try it failed due to insufficient space, derp moment .. realized i needed to extend the vm disk. Did that.

    Second try it installed! Im in the process of isntalling phpvirtualbox as well.

Share This Page