Installing Ubuntu Touch on a Nexus 5


Nathan Osman's Gravatar

Nathan Osman
published June 28, 2014, 1:32 p.m.


We have written an article that describes an easier method for installing Ubuntu Touch on a Nexus 5: Installing Ubuntu Touch with MultiROM.

I am really excited about writing this article. Ubuntu Touch has come a long way in the last few months and I was thrilled to be able to finally try it out on a Nexus 5. What follows is a brief overview of the process as well as some screenshots.

But first, a warning.

Warning! Flashing system images to your device is a risky operation and may void your warranty. 2buntu is not responsible for any damage caused to your phone by following these instructions.

Now with that out of the way, on with the show!

Requirements

This article makes the following assumptions:

  • You have a Nexus 5 running Android 4.4.
  • You don't care if your phone gets completely erased.
  • You are running Ubuntu 14.04 on your computer.

Although it is completely possible to flash Ubuntu Touch to other phones with other Ubuntu releases, this article will focus on using Trusty to flash to the Nexus 5.

Let's Begin

The first step is to install the following packages:

sudo apt-get install ubuntu-device-flash phablet-tools

If you haven't enabled USB debugging on your phone yet, you will need to do so by carefully following the steps below:

  1. Open Settings and tap "About phone" (it's at the bottom):

    Android - About Phone

  2. Scroll to the bottom and tap "Build Number" seven times until "You are now a developer!" is displayed:

    Android - Now a Developer

  3. Press back and you will notice that there is a new entry named "Developer options". Tap this to open a new set of options:

    Android - Developer Options

  4. Inside, you will find a checkbox that enables USB debugging:

    Android - USB Debugging

    You may be asked to confirm that you wish to enable USB debugging. If so, accept the dialog that appears by tapping "OK".

Now whenever you connect your phone to your computer, you will be asked to confirm the connection to the computer. You will need to accept this connection to continue.

Starting the Bootloader

Some of the steps that follow require that you reboot your phone to the bootloader. There are two ways to do this and both are described below:

  1. Connect your phone to your computer using a USB cable, open a terminal, and run the following command:

    adb reboot bootloader
    
  2. Power off your phone. Now hold down both the power and volume down buttons until the green Android image appears.

Unlock the Bootloader

Before we can flash anything to the phone, we must unlock the bootloader. Start the bootloader (see above) and connect your phone to your computer with a USB cable. Run the following command in a terminal:

fastboot oem unlock

(If this fails for some reason, try prefixing the command with sudo.) You will receive a warning on your phone's screen. After accepting it, the data partition on your phone will be erased.

Flashing the Images

Now you are actually ready to install Ubuntu Touch. Start the bootloader again and run the following command in a terminal while your phone is connected to your computer via USB:

ubuntu-device-flash --channel="ubuntu-touch/devel" --bootstrap --server="http://system-image.tasemnice.eu"

This may take a considerable amount of time depending on the speed of your Internet connection. Once the ubuntu-device-flash tool finishes downloading the correct images for your device, it will then flash them. Wait until the command exits - it may take some time to complete.

The Fun Part

Once the flashing is complete, your phone will reboot and Ubuntu Touch will start for the first time. It may take a minute or two for the boot process to complete. You will then be greeted with the lockscreen:

Ubuntu Touch Lock Screen

You will also be greeted with a brief tutorial explaining the different swipe gestures for getting around.

Taking Screenshots

Getting a screenshot is difficult but not impossible. The phablet-tools package contains a command named phablet-screenshot that obtains a screenshot from the device when it is connected to the computer. Unfortunately, it didn't work out of the box. I had to edit a couple of lines.

If you want a diff, use this:

--- /usr/bin/phablet-screenshot 2014-04-16 04:21:45.000000000 -0700
+++ /usr/bin/phablet-screenshot 2014-07-01 18:56:56.987368596 -0700
@@ -105,8 +105,8 @@
     CONVERTOPTS="$CONVERTOPTS -depth $depth -size $size"

     echo "I: Dumping $FBDEV ..."
-    adb shell mirscreencast -m /tmp/mir_socket -n1
-    adb $ADBOPTS pull /tmp/mir_screencast_$1.$sfx ${PICDIR}/fb
+    adb shell mirscreencast -m /var/run/mir_socket -n 1
+    adb $ADBOPTS pull /tmp/mir_screencast_${1}_60Hz.$sfx ${PICDIR}/fb

     [ ! -e "${PICDIR}/fb" ] && echo "E: Capture failed!" && return
     convert $CONVERTOPTS $sfx:${PICDIR}/fb[0] "$DST"

If you're not sure what a diff is (never mind how to use one), follow these instructions:

  1. Open a terminal and launch your favorite text editor as root.

  2. Open /usr/bin/phablet-screenshot and locate line 108.

  3. Change lines 108 and 109 to the following:

    adb shell mirscreencast -m /var/run/mir_socket -n 1
    adb $ADBOPTS pull /tmp/mir_screencast_${1}_60Hz.$sfx
    

Reinstalling Android

If you change your mind and want to revert to Android (which, thankfully, is very easy to do with a Nexus device), you can do so by following these steps:

  1. Download and extract this file.

  2. Connect your phone to your computer using a USB cable and run the following command:

    adb reboot bootloader
    
  3. cd to the directory containing the files you extracted in step 1.

  4. Run the flash-all.sh script:

    ./flash-all.sh
    

That's it! When the process completes, you'll be back in Android.

Is It Stable?

Unfortunately, Ubuntu Touch is not very stable on the Nexus 5 - the Mir display server frequently crashed or froze on me, requiring a hard reset. I do not recommend using Ubuntu Touch on a Nexus 5 that you use on a daily basis.

All of that being said, the OS looks very promising and has come a long way. As a bonus, I will include another screenshot showing our very own 2buntu app for Ubuntu Touch running on an actual device:

2buntu Ubuntu Touch App on Nexus 5

Looks like we have a font-size issue to fix :)