How to install Linux on Surface Pro 3

Surface Pro 3 is a very attractive device for buying as a laptop plus tablet replacement. Compared to previous generations of Surface Pro, the third iteration of the Microsoft's premium tablet comes with better battery life, great screen resolution and a really powerful Intel Core processor. For those users who like the Surface Pro 3 hardware but prefer Linux instead of Windows, I would like to share with you a way to install Linux.


Before you proceed, it is necessary to obtain the following devices:

  • USB hub
  • USB mouse
  • USB keyboard
  • Unfortunately, Debian fails to detect the integrated WiFi adapter of Surface Pro 3, so we need to use some USB Ethernet adapter or USB tethering from a smartphone.

Surface Pro 3 supports only UEFI installation, so we need a Linux distro which supports such a way of installation. Debian is one of the UEFI-ready Linux distros. Please note that x86 UEFI is not available in Surface Pro 3, so AMD64 setup image must be used.

Preparing to install Debian

Save your recovery partition to a USB flash drive

Besides the system and data partitions, Surface Pro 3 has a 5 GB recovery partition.
Hard drive partitions
It is possible (and recommended) to copy that partition to an 8 GB or higher capacity flash drive. Type "recovery" without quotes right on the Start screen and click "Create a recovery drive".
Search recovery
After your recovery drive is created, Windows will offer to delete the recovery partition from the SSD drive.
Delete recovery partition
It is safe to accept this, as now you have the recovery flash drive with the same data, so you don't need the SSD partition. If you boot from the recovery flash drive, it will restore the whole SSD layout, including Windows and the recovery partition you delete.

Shrink the C: drive

Right click the C: drive in Disk Management and choose the Shrink command from its context menu. In the next dialog, type the desired free disk space you would like to reserve.
Shrink

Disable hibernation

Linux won't mount NTFS partitions if Windows has been hibernated, so it is necessary to disable hibernation/deep sleep completely. Open the command prompt as administrator and type the following command:

powercfg -hibernate off

Installation

Power off your Surface Pro 3. Now press and hold the "+" volume button and power it on. It will boot to UEFI settings, where you should disable the Secure Boot feature. With Secure Boot disabled, it is possible to boot and install another OS. Shutdown Surface Pro 3 again.

Install Debian Linux

Connect the USB drive with Debian setup to the USB hub. Press and hold the "-" volume button and power on the Surface Pro 3. Run the desired setup mode (GUI/text mode) and do not forget to create linux partitions manually. You can create one root ( / ) partition and put all mount points and even the swap file on it if you do not like having many partitions on your drive.
fdisk

The GRUB2 loader will not be written to MBR due to UEFI. It will be added to EFI instead at

efi/debian/grubx64.efi

Continue to install Debian. After setup finishes, it will restart Surface Pro 3 and Windows 8.1 will be loaded.

On the Start screen, type recovery again, and click Recovery options in search results. Click "Restart now" in the Advanced startup options.
Advanced startup
The Advanced Startup options will be opened. Continue to Use a device - > Debian.
Use a device
Boot to Debian and edit the following file:

/etc/default/grub

Uncomment the following line:

GRUB_GFXMODE=640x480

After that, update the grub configuration with the following command:

update-grub

If you are annoyed that to boot into Debian, you have to show Advanced startup every time from Windows, it is possible to set GRUB2 as the default EFI boot option. In Debian, type the following command:

# efibootmgr
...
Boot Order: 0000,0002,0001
Boot0000* USB Drive
Boot0001* Debian
Boot0002* Windows Boot Manager

Change the boot sequence with the following command:

# efibootmgr --bootorder 0000,0001,0002

Configuring devices

In Debian, the following devices do not work out of the box:

  • WiFi
  • Bluetooth
  • Type Cover 3 with touchpad
  • Stylus
  • Touchscreen

This is unfortunate and not OK. Let's fix it.

WiFi and Bluetooth

To get these two working, we need to obtain drivers from the vendor's site. The chip is from Marvell. Use the following commands:

$ git clone git://git.marvell.com/mwifiex-firmware.git
# mkdir -p /lib/firmware/mrvl/
# cp mwifiex-firmware/mrvl/* /lib/firmware/mrvl/

After the reboot, you should get WiFi and Bluetooth working.

Type Cover 3

This is more serious issue than wireless devices. To get it working, we need to recompile the kernel and use the latest kernel, v3.16. We can get it from the experimental repository of Debian.
Add the following line to the /etc/apt/sources.list:

deb http://ftp.de.debian.org/debian experimental main

Now we need to obtain its sources:

# apt-get update
# apt-get -t experimental install linux-headers-3.16-trunk-amd64 linux-image-3.16-trunk-amd64 linux-source-3.16

Unpack sources:

# tar -xf /usr/src/linux-source-3.16.tar.xz
# cd linux-source-3.16

Create a new typocover3.patch file with the following content:

--- a/drivers/hid/hid-ids.h	2014-01-19 21:40:07.000000000 -0500
+++ b/drivers/hid/hid-ids.h	2014-04-20 23:29:35.000000000 -0400
@@ -631,6 +631,7 @@
 #define USB_DEVICE_ID_MS_NE4K		0x00db
 #define USB_DEVICE_ID_MS_NE4K_JP	0x00dc
 #define USB_DEVICE_ID_MS_LK6K		0x00f9
+#define USB_DEVICE_ID_MS_TYPE_COVER_3	0x07dc
 #define USB_DEVICE_ID_MS_PRESENTER_8K_BT	0x0701
 #define USB_DEVICE_ID_MS_PRESENTER_8K_USB	0x0713
 #define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K	0x0730
--- a/drivers/hid/hid-core.c	2014-01-19 21:40:07.000000000 -0500
+++ b/drivers/hid/hid-core.c	2014-04-21 03:13:54.000000000 -0400
@@ -702,6 +702,11 @@ static void hid_scan_collection(struct h
 	if (((parser->global.usage_page << 16) == HID_UP_SENSOR) &&
 	    type == HID_COLLECTION_PHYSICAL)
 		hid->group = HID_GROUP_SENSOR_HUB;
+
+	if (hid->vendor == USB_VENDOR_ID_MICROSOFT &&
+	    hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3 &&
+	    hid->group == HID_GROUP_MULTITOUCH)
+		hid->group = HID_GROUP_GENERIC;
 }
 
 static int hid_scan_main(struct hid_parser *parser, struct hid_item *item)
--- a/drivers/hid/usbhid/hid-quirks.c	2014-01-19 21:40:07.000000000 -0500
+++ b/drivers/hid/usbhid/hid-quirks.c	2014-04-20 23:29:35.000000000 -0400
@@ -73,6 +73,7 @@ static const struct hid_blacklist {
 	{ USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
 	{ USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
 	{ USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET },
+	{ USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3, HID_QUIRK_NO_INIT_REPORTS },
 	{ USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GX680R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS },
 	{ USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS },
 	{ USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS },
 

Now apply the patch:

patch -p1 --ignore-whitespace -i typecover3.patch

Now copy the current kernel configuration for use with the new kernel:

# cp /boot/config-`uname -r` .config
# make menuconfig

Load config
Save the config and exit from the menuconfig menu. No more changes are required. Now compile the kernel:

# make-kpkg clean
# fakeroot make-kpkg --initrd --append-to-version=-typecover3 kernel_image kernel_headers

It will take around an hour. You should get two *.deb packages, which you need to install:

# cd ..
# dpkg -i linux-image*.deb linux-headers*.deb

That's it. Reboot with the new kernel, and Type Cover 3 should work.

Touchpad

This is quite simple, just add the following text in the /etc/X11/xorg.conf file:

Section "InputClass"
        Identifier "Surface Pro 3 cover"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "vendor" "045e"
        Option "product" "07dc"
        Option "IgnoreAbsoluteAxes" "True"
EndSection

Reboot again. Everything will work.

Now install the laptop-mode-tools package to improve the powersaving in Linux.
That's it.

Closing words

Although it is possible to get most features of Surface Pro 3 working under Linux, it still has a few issues. The sound volume buttons do not work out of the box, as well as the stylus buttons. And one gotcha, the accelerometer sensor does not work too. If you are able to tolerate these issues, then you can be happy with Linux installed on your Surface Pro 3 device. (via habr).

14 thoughts on “How to install Linux on Surface Pro 3

  1. diar

    Wow you just made your Surface useless. Why would anyone put Linux on an Surface is beyond me.

    Poorly-rated. Like or Dislike: Thumb up 2 Thumb down 64

    Reply
    1. Sergey Tkachenko Post author

      Because you can! If you are a developer, you just feel good in Linux and work more comfortable than anywhere else. Also, many people wondered how usable the Linux desktop with a touchscreen.

      Well-loved. Like or Dislike: Thumb up 30 Thumb down 0

      Reply
    2. James

      It’s likely that there are innumerable things that are beyond you. Civility for instance…

      Well-loved. Like or Dislike: Thumb up 13 Thumb down 0

      Reply
  2. jmdana

    Excellent post!

    Did you get scrolling working in either the touchscreen or the trackpad? They don’t seem to work for me…

    Like or Dislike: Thumb up 1 Thumb down 0

    Reply
  3. Joel

    Hello,
    A the end of the installation process of Debian 7, the program didn’t ask me about grub. Installation ended, that’s all… and impossible to boot on Debian by the Advanced startup of Windows 8…
    Also, when I created the partitions, the installation programs warned me about something I didn’t undestood : “no EFI partition” or something like that… But it created the linux partitions…
    Who can help me ?
    Thank you !

    Like or Dislike: Thumb up 0 Thumb down 0

    Reply
    1. Zaza

      Idem for me…
      Are you found solution !?

      Like or Dislike: Thumb up 0 Thumb down 1

      Reply
    2. Christian

      Great post, but sadly it is the same problem for me. Did everything you wrote with mint 17, installation worked like a charm, but now i cant get it to boot to mint, any suggestions?

      Thank you!

      Like or Dislike: Thumb up 0 Thumb down 0

      Reply
  4. Steven

    Cool. Does right click on the pen work?

    Like or Dislike: Thumb up 0 Thumb down 0

    Reply
  5. kyle

    best wifi solution out there… thanks

    Like or Dislike: Thumb up 0 Thumb down 0

    Reply
    1. Sergey Tkachenko Post author

      you are welcome

      Like or Dislike: Thumb up 0 Thumb down 0

      Reply
  6. Josh Lefler

    I am happy to report that this process has gotten quite a bit easier in Debian Jessie. The typepad worked out of the box (including during install) and, after installation, turning on the surface presents a GRUB boot menu that offers the choice to boot into windows or Linux without further tampering. I haven’t installed a GUI yet, so I can’t speak as to the touchpad or anything else. Once I do, I’ll do a blog post with details.

    Like or Dislike: Thumb up 1 Thumb down 0

    Reply
    1. Sergey Tkachenko Post author

      Ok, thank you.

      Like or Dislike: Thumb up 0 Thumb down 0

      Reply
    2. Chris Kenison

      Josh,

      Did you get the touchpad to work? I tried to edit /etc/X11/xorg.conf file, but it didn’t exist.

      Thoughts?

      Chris

      Like or Dislike: Thumb up 0 Thumb down 0

      Reply
  7. Chris Kenison

    I just installed and it installed Debian with kernal 3.16.0.4-amd64 #1 SMP Debian 3.16.7-ckt11-1 – Is this the same version (because my keyboard works). I ask, because although my keyboard works, it doesn’t work in the bootloader.

    Thoughts?

    Chris

    Like or Dislike: Thumb up 0 Thumb down 0

    Reply

Leave a Reply

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