Guide: Virtualbox 6.x and PHPVirtualbox on OMV5 and Debian 10.x

  • Install Debian 10.x – Openmediavault 5.X – Virtualbox 6.X - PHPVirtualbox

    This is walktrough for installing OMV5 in combination with Virtualbox 6. When using OMV-Extras you have the possibility to use Cockpit for your Virtual Machines.
    After working with Virtualbox for the last 5 years I find that Cocpit lacks the features that Virtualbox has.
    I'm fairly new to Linux so use this at own risk. I find that everything is just running fine!

    I did the installation as root, so i didn't ran into any permission problems.

    Install debian 10.1 including SSH

    Network config: (set static ip in interfaces - This is later adopted by OMV)
    nano /etc/network/interfaces


    iface enp0s17 inet static

    address 192.168.X.X


    gateway 192.168.X.X

    dns-nameservers 192.168.X.X


    "[CTRL] X Y [Enter]" - Save the file.

    SSH permit root login
    nano /etc/ssh/sshd_config
    PermitRootLogin yes
    "[CTRL] X Y [Enter]" - Save the file.

    Install OMV5.X
    apt-get install build-essential

    nano /etc/apt/sources.list.d/openmediavault.list
    deb usul main
    "[CTRL] X Y [Enter]" - Save the file.

    export LANG=C
    export DEBIAN_FRONTEND=noninteractive
    wget -O "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc"
    apt-key add "/etc/apt/trusted.gpg.d/openmediavault-archive-keyring.asc"
    apt update
    apt install postfix openmediavault
    omv-confdbadm populate

    Login to Openmediavault (admin - openmediavault)
    Enable all networkcards in OMV5 (if more than one)
    Mount all your disks in OMV5

    Install Virtualbox 6.x
    wget -q -O- | sudo apt-key add -
    wget -q -O- | sudo apt-key add -
    echo "deb [arch=amd64] buster contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
    sudo apt update
    sudo apt install linux-headers-$(uname -r) dkms
    sudo apt install virtualbox-6.1

    Install Virtualbox extension pack
    cd ~/
    sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.0.vbox-extpack

    Create user "vbox" and make this user a member of "vboxusers"
    adduser vbox
    sudo usermod -aG vboxusers vbox
    sudo systemctl status vboxdrv
    (see if vboxservices are running - should be "active (exited)")

    Install phpvirtualbox

    sudo apt-get install php7.3-soap
    (next on a client PC/Laptop)
    Extract and rename folder to: "phpvirtualbox"

    open config.php-example in folder "phpvirtualbox" with notepad(++)

    var $username = 'vbox';
    var $password = 'vbox'; (or the password supplied by you)
    var $enableAdvancedConfig = true;

    save file as config.php
    copy folder "phpvirtualbox" to /var/www

    On the OMV machine:

    chown -R 998:996 /var/www/phpvirtualbox

    chmod -R 755 /var/www/phpvirtualbox/

    sudo nano /etc/default/virtualbox
    "[CTRL] X Y [Enter]" - Save the file.

    Restart vbox services
    sudo systemctl restart vboxdrv
    sudo systemctl restart vboxweb-service

    Create user "phpvirtualbox-webgui" for NGINX

    adduser phpvirtualbox-webgui
    (password: phpvirtualbox)

    Create configfifle for website "phpvirtualbox-webgui" that runs in NGINX
    nano /etc/nginx/sites-available/phpvirtualbox-webgui

    "[CTRL] X Y [Enter]" - Save the file.

    Create configuration file for "php-fpm"
    nano /etc/php/7.3/fpm/pool.d/phpvirtualbox-webgui.conf

    "[CTRL] X Y [Enter]" - Save the file.

    Activate PHPVirtualbox website
    sudo ln -s /etc/nginx/sites-available/phpvirtualbox-webgui /etc/nginx/sites-enabled/
    systemctl restart nginx
    systemctl restart php7.3-fpm

    Check if you can reach phpvirtualbox by entering the following URL: "http://[your-OMV5-server]:8080/" in for instance "Firefox"

    The default username and password for phpvirtualbox is admin/admin

    Start and Stop VM’s automaticly on boot and shutdown
    nano /etc/default/virtualbox


    "[CTRL] X Y [Enter]" - Save the file.

    nano /etc/vbox/autostart.cfg

    default_policy = deny
    # Create an entry for each user allowed to use autostart
    vbox = {
    allow = true

    "[CTRL] X Y [Enter]" - Save the file.

    sudo chgrp vboxusers /etc/vbox
    sudo chmod 1775 /etc/vbox

    Choose VMs to automatically start and stop

    The first time a user configures autostart, the command: VBoxManage setproperty autostartdbpath /etc/vbox needs to be run.
    Note: The autostart options are stored in the /etc/vbox file, and the VM itself. If moving the vm, the options may need to be set again.
    VBoxManage modifyvm <uuid|vmname> --autostart-enabled <on|off>
    You can also: VBoxManage modifyvm <uuid|vmname> --autostop-type <disabled|savestate|poweroff|acpishutdown>

    su vbox
    VBoxManage setproperty autostartdbpath /etc/vbox

    VBoxManage modifyvm [servername 1] --autostart-enabled on
    VBoxManage modifyvm [servername 2] --autostart-enabled on --autostart-delay 120
    VBoxManage modifyvm [servername 3] --autostart-enabled on --autostart-delay 300

    VBoxManage modifyvm [servername 1] --autostop-type savestate
    VBoxManage modifyvm [servername 2] --autostop-type savestate
    VBoxManage modifyvm [servername 3] --autostop-type savestate

    Restart VirtualBox autostart service

    su root

    sudo service vboxautostart-service restart

    Virtualbox uses port 9000 to 9100 for VRDP, when you want to use Portainer in OMV you have to change these ports to another range for example 9100-9200. You can find these settings in phpvirtualbox, under settings of the VM, display -> remote display tab.

    You can also change the parameter in the config.php of phpvirtualbox to reflect the correct ports:

    var $vrdeports = '9100-9200';

    Tested autoshutdown, now OMV waits until the machines are in "Saved State" before shutting the machine down. This works now. In OMV4 with the OMV-Extra's Virtualbox plugin installed the machines get aborted.

    Good luck!!!

    Regards, Roru69

    Edited 17 times, last by roru69: Removed some dutch words that were still in the post. Corrected some Typo's. Changed the repository from Bionic to Buster (tested and works). Corrected some small errors. ().

  • Continued - Backup Virtual Machine Bash script with OMV5.

    nano /var/lib/vbox/

    (Change the variables in below scipt, copy and paste bash scipt below, save with "[CTRL] X Y [Enter]")
    The "declare -a REBOOT" part is for machines which need a reboot after Saving State. In some cases that is needed to initialize USB hardware which is connected.

    chown -R vbox:vboxusers /var/lib/vbox
    chmod +x /var/lib/vbox/

    Create a scheduled job within the OMV5 Webgui
    Time of execution: Certain Date
    Minute: 0
    Hour: 4
    Day of month: *
    Day of week: Wednesday
    User: vbox
    Command: /var/lib/vbox/
    Comment: Backup of Virtualbox Machines

    Enable and save the job.
    Above is an example of a job that backups the Virtualbox Machines every Wednesday at 04:00.

    The script is initially made by Vorkbaard. I edited the script to add more logging and introduced a reboot because i noticed that i had a machine where the USB Cardreader didn't work when it was started from "Saved State".

    Regards RoRu69

    Edited 10 times, last by roru69: Added the steps needed to get the script running and executed on demand ().

  • roru69

    Changed the title of the thread from “Guide: Virtualbox 6.x on OMV5 and Debian 10.x” to “Guide: Virtualbox 6.x and PHPVirtualbox on OMV5 and Debian 10.x”.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!