How to install VirtualBox on Scaleway's x86_64 servers

Scaleway offers reasonably priced dedicated servers that are now even cheaper than Hetzner's robo market.

I wanted to use them for doing Ansible tests using Vagrant. The problem is you can't easily install VirtualBox there, and it's needed for Vagrant to work.

Here's a script that should do most of the work for you:


#!/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/
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)

make -j${NUM_CORES} oldconfig include modules

sudo -E /sbin/rcvboxdrv setup

# Check that it's fine.
VBoxManage --version


I hope it works for you. It worked for me. See also the gist here. You can download it directly from your box:


$ wget https://gist.githubusercontent.com/nictuku/13afc808571e742d3b1aaa0310ee8a8d/raw/d41ac5c7e1eb0c030a67b7bdaab69981217f46ed/scaleway-virtualbox-module-build.sh
Let me know how it goes. Have fun!

Popular posts from this blog

How to crack Windows Terminal Services 3 month trial

Caveats about Linux connection tracking and high traffic servers

German to English dictionary in the Kindle