This is all from Redditer michaela_elise. (Thank you!)
There is a script that will get and build the ChromeOS 3.4 kernel on your Ubuntu install. This is great because now we can compile kernel mods.
The apt-get install linux-headers-$(uname -r)
does not work because 3.4.0 seems to be a Google specific build and you cannot just get those headers.
I have added the script here. Just run it as sudo and let it go. When it is done, you will have /usr/src/kernel (this the source and compiled kernel), /usr/src/linux-headers-3.4.0, it also installs this version of the kernel.
#!/bin/bash
set -x
#
# Grab verified boot utilities from ChromeOS.
#
mkdir -p /usr/share/vboot
mount -o ro /dev/sda3 /mnt
cp /mnt/usr/bin/vbutil_* /usr/bin
cp /mnt/usr/bin/dump_kernel_config /usr/bin
rsync -avz /mnt/usr/share/vboot/ /usr/share/vboot/
umount /mnt
#
# On the Acer C7, ChromeOS is 32-bit, so the verified boot binaries need a
# few 32-bit shared libraries to run under ChrUbuntu, which is 64-bit.
#
apt-get install libc6:i386 libssl1.0.0:i386
#
# Fetch ChromeOS kernel sources from the Git repo.
#
apt-get install git-core
cd /usr/src
git clone https://git.chromium.org/git/chromiumos/third_party/kernel.git
cd kernel
git checkout origin/chromeos-3.4
#
# Configure the kernel
#
# First we patch ``base.config`` to set ``CONFIG_SECURITY_CHROMIUMOS``
# to ``n`` ...
cp ./chromeos/config/base.config ./chromeos/config/base.config.orig
sed -e \
's/CONFIG_SECURITY_CHROMIUMOS=y/CONFIG_SECURITY_CHROMIUMOS=n/' \
./chromeos/config/base.config.orig > ./chromeos/config/base.config
./chromeos/scripts/prepareconfig chromeos-intel-pineview
#
# ... and then we proceed as per Olaf's instructions
#
yes "" | make oldconfig
#
# Build the Ubuntu kernel packages
#
apt-get install kernel-package
make-kpkg kernel_image kernel_headers
#
# Backup current kernel and kernel modules
#
tstamp=$(date +%Y-%m-%d-%H%M)
dd if=/dev/sda6 of=/kernel-backup-$tstamp
cp -Rp /lib/modules/3.4.0 /lib/modules/3.4.0-backup-$tstamp
#
# Install kernel image and modules from the Ubuntu kernel packages we
# just created.
#
dpkg -i /usr/src/linux-*.deb
#
# Extract old kernel config
#
vbutil_kernel --verify /dev/sda6 --verbose | tail -1 > /config-$tstamp-orig.txt
#
# Add ``disablevmx=off`` to the command line, so that VMX is enabled (for VirtualBox & Co)
#
sed -e 's/$/ disablevmx=off/' \
/config-$tstamp-orig.txt > /config-$tstamp.txt
#
# Wrap the new kernel with the verified block and with the new config.
#
vbutil_kernel --pack /newkernel \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--version 1 \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--config=/config-$tstamp.txt \
--vmlinuz /boot/vmlinuz-3.4.0 \
--arch x86_64
#
# Make sure the new kernel verifies OK.
#
vbutil_kernel --verify /newkernel
#
# Copy the new kernel to the KERN-C partition.
#
dd if=/newkernel of=/dev/sda6
Let me know how it works for you. I have compiled and insmod'd kernel modules with this.
Here is how you #include the headers
include </usr/src/linux-headers-3.4.0/include/linux/module.h>
include </usr/src/linux-headers-3.4.0/include/linux/kernel.h>
include </usr/src/linux-headers-3.4.0/include/linux/init.h>
include </usr/src/linux-headers-3.4.0/include/linux/syscalls.h>
//or whatever you need specifically
And I am guessing you already know this but in case someone does not This is the basic makefile for kernel mods. Once you use the script I linked, you can just run make with this makefile and all is well. replace kmod.o with whatever your source.c is called except keep it as .o
Makefile obj-m += kmod.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
p.s. I had to modify sysinfo.h because the type __kernel_ulong_t was not defined. I changed it to uint64_t. This seems to work just fine. my mods have had no problems thus far. Make sure if you have to do this to edit the sysinfo.h in the 3.4.0 headers
p.p.s. This fixes the issues with vbox and vmware player!!! They just install and work!!