Official website for Linux User & Developer
FOLLOW US ON:
Nov
19

Run Linux on Android – part 1

Posted by Gavin Thomas

Want an ultra-portable version of Linux? Put it on your phone

Run Linux on Android

If you can’t wait for the launch of the official Ubuntu smartphones (the first models are supposedly due later this year), don’t want to shell out for a new phone anyhow, or would prefer to use a different version of Linux on a portable device, there is an alternative. It’s possible to run a variety of popular Linux distros on a standard Android smartphone or tablet – everything from a simple BusyBox toolset right up to a full distribution with a desktop environment. You don’t even need to root your phone for some of the methods that we explore in this feature.

The advantages of running Linux on an Android device are manifold. As well as being able to SSH into other computers, you’ll have access to all your favourite Linux tools and you can also run a desktop GUI with most methods. The possibilities are endless. You could potentially even turn your Android device into a LAMP server to run web apps! So, if you’ve got an ageing Android phone or tablet kicking around, why not give it a try?

No rooting required

As mentioned, some solutions for running Linux on an Android phone don’t even require you to root the device to circumvent Android’s security features and gain superuser privileges – although we’ll take a look at that process later. The first and simplest of these is Kevin Boone’s KBOX2 project (see the section towards the end of this post), a port of BusyBox packaged with a number of Linux utilities. As with most of the solutions we explore in this feature, it can be installed via an Android app available in the Google Play Store.

Another simple non-root solution is the Limbo PC Emulator, a port of the QEMU hypervisor. The Android app can be downloaded in APK from from the project website: sourceforge.net/projects/limbopcemulator. Download an ISO for the desired distro and you can then run it in a virtual machine created by the app. Since the app is emulating x86 architecture on an ARM-based device, however, it’s a bit on the slow side.

Possibly a more useful alternative is the Debian noroot app, available from the Play Store. While the app actually provides a compatibility layer rather than a full Debian OS, it does enable you to run Debian applications on your Android device.

If you’re after a more fully-featured distro without rooting, however, the best solution currently available is the GNURoot app by Corbin Champion. Downloadable for free from the Play Store, it works on non-rooted devices by using a ptrace container implemented via the PRoot utility. No need to worry about any technical jargon, however, since the app does all the nitty-gritty for you and is very easy to use. After downloading and installing the main GNURoot app, you then need to download and install one of the ‘helper’ apps available for different ARM-based distros: (Debian) Wheezy, Fedora, Aboriginal (a lightweight BusyBox variant) and Gentoo. There’s also an x86 version of Wheezy available if you have an x86-based device. The downloaded distro can then be unpacked and launched using the simple menu system in the main GNURoot app, which does all the hard work and eventually places you in a command-line terminal emulator (see ‘Launch a distro with GNURoot’ instructions at the end of this post). You’re then all set to go and should be able to install any packages from the distro’s repo in the usual fashion, using the relevant package manager, such as apt-get or yum. You can create extra terminal windows by tapping the ‘+’ button at the top, then switch between them via the top-left drop-down menu. The top-right (three-dots) icon also brings up a menu for various settings, including font size (you might well want to increase it to see the text more easily on a small screen) and a list of special keys accessed via various volume button combinations.

Getting graphical

While useful for running various Linux tools and utilities, one obvious limitation of GNURoots’ four main distro options is that they only run via the command line. To run programs requiring windows, you’ll need a GUI. Fortunately, GNURoot does offer a way to implement one, using the helper app called ‘GNURoot Wheezy X (xterms)’, which launches a VNC server for this purpose. To see the GUI, you’ll also need to download one of the many VNC clients available in the Play Store – we used VNC Viewer.

The WheezyX distro launches in a terminal window. After updating and upgrading, as before, note the address of the VNC server at the top – it should be ‘localhost:1’ the first time. You can then open the VNC Viewer app and point it to this address, entering the password as ‘password’. A virtual desktop will then launch – note that there’s no proper desktop environment by default; just an xterm terminal window for Wheezy. By swiping around the screen, you can move the mouse pointer onto this window and tap to select it. You can use the keyboard icon in the pop-up top toolbar to start typing into the terminal, and use the handy row of special keys above the on-screen keyboard for things like Ctrl, Alt, the cursor arrows and function keys.

From this terminal window you can install and launch programs to run within windows on the desktop. Using the mouse pointer, windows can be dragged around and resized. While a bit fiddly, the system works pretty well, although you may get the odd error and applications may well be missing audio (a common problem when using VNC viewers). You can also install a desktop environment via the terminal. We managed to get Xfce working by installing it with: apt-get install xfce4. We then launched it from the VNC Viewer terminal with: startxfce4.

For some reason, the main desktop launched inside a window of its own, but could be dragged into position to fill the screen. There’s an application menu at the top for launching programs, although some items don’t work by default. So you may need to tinker around with the system to get it working better for you.

GNURoot Debian Xfce
Here’s Debian Wheezy for GNURoot running Xfce – open the image to view it at full size

 KBOX2 BusyBox

The KBOX2 project works by constructing a minimal Linux root file system within the private data area of the hosting terminal emulator app, so you’ll need to download one to use it – try Android Terminal Emulator by Jack Palevich. While you can install KBOX2 manually from that app’s command line, it’s easier to use the OneBox Package Manager app – you’ll need to buy a companion app (£2.03/$3.10). Just follow the in-app directions and it’ll run the setup script for KBOX2 within the terminal emulator. Now go to the latter and enter:

/data/data/jackpal.androidterm/kbox2/bin/kbox_shell

The prompt should change to /home/kbox $. You can then download the packages you need from the KBOX2 site (via the device’s web browser) and install them with:

dpkg -i /sdcard/Download/{package}.deb

Compatible packages include Perl, Dropbear (SSH support), GCC, Vim and rsync.

Launch a distro with GNURoot

  1. Search for GNURoot in the Play Store on your Android device. Install the main GNURoot app, then the helper app of whichever distro you want to run with it.
  2. Open the GNURoot app and choose the distro for the helper app you’re using from the top drop-down menu. Then tap the Create New Rootfs button to unpack it – this can take a few minutes.
  3. Once done, select that distro from the second drop-down and tick the ‘Launch as Fake Root’ box (so you can use apt-get and other root commands), then tap Launch Rootfs.
  4. It may a take a while to start the first time, resulting in a black screen before a familiar command-line terminal appears. You are now ready to use the downloaded distro.
  5. First, to ensure everything’s up to date, use the commands apt-get update and apt-get upgrade in Wheezy. If using Fedora, instead use yum update.

ARM-less devices

For this article, we’ve focused on installing Linux on ARM-based devices. However, some Android devices, such as the Samsung Galaxy Tab 3, are based on the x86 architecture. So, since nearly all Linux distros are based around x86, in theory they should easily run on these devices – whether using a live USB stick (via USB2Go) or a full install. You may need to tweak settings to get some features working, such as the virtual keyboard and screen rotation. Ubuntu and openSUSE (with its TabletPC pattern) seem to be the the best options.

Next time

That’s it for now, but check in again tomorrow and we’ll take a look at the rooted options for running Linux on Android phones and tablets.

  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.
    • linuxuberalles

      Here’s a summary of my (bad) luck with LinuxOnAndroid,
      GNURoot, and LinuxDeploy on a ChainFire rooted
      (CF-Auto-Root-mondrianwifi-mondrianwifixx-smt320)
      Samsung Galaxy Tab Pro (SM-T320 KitKat) tablet.

      LinuxOnAndroid

      LinuxOnAndroid was my first choice because, after much pain,
      I got working on my Droid Razr-M smart phone (Android 4.2.x
      JellyBean). On the phone it had several problems: 1) the
      bootscript.sh was defective (required much editing);
      2) the LARGE (only 4GB) Fedora 19 image is too small to be
      useful; 3) the phone is computationally challenged;
      4) the phone is display and keyboard challenged. Hunting
      on the LinuxOnAndroid website reveals that the Fedora 19
      image can be resized fairly easily; I enlarged mine to 16GB.

      After much avaricious lusting for a good price ($250), the
      quad-core Snapdragon 2.5GHz Samsung Galaxy Tab Pro 8.4 with
      16GB internal and an added 64GB external SD card became
      attractive for experimentation. While the hardware limitations
      are, presumable/hopefully alleviated, Android 4.4.x (KitKat)
      seems to be challenged in new and different ways. In particular,
      you can’t use ext4 formatting on the external SD card. Google
      (and/or Samsung) apparently considers paying royalties to
      Microsoft for exfat (with its defective everything-is-executable
      permissions) to be preferable to using superior extN format.
      So much so that they effectively prohibit one from using ext4
      on the SD card – even though the Android system itself uses it.
      WTF?!?!?!?!

      Consequently, I put the expanded LinuxOnAndroid Fedora 19 ISO
      image on the exfat SD card, and since that image is formatted
      internally for ext4, I am hoped that Fedora on Android would
      not be damaged goods. (Android itself appears to be damaged,
      but I digress.)

      Unfortunately, there seem to be other things wrong with
      LinuxOnAndroid that render it dysfunctional. When you
      install it, it puts stuff on the tablet in
      /data/data/com.zpwebsite.linuxonandroid/files. The
      bootscript.sh it loads there is defective. Despite being
      updated from the version that I tried on my phone, it seems
      to be incompatible with KitKat 4.4.x. I spent considerable
      time googling for a solution and editing the file, but to
      no avail. I could not get Fedora 19 to boot. Over a period
      of time, I wasted about a week on it.

      DeployLinux

      Deploylinux looks slick and installation appears to be highly
      configurable, with support for many flavors of Linux. It
      looks like you should be able to point it to /storage/extSdCard
      for installation. Unfortunately it can’t even create the
      installation image file. Googling this issue reveals that it is
      rather widespread. Some kind of protections and/or KitKat
      problem? Who knows. Everyone seems to have trouble, and no
      answers are forthcoming. I wasted about a day on it.

      GNURoot

      In some ways, GNUroot looks the most promising of the trio.
      First, it does not require the tablet to be rooted. Initially,
      I installed the Fedora Remix. Installation was absolutely
      trivial and successful. Unfortunately, this seems to be a
      terribly OLD Fedora. “uname -a” reveals no information about
      what version it is (16, 17, 18, 19, 20 ???). “yum update”
      fails – perhaps because it is such an ancient version that
      there are no longer any repos available for it. This is very
      unfortunate for me, because I vastly prefer Fedora to
      Debian-based Linux. (I hate apt-get, apt-cache, dpkg…
      Give me yum any day.) Next I tried installing the WheezyX
      Remix. That, too installed easily and successfully. In this
      case, “apt-get upgrade” and “apt-get update” worked fine,
      and “apt-get install ‘xfce4*'” spent hours installing around
      2000 new packages (many of which didn’t seem relevant to
      XFCE). The problem here is that I could never make it do
      anything X-related. VNC Viewer would not connect to it.
      Furthermore, it doesn’t clean up after itself. Every time
      I tried, I had to try localhost:N+1 where N keeps growing.
      At least this provides a functioning Linux, but a only in
      the sense of a console “window”. I also could not make
      autofs work to mount large number of home Linux workstations
      as /net/machinexyz.

      Bottom Line

      I appreciate the hard work of the developers of LinuxOnAndroid,
      LinuxDeploy and GNURoot. I’m frustrated to be so close to, yet
      so far from having a full-up Linux running on my “hot” tablet. I
      really would like to be able to have a full-up Linux development
      environment on ARM via Android and begin porting some of my

      signal processing software to it.

      I would appreciate any help anyone can provide to help reach
      this goal. So far my experience with my new tablet has been
      restricted to that of being a media-consuming fool, which is not

      why I spent $250 on it.

      Overall, I am quite saddened by what Samsung and/or Google
      have done to screw up the Linux goodness on which Android
      is based. Apparently Richard Stallman is correct: GNU is the
      heart of Linux – LiGNUx.

    • nick

      I may be able to help you get Linux deploy working try redirecting the download folder for your Linux.IMG file to the root of your device such as /sdcar/Linux.IMG that’s where I have mine directed and I’ve installed multiple distros on my galaxy s5 also make sure you allow enough memory for the download by changing the linux.IMG size in your settings… Hopefully that will help g.l.

    • Pingback: Tablet Linux | Rio Grande Tecnologia e Eletrônicos()

    • chris turner

      there is a new one – GNuroot debian – how do you get a GUI to work with that- been trying lxde (apt-get install lxde-core) it loads thousands of files but blows up halfway through ?

      is GNUroot debian just not finished –
      I can’t use gnuroot and gnuroot wheezy as it installs in the main memory, no room on phone for that

    • It’s an advantage of Android device that you can customize it according to your needs. Installing Linux on Android can be very useful for many people out there. Thanks for this step by step tutorial on how to do that.

      Going to try it soon.
      Free Recharge Tricks

    • Dreamazium

      This is the worst article i have ever read!