Skip to content

Instantly share code, notes, and snippets.

@komuw
Last active February 16, 2022 09:13
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save komuw/10991598 to your computer and use it in GitHub Desktop.
Save komuw/10991598 to your computer and use it in GitHub Desktop.
how to properly install virtualbox on chromebook.
Taken from:https://github.com/dnschneid/crouton/wiki/Build-kernel-headers-and-install-Virtualbox-(x86)
https://github.com/dnschneid/crouton/wiki/Build-kernel-headers-and-install-Virtualbox-(x86)
only pasted here so I can be sure I will always have it.
NB: do this ALTERNATIVE INSTEAD(it solves multi reboots on vagrant up)
1. build kernel headers as per this diff method: https://github.com/divx118/crouton-packages/blob/master/README.md
ie: from a shell in ua chroot(ubuntu)
$ cd ~
$ wget https://raw.githubusercontent.com/divx118/crouton-packages/master/setup-headers.sh
$ sudo sh setup-headers.sh
2. install this particular virtualbox(http://download.virtualbox.org/virtualbox/4.3.14/virtualbox-4.3_4.3.14-95030~Ubuntu~raring_amd64.deb)
ie version: VirtualBox 4.3.14 (released July 15th 2014)
General info
This guide is tested on an HP chromebook 14 which has an Intel Celeron 2955U CPU. However it should work for any x86 chromebook. Just be sure you clone the right kernel source for your device.
For installing virtualbox we need a kernel headers package to compile the virtualbox modules. However there are no kernel headers available to install that work with the kernel of your chromebook. That is why we need to build our own. In the section below we explain how you can do that.
Getting the kernel source
There's a git repo where the kernel sources can be found, but you have to know which branch you're on. Branches can be identified by chromeos-version where version is your kernel version.
On the HP chromebook 14 I have kernel 3.8.11 so I need the chromeos-3.8 branch.
Note: Older devices will use "kernel" instead of "kernel-next".
First we need some tools installed in our chroot. I did this on a precise with xfce chroot, but it should also work on others.
Note: All the shell commands on this page need to be done in the shell of your chroot(ie inside ubuntu) if not specified otherwise.
$ sudo apt-get install git-core make kernel-package
#Cloning the kernel branch chromeos-3.8 to our home folder.
$ cd ~
$ git clone https://chromium.googlesource.com/chromiumos/third_party/kernel -b chromeos-3.8
#Before we start building we need to setup our kernel config. More info can be found on the chromium dev pages
#First I had to run with -Werror, because I got one small problem when building some wifi module. This could be a problem with the gcc compiler I used.
#Just use your favorite text editor and edit "chromeos/config/base.config" in the kernel-next dir.
$ cd kernel
$ vi chromeos/config/base.config
#Search for CONFIG_ERROR_ON_WARNING=y and make it CONFIG_ERROR_ON_WARNING=n
#Look at which flavor you need for your chromebook. We have x86_64 so we setup the config for chromeos-intel-pineview.
#More info on which flavor to choose see the kernel config info site mentioned above.
$ ./chromeos/scripts/prepareconfig chromeos-intel-pineview
$ make oldconfig
#Building kernel headers and kernel image
#Now we can start building kernel_headers and kernel_image. Note that this will take some time.
$ make-kpkg --rootcmd fakeroot kernel_image kernel_headers
#After it is finished without errors you should now see two *.deb files in the directory above kernel-next. If you followed #this guide to the letter it should be your home dir.
$ ls -al ~ | grep .deb
-rw-r--r-- 1 root root 8340026 Dec 27 18:08 linux-headers-3.8.11_3.8.11-10.00.Custom_amd64.deb
-rw-r--r-- 1 root root 7656850 Dec 27 18:07 linux-image-3.8.11_3.8.11-10.00.Custom_amd64.deb
#Installing kernel headers/image
#Before we can install we need to umount /lib/modules which is bind mounted in enter-chroot.
#We also need to disable module_locking for loading the vboxdrv kernel modules and actually load the modules.
#This can be done in rc.local.
#Create the following /etc/rc.local or add this to your /etc/rc.local if you already have one.
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# umount bindmounts /lib/modules from enter-chroot
for m in `cat /proc/mounts | /usr/bin/cut -d ' ' -f2 | grep /lib/modules| grep -v "^/$" `; do
umount "$m"
done
# disable module locking and try to load vboxdrv
if [ -f /etc/init.d/vboxdrv ]; then
chmod 0666 /sys/module/lsm/parameters/module_locking
echo 0 > /sys/module/lsm/parameters/module_locking
/etc/init.d/vboxdrv start
i="0"
while [ $i -lt 5 ]; do
loaded=$( cat /proc/modules|grep -o vboxdrv ) || loaded="empty"
if [ "$loaded" = "vboxdrv" ]; then
break
fi
sleep 1
i=$((i+1))
done
echo 1 > /sys/module/lsm/parameters/module_locking
chmod 0400 /sys/module/lsm/parameters/module_locking
fi
exit 0
#end of file contents
#Also be sure to change the execution bit
$ sudo chmod +x /etc/rc.local
#You can now logout and login again in your chroot to see if the script rc.local works.
#If all is well, everything in /lib/modules is umounted so we can install our two deb files.
#You can check this with the following.
$ cat /proc/mounts | grep /lib/modules
sudo dpkg -i linux-image-3.8.11_3.8.11-10.00.Custom_amd64.deb
sudo dpkg -i linux-headers-3.8.11_3.8.11-10.00.Custom_amd64.deb
#Now you can download virtualbox and install it. After installing, logout of your chroot and log back in. Virtualbox drivers #should now be loaded. You can check it by looking at lsmod or cat /proc/modules.
#Note: The vboxdrv will stay loaded when you log out of your chroot.
#You can unload it before logging out with
$ sudo /etc/init.d/vboxdrv stop
#Or in a chronos shell
$ sudo /sbin/rmmod vboxpci
$ sudo /sbin/rmmod vboxnetadp
$ sudo /sbin/rmmod vboxnetflt
$ sudo /sbin/rmmod vboxdrv
@TheEssem
Copy link

TheEssem commented Sep 7, 2017

Can you please update this guide to use Markdown? It's hard to read right now.

@hermanpg
Copy link

hermanpg commented Jan 27, 2018

Did you (or anybody else) recently use this method to install on a chromebook? I followed the procedure and got stuck in a kernel compile which I am unfortunately unable to resolve. If anybody is interested or willing to help to get this working please let me know. I am trying to get virtualbox installed on an Acer Chromebook 14 for Work (CP5-471). I have Ubuntu 16 installed. I am trying to compile kernel version 3.18. I get stuck at the following error after appx 10 minutes of the compile process:

drivers/gpu/drm/udl/udl_connector.c17:27: fatal error: udl_connector.h: no such file or directory
compilation terminated.
Scripts/Makefile.build:257: recipe for target 'drivers/gpu/drm/udl/udl_connector.o' failed

... (etc)
make: *** [debian/stamp/build/kernel] Error 2

Thanks in advance,

Herman

Screenshot:

screenshot from 2018-01-27 10-30-16

@vincentsmh
Copy link

Edit drivers/gpu/drm/udl/udl_connector.c and modify ...

#include <udl_connector.h>
to
#include "udl_connector.h"

Hope this is help for you.

@riyaadazad
Copy link

Does this apply? dnschneid/crouton#4026 ("The internet is wrong and all the tutorials are broken")

@Tom38705
Copy link

Tom38705 commented Mar 8, 2021

oh lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment