If you didn’t catch the first part of this guide yesterday, have a read of this. Now you’re up to speed…
If you want to make full use of Linux on your Android device, the best solutions require rooting it and unlocking its bootloader (see ‘Rooting questions’ section below). Whichever way you do it, this a major step as it will void your warranty and also runs a risk of ‘soft-bricking’ the device – although it can be made to work again if that happens. Another drawback is that unlocking the bootloader will factory-reset your phone and erase all its apps and data, so ensure that you make a backup beforehand.
Once you’ve rooted your phone and unlocked the bootloader, you are able to install and run a compatible Linux distro within a chroot environment on the device. The easiest way to do this is by using one of the installer apps available in the Play Store. We tested out Complete Linux Installer and Linux Deploy. Both of them enable you to run a run a selection of popular Linux distros within a chroot environment on the Android device – it’s not a virtual machine since they run directly on the ARM architecture. You can then access the running distro from an SSH/terminal app or, if using a GUI, a VNC viewer.
While, in theory, the Complete Linux Installer’s built-in guides and easy-to-use interface make it possible to install and launch a distro – choose from various flavours and sizes of Ubuntu, Debian, ArchLinux, Kali Linux, Fedora and openSUSE – with just a few button taps, we experienced a few problems getting most of them to work. Still, the team behind it are currently alpha-testing an improved version three, so you might want to give that a try when it’s ready.
However, here we’ll focus on Linux Deploy, which proved more reliable. Launching the app takes you to a simple black screen with your device’s IP address and some options at the top (see ‘Run a distro with Linux Deploy’ section below). Tapping the down-arrow icon takes you the settings screen where you can choose a distro to install: Debian, Ubuntu, Arch Linux, Fedora, openSUSE, Kali Linux and Gentoo are available, plus a RootFS option. Further settings enable you to change the version and architecture (useful if your device doesn’t have an ARMv7 CPU). You can also choose a desktop environment (LXDE, Xfce, GNOME, etc) and alter VNC display settings to suit your screen resolution. When ready, hit the Install option at the top and Linux Deploy will begin installation – by default, to an IMG file. Naturally, this may take some time – usually 30 to 60 minutes, depending on the distro and your Wi-Fi connection speed (don’t do it over 3G!) – with all the processes shown on screen. You’ll know it’s finished when you see the ‘<<< end: install’ line. So long as it didn’t fail, you’re ready for launch.
Hit the Start button to boot the Linux instance; SSH and VNC servers will be launched by default. Note that you can’t enter any commands from Linux Deploy itself – you need to connect from an SSH app, such as VX ConnectBot or JuiceSSH. You can then enter standard Linux commands from the terminal.
To access the GUI and desktop environment, you’ll need to use a VNC app such as VNC Viewer. If the desktop has the wrong dimensions, just go and change the GUI settings in Linux Deploy and restart the distro from there.
While we enjoyed considerable success using Linux Deploy, we did encounter a few teething troubles. If the distro installation fails for some reason, in most cases simply hitting Stop and then reinstalling fixes the problem. We also sometimes got a ‘failed to truncate’ error when Linux Deploy was making an IMG file at the start of an installation; we found that reducing the image size solved this, though it’s not ideal as it reduces the space for the distro. Indeed, a limitation is that Android’s FAT32 file system for SD cards has a maximum file size of 4GB, so you can’t install a distro .img file greater than this. A solution is to create two partitions on the card – FAT32 and ext2/3/4 – and then install the distro to the latter (either as a file or partition); if your device only has internal storage, you may be able to use a workaround involving a USB2Go cable and pen drive.
While it’s great to be able to run a desktop distro on your phone, navigating it with a mouse pointer and virtual buttons can be fiddly. So you might want to give Ubuntu Touch a try. Not to be confused with Ubuntu for Android (which is used via a monitor and physical keyboard), Touch puts a special touch-screen version of Ubuntu on your device. Unlike the other methods for running distros, it doesn’t run in a chroot environment within Android – instead, you install it as a standalone OS in the recovery partition of your device and you can then dual-boot it with Android via the fastboot menu.
While officially, Ubuntu Touch only supports certain Samsung Galaxy and Google Nexus devices, it can be made to run on others. See the website for more details: https://wiki.ubuntu.com/Touch/Devices.
Installation is surprisingly easy if you’ve already rooted your device and unlocked its bootloader. Simply download the Ubuntu installer ZIP file and move it to the root of your SD card. Then put your device into fastboot mode: turn it off, then hold the power and volume-down buttons until you see the green robot screen with a large Start option. Use the volume-down button to switch to Recovery mode and then press the power button.
Now use the menus to install the Ubuntu installer ZIP from your SD card (in the /0 directory). Reboot the device and you should find the Ubuntu Dual Boot app in your Android apps menu. You’ll need to ensure you can run apps from unknown sources (under Settings>Security). Now tap the app icon, then ‘Choose which channel to install’ to select a version of Ubuntu. You’ll need to wait quite a while for the app to download and be installed.
When it’s finished, tap the ‘Reboot to Ubuntu’ button to launch Ubuntu Touch on your device. The gesture-based navigation system is easy to use: swipe from the left edge to open the launcher, from the right for the app switcher, from the top for a quick settings panel, and from the bottom for extra options. Linux commands can be entered via the Terminal app. Note that since Touch is still in beta, there are a few issues, depending on the device, but it’s usable and gives you a good preview of how the finished system will work.
To return to Android, simply power down, then hold the power button to launch it. To restart Touch from Android, open the Ubuntu Dual Boot app and hit the reboot button. You can also uninstall it from the settings menu here.
As we have demonstrated, there are many ways to install Linux on your Android device, each with its own pros and cons. There are also many things you can do with it once installed – see the ‘Why do it?’ section below for some ideas. So, why not get Linux onto your phone and take it with you wherever you go?
What is rooting?
In short, it is gaining root access to control some of the Android system’s secure features. This involves unlocking the device’s bootloader, replacing the recovery system with a custom version and installing a superuser app.
What benefits does it offer?
Advantages include the ability to modify every aspect of the Android system, install custom ROMs, overclock the CPU, install extra apps, remove OEM bloatware and, of course, run a full-blown Linux distro.
How difficult is it to do?
The process differs for every Android device, but often entails connecting it to a computer. For this, the device must have USB Debugging enabled in Settings>Developer Options, which appears when you tap the Build Number seven times on the About Phone/Tablet screen. If the manual command-line method using the ADB and Fastboot tools is too daunting, there are numerous desktop utilities available to simplify the process. There’s even an Android app, Towelroot, that can root many devices with a single button tap.
What are the downsides?
You’ll almost certainly void your warranty and there is a low risk of soft-bricking your device (ie it won’t boot up properly), but you should be able to restore it to working order using a connected computer with the adb and fastboot tools to re-flash the original Android ROM. Also, unlocking the device’s bootloader will perform a factory reset that wipes the device’s data and downloaded apps, so you’ll want to be sure they’re backed up first. While, by default, app data is backed up to your Google account in the cloud, it’s not exactly transparent and you’ll need to re-download the apps afterwards, so you might want to do a further computer backup. A good way to do this on a non-rooted phone is with ClockworkMod’s Helium Android app and desktop client.
Run a distro with Linux Deploy
- Launch Linux Deploy and tap the down-arrow icon at the top to access the settings. First, tap Distribution to choose a distro. Then tap ‘Distribution suite’ to choose a version, and Architecture if you want to change that too.
- Scroll down the settings and tap ‘Desktop environment’ to choose one. SSH and GUI are enabled by default. Tap GUI settings to alter the width and height settings to suit your screen (you can always change them later).
- When all the settings are made, tap Install at the top to begin the installation. After making the .img file, all the installation processes will be detailed on screen. When you see ‘<<< end: install’, the distro is ready to launch. Tap Start.
- To access the distro from a terminal, launch your SSH app and (if using default settings) log into android@<your device IP address> with the ‘changeme’ password. You can now enter standard Linux commands from the terminal.
- To use a GUI, launch your VNC viewer app. Use ‘localhost:0’ as the address, port 5900 and the ‘changeme’ default password. Once connected, the desktop will appear – if not sized correctly, change the GUI settings in Linux Deploy, then Stop and Start.
Why do it?
- It’s portable and convenient. No need to carry around a Linux laptop when you can run Linux on your Android phone instead.
- Access the command line from a terminal emulator and use all of your favourite Linux tools
- Or use a VNC viewer to run a desktop GUI and windowed applications.
- Gain access to thousands of Linux applications. Many of these are more powerful and more customisable than their Android equivalents.
- It’s particularly useful for power users and software developers; in order to build ARM software, and have real git-annex repositories, for instance.
- You could even run a LAMP server from your device, to run web apps. It’s relatively straightforward to configure.
- A Linux-running Android device could be used in hardware projects, such as robots – either in place of a Rasberry Pi or as a remote control unit.
- Gain all the benefits of running Linux without harming your standard Android environment, giving you the best of both worlds on one portable device.