Graeme Hill's Dev Blog

Turning a Galaxy Note Pro into a Linux laptop

Star date: 2014.137

Disclaimer

Parts of this guide include rooting your device, flashing custom kernels, and changing config files that require root access. Any of these things could break your device and/or void the warranty. I ACCEPT RESPONSIBILITY FOR NOTHING. If you want to actually follow my process then do so at your own risk. Also note that in order to get some things to work I had to disable some security features that are there to protect you (ie: secure password storage was disabled and SELinux mode is changed to permissive).

Motivation

Lately I've been looking for a laptop with the following attributes:

  • Less that $1000 (Canadian)
  • 11-13 inches
  • Full sized keyboard
  • High resolution screen (better than 1080p)
  • Excellent Linux support
  • Whole day battery life
  • Durable
  • Light weight
  • Quiet (I don't want to hear fans)
  • Cool (I don't want to feel hot air blowing onto my hands when I type)
  • Should still be able to do simple things like video chat with people who use normal consumer software like Skype or Google Hangouts (ie: the stuff that is well supported on Android but not always on GNU distros like Ubuntu).

Pretty much the only factor I don't care about is raw computing power. These requirements disqualify almost every laptop in existence so I had to think outside the box a little bit and then I realized that there was one device that does meet the critera: the 12.2" Samsung Galaxy Note Pro. If you add on the Logitech PRO keyboard case then the cost comes to about $830 and you get a computer with a 2560x1600 screen, no fans, 12 hour battery life, first party linux driver support, full sized keyboard, and all the good stuff that comes with Android. What you do not get out of the box is software for getting real work done like you would on a desktop OS. The rest of this article is about solving that problem.

The goal

The goal is to get Ubuntu running alongside Android without any virtual machines or dual booting (not that I would be able to dual boot even if I wanted to). I definitely do NOT want to run X server inside Android because it is super slow (on Android I mean) and not very tablet friendly. I'm just going for a rock solid command line environment. If I exclusively use pure Android apps and Ubuntu console apps then I will have no need for a pesky mouse. My console tools of choice are tmux, vim, and tig (among others of course). If you do want to run X then there's nothing stopping you. You'll just need to get a VNC viewer app (it's mentioned in the guide that comes with Complete Linux Installer).

Overview of the process

  • Root the device
  • Set SELinux to permissive
  • Fix keyboard issues
  • Run Complete Linux Installer

Step 1: Root the device

You can't mount a loop device and chroot into it without root access, so that's the first thing you'll want to do. Chainfire posted a version of CF AutoRoot that works on the SM-P900 and SM-P905 on xda-developers and you can get it here. I tried many versions of Odin when doing this and the only one that worked was 3.07 for some reason. It also didn't work the first time and I had to do some combination of cache wipes and reboots before it finally worked.

Step 2: Set SELinux to permissive

Sadly, getting root access to your device does not actually let you do anything you want. This is because newer Android devices have strict SELinux policies set to "enforcing" mode. You will not be able to run the linux installer unless it is in "permissive" mode. There are apps in the app store that toggle SELinux modes (or you can use the setenforce terminal command) but on this device Samsung has disabled that functionality. If you try executing setenforce 0 in a terminal it just does nothing. The only way to fix this is to get a custom kernel. There doesn't seem to be a ton of custom development going on for this device and I wasn't able to find any permissive kernels so I had to compile my own. My strategy was to make the absolute minimum changes to configuration for the sake of stability. All I wound up doing was changing a parameter in the SELinux Makefile that toggles whether or not it will force SELinux to Enforcing mode. This means that by default it is still enforcing, but it at least allows you to change it to permissive.

If you're using the North American version of the SM-P900 (wifi version) then you can download the kernel that I already compiled here. If you are using a different hardware version then you'll have to compile the kernel yourself. I wrote this article describing my process which would likely work for other versions of the device (or possibly entirely different Samsung devices). The tar file I linked can be flashed with Odin (I used version 3.07). The article mentioned above also has a section at the bottom that describes how to actually flash it using Odin if you haven't done that before.

The only problem with this kernel is that it seems to have some screwy effects on wifi. I found that on reboot it would not reconnect automatically, it was very slow to establish a connection, and if I tried to switch from one wifi network to another it would just stop working entirely. It seems that this is not actually a wifi driver issue (thank god) but actually some problem related to secure storage of wifi credentials. If you simply open up /system/build.prop and change ro.securestorage.support from true to false and then reboot it seems to work normally. I know that some Samsung devices have issues with external storage on custom kernels but I have not tested that at all. On my device /system is mounted in readonly mode so I had to remount it first:

su
mount -o remount,rw /system
vi /system/build.prop # <-- or whatever is your preferred method of editing text files

Next time you reboot /system will be back to readonly mode.

Step 3: Fix keyboard issues

There are two problems using the keyboard case:

  • If you are still holding shift when you hit space bar (which apparently I do a lot) then instead of entering a space it will display the current lanugage which is almost definitely not what you want.
  • The escape key is actually a back key and doesn't always do what you want it to, plus it's way too small (a pretty big problem when you intend on using vim heavily). My solution to this is to remap caps lock to escape and just sacrifice caps lock entirely. This is actually something I do on all my computers anyways because I find that caps lock is not needed and the escape key is too useful to have way off in the corner where I need to move my entire palm to get to it.
Fixing the shift+space issue

It turns out this has nothing to do with the Logitech PRO keyboard, it's actually a problem with the Samsung virtual keyboard. If you just download the default google keyboard from Google Play and make it your default then the issue goes away. This was a little surprising to learn because I assumed that the virtual keyboard software is not doing anything when you use a physical keyboard. Apparently that is not the case.

Remapping caps lock to escape

This was pretty easy using this very helpful guide by Isaac Su. It was meant for the Asus Transformer TF-101 but almost exactly the same process works the Note Pro. I wasn't exactly sure which of the many config files needed to be changed, so I just used a command to change them all:

# If not already done then get root access and disable selinux
su
setenforce 0

# remount file system as read/write
mount -o remount,rw /system

# replace CAPS_LOCK with ESCAPE
find /system/usr/keylayout/* -type f -exec sed -i 's/CAPS_LOCK/ESCAPE/g' {} \;

Now reboot the device and the keylayout should change (/system will also revert to read-only which is a good thing).

Step 4: Run Complete Linux Installer

There are other methods, but I prefer to just get Complete Linux Installer from Google Play. When you start it up you can go to instructions and it has a bunch of images you can download. I used the ubuntu 13.10 core image and then resized it to 10GB using this tutorial. I don't really like Terminal Emulator which is what Complete Linux Installer will automatically use when you click launch, so instead I open a local (ie: non-SSH) session with the app JuiceSSH and run the following commands:

su
setenforce 0
sh /data/data/com.zpwebsites.linuxonandroid/files/bootscript.sh /sdcard/ubuntu.img

Make sure to replace ubuntu.img with the actual name of your image file. If all goes well you'll be prompted for a few settings and then you're in! Alternatively, if you want an easier way to start it up you can just click the launch button in Complete Linux Installer and then SSH to localhost with JuiceSSH or whatever is you're preferred terminal client.