How to install VirtualBox 6.x with phpVirtualbox web interface on Debian 11 bullseye/openmediavau...

How to install VirtualBox 6.x with phpVirtualbox web interface on Debian 11 bullseye/openmediavault 6

The new Open Media Vault 6 uses Debian 11 as the base system. And for a long time, Virtual Box didn't support it. After it did, everyone whose using OMV6 has gone to the KVM platform for virtualization needs. And for the cause of that, everything related to this topic is either fractions or incomplete. I have tried KVM for a short time, and the overall experience of that is just something off for me. So I am doing this with Virtual Box again and writing this down for later use, or maybe it just helps someone who's in flavoured with me in Virtual Box.

1. Prerequisites:

A working system could be either a Debian 11 bullseye or the open media vault 6, which is essentially Debian 11.

2. Plans:

  1. Install Virtual Box 6 headless version.
  2. Install Docker to containerize the web interface coming from the project phpvirtualbox.
  3. Setting up phpvirtualbox using Docker/Docker Compose.

3. Installations:

3.1 Install Virtual Box

First, before we install the Virtual Box itself, we need to tackle the dependencies for it to run without errors.

Use this command line to install them.

sudo apt install wget build-essential python2

Next, we need to download the installer. There're many ways to install Virtual Box on a Linux system. But for the sake of this tutorial, I'll go with the installer one.

Here's a list of all the releases: https://download.virtualbox.org/virtualbox/

Because the PHP program for the web interface is only supporting up to 6.x, so we'll go with 6.1.40, which is the last version before 7.

Use wget to download the files straight into the file system. And then, add the execute permission for the installer and run it.

# download file
wget https://download.virtualbox.org/virtualbox/6.1.40/VirtualBox-6.1.40-154048-Linux_amd64.run

# grant permission
chmod u+x VirtualBox-6.1.40-154048-Linux_amd64.run

# execute it
sudo ./VirtualBox-6.1.40-154048-Linux_amd64.run

Virtual Box extension pack is a binary package that extends the functionality of Virtual Box. It provides extensions like USB support and hardware pass-through. But for the most important ones, we need it for RDP, which stands for Remote Desktop Protocol. Because it is headless, we can't exactly see anything unless we use another system to connect to it. That's why we have to install it.

# download
wget https://download.virtualbox.org/virtualbox/6.1.40/Oracle_VM_VirtualBox_Extension_Pack-6.1.40.vbox-extpack

# installation
sudo vboxmanage extpack install --replace Oracle_VM_VirtualBox_Extension_Pack-6.1.40.vbox-extpack

Next, we need to create a user and a user group for Virtual Box.

# create user with a home directory
sudo useradd -m username

# change its password
sudo passwd username

Log in as that user and add a user group for yourself.

sudo usermod -aG vboxusers $(id -un)

You can verify it by typing id -nG. It will show all your groups like this:

users www-data vboxusers home

Then we reboot for things to kick in.

reboot

Up to this point, you should be able to verify the installation by this.

virtualbox -h

If nothing goes wrong, then it will output something like this:

Oracle VM VirtualBox VM Selector v6.1.40
(C) 2005-2022 Oracle Corporation
All rights reserved.

No special options.

If you are looking for --startvm and related options, you need to use VirtualBoxVM.

But of course, it goes wrong on my side...

See if you're having the same issues I have:

3.1.1 Common errors:

1. Header problem:

WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (6.0.0-0.deb11.2-amd64) or it failed to
         load. Please recompile the kernel module and install it by

           sudo /sbin/vboxconfig

         You will not be able to start VMs until this problem is fixed.

And we do as it says:

sudo /sbin/vboxconfig

Output something like this:

vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    linux-headers-amd64 linux-headers-6.0.0-0.deb11.2-amd64
This system is currently not set up to build kernel modules.
Please install the Linux kernel "header" files matching the current kernel
for adding new hardware support to the system.
The distribution packages containing the headers are probably:
    linux-headers-amd64 linux-headers-6.0.0-0.deb11.2-amd64
    ...

This is caused by not having the headers lib installed. Follow what it suggests and install them all.

sudo apt install linux-headers-amd64 linux-headers-6.0.0-0.deb11.2-amd64

Then try these two again:

sudo /sbin/vboxconfig

virtualbox -h

2. GL problem:

If it shows something like:

/opt/VirtualBox/VirtualBox: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory

That's because it lacks OpenGL support. Install this:

apt install libglu1-mesa

If it works, congratulations! 🙌🙌

Now log in as the user you created earlier and do this:

vboxwebsrv -b -H0.0.0.0 -p10082 -F/vm/logs/vboxwebsrv.log

This is the headless Virtual Box server side for accepting HTTP requests.

-b means it starts in the backgroud.
-H for listening on all addresses.
-p for which port you want it to listen to.
-F is the file for storing logs.

3. Directory problem:

It may crash at once if you don't have a home directory for this user. Like this:

vboxwebsrv: error: failed to initialize COM! hrc=NS_ERROR_FAILURE

In case that happens, create a home directory manually for it. It will put the config stuff in the home directory of the current user.

You may use the following ways to check if the service is up.

# expect outputs
curl localhost:port

# expect the process is in the list
ps -ef | grep vbox

# ditto
lsof -i :port

If the service is up, then we're good for this part.

3.2 Get Docker Engine

For different ways of installing Docker, see here: https://docs.docker.com/engine/install/debian/

Use the convenience script:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh

That should do everything right, but you can test it out if you want.

3.3 Run phpvirtualbox with Docker

phpvirtualbox is a web interface that allows you to interact with a remote Virtual Box instance.

Here's the project: https://github.com/phpvirtualbox/phpvirtualbox

But we're not going to deploy it with a PHP server and all that hassles. Here's another project based on phpvirtualbox: https://github.com/jazzdd86/phpVirtualbox

Which turns the former into a Docker image that we can easily set up with just one command line:

docker run --name <a-name-here> --restart=unless-stopped \
    -p <port-for-access-the-gui>:80 \
    -e ID_HOSTPORT=<the-host-ip:port> \
    -e ID_NAME=<a-random-name-you-like> \
    -e ID_USER=<your-username> \
    -e ID_PW='<your-password>' \
    -e CONF_browserRestrictFolders="<directories-you-want-the-vm-to-have-access-to>" \
    -d jazzdd/phpvirtualbox

You'll need to change all the fields in quotes. Here's a reference case:

docker run --name vbox --restart=always \
    -p 10080:80 \
    -e ID_HOSTPORT=192.168.1.1:10082 \
    -e ID_NAME=VboxServer \
    -e ID_USER=vbox \
    -e ID_PW='vbox' \
    -e CONF_browserRestrictFolders="/vm" \
    -d jazzdd/phpvirtualbox

After it's up, navigates to http://the-host-ip:port in the browser and use the default account: admin/admin to log in. And you should see a GUI that somewhat resembles the Virtual Box standard alone version.

4. One more thing:

There's a catch you might wanna know: This phpvirtualbox GUI is not 100% aligned with the Virtual Box that we install. Which includes these problems (but not least):

1. Some settings just won't work.

There're some settings in the GUI that you won't be able to change. I've noticed at least the Keyboard, Mouse, Audio and Video accelerations, amongst other options. They remain the same even if you have saved them. It's not too bad. But not brilliant, if you ask. If you need them working, there's a workaround: Use the Virtual Box command line tool to change these settings. You can set up the basics via the GUI and then tweak those little things in the terminal.

# to list the virtual machines, copy their name/id
vboxmanage list vms

# check their info
vboxmanage showvminfo vm-name

# change audio settings
vboxmanage modifyvm vm-name --audioin on --audioout on

# change keyboard, mouse settings
vboxmanage modifyvm vm-name --keyboard usb --mouse usb

# get a list of all the options
vboxmanage modifyvm

2. The RDP from Virtual Box isn't perfect.

Even though we need the RDP from the extension pack to initialize the virtual machines out of the box yet, it is not perfect. I have noticed that the audio from the RDP from the Virtual Box host is not working right. It turns everything into a stuttering, high-pitched sound. It sounds like a bunch of chipmunks speaking through a Gater FX. And the workaround is to have the virtual machines set up the RDP from their system, and we connect to those. For example, in Windows. Turn on the Remote Desktop feature in Settings, and instead of connecting to the host IP, connect to the guest IP with the bridged network. And the sound will be back to normal again.

And here's all for today. Thanks for reading~

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,233评论 4 360
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,013评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,030评论 0 241
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,827评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,221评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,542评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,814评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,513评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,225评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,497评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,998评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,342评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,986评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,055评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,812评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,560评论 2 271
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,461评论 2 266

推荐阅读更多精彩内容