4/17/2014 - 3:21 PM

how to properly install virtualbox on chromebook.

how to properly install virtualbox on chromebook.

Taken from:
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:
    ie: from a shell in ua chroot(ubuntu)
      $ cd ~
      $ wget
      $ sudo sh
    2. install this particular virtualbox( 
     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 -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

#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"

# 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

    while [ $i -lt 5 ]; do
        loaded=$( cat /proc/modules|grep -o vboxdrv ) || loaded="empty"
        if [ "$loaded" = "vboxdrv" ]; then
        sleep 1
    echo 1 > /sys/module/lsm/parameters/module_locking
    chmod 0400 /sys/module/lsm/parameters/module_locking

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