Building and installing a patched ubuntu kernel for the surface pro 3

Some of you have been asking for this tutorial so I hope this is easy to follow.
I am sort of repeating the instructions here


  • You have followed the instructions on this post
  • Installed Ubuntu or Ubuntu Gnome 15.04
  • Will be using an Ubuntu machine to perform the following steps. I recommend a faster machine than the surface but if you must the surface will be enough
  • You are doing all this in your home directory. It simplifies not having to set permissions.


  • Before getting started run these commands. These are necessary for the build process
    sudo apt-get install kernel-wedge
    sudo apt-get install gawk
    sudo apt-get install git
  • Make sure you have plenty of disk space I think after the build the project ballooned to 11.5 GB. The actual kernel packages are a few MB’s in size.
  • Prepare to wait. Depending on your machine this will take about an hour (i7, 16GB ram, SSD) to a few hours (Surface Pro 3)

Getting the projects

Lets get started by creating a folder for our source files and patches and navigating to it
mkdir ~/source && cd ~/source

Get the kernel. This will create a folder called ubuntu-vivid
git clone git://

Get the patches. This will create a folder called linux-surfacepro3

so right now you should have the following structure

  • ~/source/
    • ubuntu-vivid/
    • linux-surfacepro3/

Adding the patches

Now is when the fun starts. Navigate to the ubuntu-vivid folder
cd ubuntu-vivid

Apply the patches

patch -p1 --ignore-whitespace -i ../linux-surfacepro3/battery.patch
patch -p1 --ignore-whitespace -i ../linux-surfacepro3/buttons.patch
patch -p1 --ignore-whitespace -i ../linux-surfacepro3/cam.patch
patch -p1 --ignore-whitespace -i ../linux-surfacepro3/wakeup.patch
patch -p1 --ignore-whitespace -i ../linux-surfacepro3/change-default-console-loglevel.patch

I am skipping the multi-touch patch because I had problems with it

Incrementing the version

edit ubuntu-vivid/debian.master/changelog and increment the version number by 1
nano debian.master/changelog

example: 3.19.0-13.13 -> 3.19.0-13.14
mine was 3.19.0-17.17 yours might be the same

Build the kernel

Prepare for the build
fakeroot debian/rules clean

Build the new kernel
DEB_BUILD_OPTIONS=parallel=4 AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binary-generic

You will be prompted about adding a new driver (the ones for the buttons) type yes
Now sit, relax and wait. This part takes a while!
If you run into build errors you will have to google it because I am not an expert on kernel building. I could barely troubleshoot my own problems 🙂

If your build was successful, there will be 5 .deb files in the ~/source folder you can do the next to double check
cd ..

Installing the kernel

Copy the .deb files

Using a flash drive, network drive etc copy all the .dev files to a folder in your surface home directory.
I recommend saving them under ~/kernel

In the terminal navigate to the new kernel folder
cd ~/kernel

Install the kernel

sudo dpkg -i linux-headers* linux-image*

Update the Grub

sudo grub-install

This is a quote from the author of the article I am referencing

I have found that sometimes after touching grub, the first boot may take a few minutes. DO NOT STOP IT, let the system boot. Afterwards, should be fast again

Recover from grub prompt or UEFI loop

If you have this problem refer to the original article here and read the instructions at the bottom of the page

Final thoughts

I really enjoyed creating my own kernel and seeing how great it worked in my surface.

Windows is my primary OS on the surface but now I feel confident that I can do some real work in ubuntu and not worry about killing the battery or not being able to video chat or not being able to adjust the volume.
I am very glad that sleep works now… at least it seems to work 🙂

One thing I hate is that when the SP3 wakes up the touchscreen stops working. To make it work again you can just log out and log back in, no need to restart.

I have to say that Ubuntu Gnome looks absolutely stunning in the SP3. Way better than regular ubuntu or even windows 8.

The touch screen has some gestures so explore.

One last thing. The other day I lost the sleep ability in windows, to fix this I had to reinstall windows. I chose to wipe the drive and start fresh. This doesn’t touch your Ubuntu partition. This fixed my sleep problem but removed Grub. A nice surprise was that you can boot from window into Ubuntu the same way you would boot to a usb stick, by swiping from the right settings>change pc settings>Update and recovery>recovery>advanced>restart

The next blue screen will give you the option to boot from a usb device clicking that will show Ubuntu
since I use windows primarily, this is perfect for me. If you want grub back. Open the command prompt in windows with administrator rights and run this command   bcdedit /set {bootmgr} path \EFI\ubuntu\shimx64.efi
to restore to the windows boot loader run this command bcdedit /set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi

update 1: I have uploaded a kernel with all the patches already applied surface-pro-3-linux-kernel-3.19.0-27.29


  1. Had to compile the kernel in the cloud in order not to wait for ages LOL
    Thank you so much for this guide man! Only problem I have is that the power button triggers the shutdown popup instead of simply locking the screen… any settings I have to change?
    Thanks a lot


    1. Never mind, just found the answer to my question into the gnome configuration utility…
      Please post updates if you find workaround for the multi-touch patch or the touchscreen problem when waking up, thanks!!


    2. Awesome! maybe you can show us what you used to do it. I am glad it worked for you


  2. So when I used your uploaded headers I got an error
    “errors were encountered while processing

    Did you ever have that problem?


    1. Thanks for everything !!!

      I however have the same problem as Poesia Vogona …. And I need the headers to compile some other drivers (DL) so I am stuck !


      1. Sorry to hear that. I am not sure how to fix that.


    2. I checked again and yeah I did get that error. Didn’t notice before. Everything seems to be working thought. I will have to research that error more later


    3. yeah, but still worked. Did it generate the .deb files for you?


      1. could you post the .deb files you are currently using, I wasn’t able to install you linux-headers* properly because I didn’t have the same version of linux headers installed at the time, is there a way around this so I can install it properly?


  3. Wanted to let you know about a bugfix to above code. I re-installed Windows 10 and the GRUB bootloader disappeared. I used the line of code “bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi” and that fixed the GRUB loading issue, however, it triggered a problem with invalid SecureBoot . After doing some research, I found that if you use shimx64.efi instead, ie “bcdedit /set {bootmgr} path \EFI\ubuntu\shimx64.efi” then it resolves the SecureBoot issue. Essentially shim is a way to boot onto a computer with SecureBoot active.

    Hope this helps somebody!


    1. That is a great find. Thank you. I have updated the post accordingly


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.