Friday, 5 April 2019

How to install VirtualBox on Ubuntu 18.04

Go to VirtualBox Linux Downloads page and download the latest .deb package for Ubuntu 18.04.

Install it:

$ sudo dpkg -i virtualbox-6.0_6.0.4-128413_Ubuntu_bionic_amd64.deb
[sudo] password for user:
Selecting previously unselected package virtualbox-6.0.
(Reading database ... 178490 files and directories currently installed.)
Preparing to unpack virtualbox-6.0_6.0.4-128413_Ubuntu_bionic_amd64.deb ...
Unpacking virtualbox-6.0 (6.0.4-128413~Ubuntu~bionic) ...
dpkg: dependency problems prevent configuration of virtualbox-6.0:
 virtualbox-6.0 depends on libqt5core5a (>= 5.9.0~beta); however:
  Package libqt5core5a is not installed.
 virtualbox-6.0 depends on libqt5gui5 (>= 5.4.0); however:
  Package libqt5gui5 is not installed.
 virtualbox-6.0 depends on libqt5opengl5 (>= 5.0.2); however:
  Package libqt5opengl5 is not installed.
 virtualbox-6.0 depends on libqt5printsupport5 (>= 5.0.2); however:
  Package libqt5printsupport5 is not installed.
 virtualbox-6.0 depends on libqt5widgets5 (>= 5.7.0); however:
  Package libqt5widgets5 is not installed.
 virtualbox-6.0 depends on libqt5x11extras5 (>= 5.6.0); however:
  Package libqt5x11extras5 is not installed.
 virtualbox-6.0 depends on libsdl1.2debian (>= 1.2.11); however:
  Package libsdl1.2debian is not installed.

dpkg: error processing package virtualbox-6.0 (--install):
 dependency problems - leaving unconfigured
Processing triggers for systemd (237-3ubuntu10.15) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for shared-mime-info (1.9-2) ...
Errors were encountered while processing:
 virtualbox-6.0

I tried to fix the error with:

$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree     
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libdouble-conversion1 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5opengl5 libqt5printsupport5 libqt5svg5 libqt5widgets5 libqt5x11extras5
  libsdl1.2debian libxcb-xinerama0 qt5-gtk-platformtheme qttranslations5-l10n
Suggested packages:
  qt5-image-formats-plugins qtwayland5
The following NEW packages will be installed
  libdouble-conversion1 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5opengl5 libqt5printsupport5 libqt5svg5 libqt5widgets5 libqt5x11extras5
  libsdl1.2debian libxcb-xinerama0 qt5-gtk-platformtheme qttranslations5-l10n
0 to upgrade, 14 to newly install, 0 to remove and 11 not to upgrade.
1 not fully installed or removed.
Need to get 9,896 kB of archives.
After this operation, 42.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 libdouble-conversion1 amd64 2.0.1-4ubuntu1 [33.0 kB]
Get:2 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libqt5core5a amd64 5.9.5+dfsg-0ubuntu2 [2,037 kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libqt5dbus5 amd64 5.9.5+dfsg-0ubuntu2 [195 kB]                                                 
Get:4 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libqt5network5 amd64 5.9.5+dfsg-0ubuntu2 [633 kB]                                               
Get:5 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libxcb-xinerama0 amd64 1.13-2~ubuntu18.04 [5,264 B]                                             
Get:6 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libqt5gui5 amd64 5.9.5+dfsg-0ubuntu2 [2,566 kB]                                                 
Get:7 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libqt5widgets5 amd64 5.9.5+dfsg-0ubuntu2 [2,205 kB]                                             
Get:8 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libqt5opengl5 amd64 5.9.5+dfsg-0ubuntu2 [132 kB]                                               
Get:9 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libqt5printsupport5 amd64 5.9.5+dfsg-0ubuntu2 [178 kB]                                         
Get:10 http://gb.archive.ubuntu.com/ubuntu bionic/universe amd64 libqt5x11extras5 amd64 5.9.5-0ubuntu1 [8,596 B]                                                   
Get:11 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 libsdl1.2debian amd64 1.2.15+dfsg2-0.1 [174 kB]                                                       
Get:12 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 libqt5svg5 amd64 5.9.5-0ubuntu1 [128 kB]                                                               
Get:13 http://gb.archive.ubuntu.com/ubuntu bionic-updates/main amd64 qt5-gtk-platformtheme amd64 5.9.5+dfsg-0ubuntu2 [117 kB]                                       
Get:14 http://gb.archive.ubuntu.com/ubuntu bionic/main amd64 qttranslations5-l10n all 5.9.5-0ubuntu1 [1,485 kB]                                                     
Fetched 9,896 kB in 38s (263 kB/s)                                                                                                                                 
Selecting previously unselected package libdouble-conversion1:amd64.
(Reading database ... 179318 files and directories currently installed.)
Preparing to unpack .../00-libdouble-conversion1_2.0.1-4ubuntu1_amd64.deb ...
Unpacking libdouble-conversion1:amd64 (2.0.1-4ubuntu1) ...
Selecting previously unselected package libqt5core5a:amd64.
Preparing to unpack .../01-libqt5core5a_5.9.5+dfsg-0ubuntu2_amd64.deb ...
Unpacking libqt5core5a:amd64 (5.9.5+dfsg-0ubuntu2) ...
Selecting previously unselected package libqt5dbus5:amd64.
Preparing to unpack .../02-libqt5dbus5_5.9.5+dfsg-0ubuntu2_amd64.deb ...
Unpacking libqt5dbus5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Selecting previously unselected package libqt5network5:amd64.
Preparing to unpack .../03-libqt5network5_5.9.5+dfsg-0ubuntu2_amd64.deb ...
Unpacking libqt5network5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Selecting previously unselected package libxcb-xinerama0:amd64.
Preparing to unpack .../04-libxcb-xinerama0_1.13-2~ubuntu18.04_amd64.deb ...
Unpacking libxcb-xinerama0:amd64 (1.13-2~ubuntu18.04) ...
Selecting previously unselected package libqt5gui5:amd64.
Preparing to unpack .../05-libqt5gui5_5.9.5+dfsg-0ubuntu2_amd64.deb ...
Unpacking libqt5gui5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Selecting previously unselected package libqt5widgets5:amd64.
Preparing to unpack .../06-libqt5widgets5_5.9.5+dfsg-0ubuntu2_amd64.deb ...
Unpacking libqt5widgets5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Selecting previously unselected package libqt5opengl5:amd64.
Preparing to unpack .../07-libqt5opengl5_5.9.5+dfsg-0ubuntu2_amd64.deb ...
Unpacking libqt5opengl5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Selecting previously unselected package libqt5printsupport5:amd64.
Preparing to unpack .../08-libqt5printsupport5_5.9.5+dfsg-0ubuntu2_amd64.deb ...
Unpacking libqt5printsupport5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Selecting previously unselected package libqt5x11extras5:amd64.
Preparing to unpack .../09-libqt5x11extras5_5.9.5-0ubuntu1_amd64.deb ...
Unpacking libqt5x11extras5:amd64 (5.9.5-0ubuntu1) ...
Selecting previously unselected package libsdl1.2debian:amd64.
Preparing to unpack .../10-libsdl1.2debian_1.2.15+dfsg2-0.1_amd64.deb ...
Unpacking libsdl1.2debian:amd64 (1.2.15+dfsg2-0.1) ...
Selecting previously unselected package libqt5svg5:amd64.
Preparing to unpack .../11-libqt5svg5_5.9.5-0ubuntu1_amd64.deb ...
Unpacking libqt5svg5:amd64 (5.9.5-0ubuntu1) ...
Selecting previously unselected package qt5-gtk-platformtheme:amd64.
Preparing to unpack .../12-qt5-gtk-platformtheme_5.9.5+dfsg-0ubuntu2_amd64.deb ...
Unpacking qt5-gtk-platformtheme:amd64 (5.9.5+dfsg-0ubuntu2) ...
Selecting previously unselected package qttranslations5-l10n.
Preparing to unpack .../13-qttranslations5-l10n_5.9.5-0ubuntu1_all.deb ...
Unpacking qttranslations5-l10n (5.9.5-0ubuntu1) ...
Setting up libxcb-xinerama0:amd64 (1.13-2~ubuntu18.04) ...
Setting up libdouble-conversion1:amd64 (2.0.1-4ubuntu1) ...
Setting up libsdl1.2debian:amd64 (1.2.15+dfsg2-0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up qttranslations5-l10n (5.9.5-0ubuntu1) ...
Setting up libqt5core5a:amd64 (5.9.5+dfsg-0ubuntu2) ...
Setting up libqt5dbus5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Setting up libqt5network5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Setting up libqt5gui5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Setting up qt5-gtk-platformtheme:amd64 (5.9.5+dfsg-0ubuntu2) ...
Setting up libqt5x11extras5:amd64 (5.9.5-0ubuntu1) ...
Setting up libqt5widgets5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Setting up libqt5printsupport5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Setting up libqt5opengl5:amd64 (5.9.5+dfsg-0ubuntu2) ...
Setting up libqt5svg5:amd64 (5.9.5-0ubuntu1) ...
Setting up virtualbox-6.0 (6.0.4-128413~Ubuntu~bionic) ...
Adding group `vboxusers' (GID 128) ...
Done.
vboxdrv.sh: failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.
Processing triggers for libc-bin (2.27-3ubuntu1) ...

I tried to follow the suggestion:

$ sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.

There were problems setting up VirtualBox.  To re-start the set-up process, run
  /sbin/vboxconfig
as root.

Despite the errors, I tried to launch VirualBox and UI will launch but there was an error message in Terminal:

$ virtualbox
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
         available for the current kernel (x.x.x-xx-generic) 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.

Solution accepted as the best answer for this SO question worked for me:

Creating Machine Owner Key Pair


$ sudo -i
root@bobox:~# whoami
root
root@bobox:~# mkdir /root/module-signing
root@bobox:~# cd /root/module-signing/
root@bobox:~/module-signing#  openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=YOUR_NAME/"
Generating a 2048 bit RSA private key
...........................+++
............+++
writing new private key to 'MOK.priv'
-----
# chmod 600 MOK.priv

Enrolling MOK


root@bobox:~/module-signing# mokutil --import /root/module-signing/MOK.der
input password: 
input password again: 

root@bobox:~/module-signing# reboot

Upon reboot I followed the instructions:









Upon reboot I checked that my certificate has indeed been loaded:

$ dmesg|grep 'EFI:'
[    1.270214] Loaded UEFI:db cert 'Dell Inc. UEFI DB: 5ddb...' linked to secondary sys keyring
[    1.270232] Loaded UEFI:db cert 'Microsoft Corporation UEFI CA 2011: 13ad...' linked to secondary sys keyring
[    1.270246] Loaded UEFI:db cert 'Microsoft Windows Production PCA 2011: a929...' linked to secondary sys keyring
[    1.272543] Loaded UEFI:MokListRT cert 'YOUR_NAME: 9b92...' linked to secondary sys keyring
[    1.272692] Loaded UEFI:MokListRT cert 'Canonical Ltd. Master Certificate Authority: ad91...' linked to secondary sys keyring

Signing VirtualBox kernel files


Difference between .o and .ko file


root@bobox:~# cd /root/module-signing/
root@bobox:~/module-signing# ls
MOK.der  MOK.priv
root@bobox:~/module-signing# nano sign-vbox-modules.sh
root@bobox:~/module-signing# ls
MOK.der  MOK.priv  sign-vbox-modules.sh

root@bobox:~/module-signing# cat sign-vbox-modules.sh 
#!/bin/bash

for modfile in $(dirname $(modinfo -n vboxdrv))/*.ko; do
  echo "Signing $modfile"
  /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 \
                                /root/module-signing/MOK.priv \
                                /root/module-signing/MOK.der "$modfile"
done

root@bobox:~/module-signing# chmod 700 sign-vbox-modules.sh
root@bobox:~/module-signing# ./sign-vbox-modules.sh 
Signing /lib/modules/4.15.0-47-generic/misc/vboxdrv.ko
Signing /lib/modules/4.15.0-47-generic/misc/vboxnetadp.ko
Signing /lib/modules/4.15.0-47-generic/misc/vboxnetflt.ko
Signing /lib/modules/4.15.0-47-generic/misc/vboxpci.ko


Verification

Load VirtualBox driver:

$ modprobe vboxdrv

VirtualBox launched from terminal shows no errors:

$ virtualbox

I also tested running Docker container on the same machine (while running VirtualBox VM with Win 10) and it worked fine:

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:8e3114318a995a1ee497790535e7b88365222a21771ae7e53687ad76563e8e76
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

1 comment:

micheal pan said...

BE SMART AND BECOME RICH IN LESS THAN 3DAYS....It all depends on how fast 
you can be to get the new PROGRAMMED blank ATM card that is capable of
hacking into any ATM machine,anywhere in the world. I got to know about 
this BLANK ATM CARD when I was searching for job online about a month 
ago..It has really changed my life for good and now I can say I'm rich and 
I can never be poor again. The least money I get in a day with it is about 
$50,000.(fifty thousand USD) Every now and then I keeping pumping money 
into my account. Though is illegal,there is no risk of being caught 
,because it has been programmed in such a way that it is not traceable,it 
also has a technique that makes it impossible for the CCTVs to detect 
you..For details on how to get yours today, email the hackers on : (
atmmachinehackers1@gmail.com ). Tell your 
loved once too, and start to live large. That's the simple testimony of how 
my life changed for good...Love you all ...the email address again is ;
atmmachinehackers1@gmail.com