-
-
Save nictuku/13afc808571e742d3b1aaa0310ee8a8d to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Expects Ubuntu 16.06 (xenial) and kernel 4.x. | |
# Based upon a blog post by Zach at http://zachzimm.com/blog/?p=191 | |
set -eux | |
# Have the user call sudo early so the credentials is valid later on | |
sudo whoami | |
for x in xenial xenial-security xenial-updates; do | |
egrep -qe "deb-src.* $x " /etc/apt/sources.list || echo "deb-src http://archive.ubuntu.com/ubuntu ${x} main universe" | sudo tee -a /etc/apt/sources.list | |
done | |
echo "deb http://download.virtualbox.org/virtualbox/debian xenial contrib" | sudo tee -a /etc/apt/sources.list.d/virtualbox.list | |
sudo apt update | |
sudo apt-get install dkms virtualbox-5.0 -y | |
KERN_VERSION=$(uname -r |cut -d'-' -f1) | |
EXTENDED_VERSION=$(uname -r |cut -d'-' -f2-) | |
cd /var/tmp | |
wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-${KERN_VERSION}.tar.xz | |
tar xf linux-${KERN_VERSION}.tar.xz -C /var/tmp/ | |
export KERN_DIR="/var/tmp/linux-${KERN_VERSION}" | |
cd "${KERN_DIR}" | |
zcat /proc/config.gz > .config | |
# Fetch the tools necessary to build the kernel. Using generic because there may not be a package for our $KERN_VERSION. | |
sudo apt-get build-dep linux-image-generic -y | |
NUM_CORES=$(cat /proc/cpuinfo|grep vendor_id|wc -l) | |
# Two options here: full kernel build, which gives no warnings later. Or this partial build: | |
# make -j${NUM_CORES} oldconfig include modules | |
# If you do the partial build, the vboxdrv setup step below will fail and can be fixed with a "sudo modprobe -f vboxdrv" | |
# Since that's annoying, I'm leaving the full build by default. | |
make -j${NUM_CORES} | |
sudo -E /sbin/rcvboxdrv setup | |
VBoxManage --version |
This is great! Thanks for your contribution, Im getting the following error:
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
HOSTCC scripts/extract-cert
scripts/extract-cert.c:21:25: fatal error: openssl/bio.h: No such file or directory
compilation terminated.
scripts/Makefile.host:91: recipe for target 'scripts/extract-cert' failed
make[1]: *** [scripts/extract-cert] Error 1
Makefile:551: recipe for target 'scripts' failed
make: *** [scripts] Error 2
any ideas?
Install libssl-dev
I ran the script but when I fired up the the vm it gets stuck in 'starting vm'. No relevant error message in the log file.
Everything correct, except this: sudo -E /sbin/rcvboxdrv setup
My out:
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.
@voxsoftware Did you solve this error?
For me worked this bootscript x86_64 4.10.8 std #1
thanks for posting this, I ran into two problems:
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
before theapt update
apt install libssl-dev
in order to build the kernel?