Ubuntu Installation Guide on Android – Part 2

Add a GUI to Ubuntu

Before installing a Graphical User Interface I guess it is better to know what to do and how to do:

  1. Download the VNC Viewer from Google Play or directly from the website and install it on your phone.
    We will install the VNC server on Ubuntu and with the VNC client installed on Android, we will connect to Ubuntu. We will also install the necessary packets to add a GUI to Ubuntu.
  2. At this point we have to work on a file located in the EXT partition in Ubuntu folder, we can reboot the phone in Recovery mode and mount the memory card from recovery therefore use ADB to work on this file, or we can use a Linux OS and do everything with the GUI of Linux (just like I did with Kubuntu).

  3. The file we have to edit is the sources.list located under /etc/apt/
    This file checks the updates for Ubuntu from its repositories.
    We have to edit it by adding this row:

    deb http://ports.ubuntu.com jaunty main universe multiverse

    We can now save it!

  4. Now turn the wifi on or use your data connection and send this command to Ubuntu:
    ./adb remount
    ./adb shell
    cd sdcard
    sh startubuntusd

    To access to Ubuntu and:

    apt-get update                     -> to update the system
    apt-get install tightvncserver     -> the vncserver
    apt-get install lxde               -> the LXDE GUI
    Or we can use the Icewm instead of Lxde, I used Lxde.
    apt-get install icewm

    You might have some errors during the updates, just repeat every command until the system take all the updates, it’s important that they’re 100% done.
    When you will give the command to install the Lxde GUI it will start the setup procedure, you can say Yes to all.

  5. After the download and installation of every packet I suggest you to repeat again all the update commands to be sure that everything is installed properly.

  6. Send this commands:
    export USER=root
    vncserver -geometry 480x320

    There’s no need to modify the resolution at the moment, this is something we will change later on.
    It is asking for a password now, choose one. It must be more than 4 char length and more important, you must remember it… Mine was 123456.
    When it asks for a special password choose NO – this is very important.
    Vnc now started but we don’t use it at the moment, just kill it:

     vncserver -kill :1
  7. We have to edit one more file, this one is the xstartup, it is located under /root/.vnc/
    The X server is used on every Linux/Unix based system and it is the base of the GUI.

  8. If you installed the Lxde, use this command to create the Xstartup and paste the code below:
    sudo gedit EXTOFYOURPHONE/root/.vnc/xstartup
    #xrdb $HOME/.Xresources
    #xsetroot -solid grey
    #x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    #x-window-manager &
    # /etc/X11/Xsession
    icewm &

    Else, if you installed IceWM:

    #xrdb $HOME/.Xresources
    #xsetroot -solid grey
    #x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    #x-window-manager &
    # /etc/X11/Xsession
    icewm &
  9. If you’re using Windows OS, you can use the ADB Pull / Push to transfer the xstartup file from Android EXT partition to Windows OS and edit it with notepad.

  10. This step is very important, it made my Ubuntu boot up after 3 days.
    We have to use the chmod to add the execution flag to xstartup.
    Lets give this command:

    chmod 755 xstartup
    ./adb remount
    ./adb shell
    chmod 755 /sd-ext/ubuntu/root/.vnc/xstartup
  11. Everything is (almost) ready!
    We can now create 2 scripts so we can run fast commands to start and stop Ubuntu and Vnc, and an algorithm to clear the temp files.

  12. the .bashrc file starts every time the superuser log in to the system, we can edit this file adding some code.
    Copy the code below at the beginning of /root/.bashrc

    export USER=root
    alias vncstart='vncserver :1 -geometry 1024x768 -depth 16 -pixelformat rgb565'
    alias vncstop='vncserver -kill :1'
    cd /
    rm -r -f tmp
    mkdir tmp
    cd /

    vncserver :1 -geometry 1024x768
    We used before the 480×320 px resolution, we can change it now!
    The code is longer than before because I found out this is the correct string to don’t let video errors appears.
    The alias creates variables and we used both vncstart>/code> and vncstopto start and stop the vnc, without writing the whole code.The second part of that code is about the TMP directory, it is better to erase it at every Ubuntu startup.

    We modified the EXT partition again, lets reboot !

  13. We finished! Lets start Ubuntu
    ./adb remount
    ./ad shell
    cd sdcard
    sh startubuntusd

    We can now open the VncViewer we installed before.

    password: the one you used before (123456)
    address: localhost
    port: 5901

    Once hit “Connect” we’re in and we cann see Ubuntu running with the GUI we chose!!
    To stop it simply type vncstop on Ubuntu shell and from the vncviewer hit disconnect.
    Ubuntu is still mounted in the memory however, if we reboot we will refresh the EXT and the RAM as well.

  14. One last thing that I have never read on internet tutorials:
    VNC starts using 5900 port as default, the 5901 is the first available and that is why we used this port before.
    When we send the vncstart code we can see, through localhost:N which is the port that VNC is using at the moment, it could be localhost:2 – localhost:3 and so on.. the port we must use for the vnc streaming must be the same of localhost:N
    localhost:3 would want the 5903

I was able to run and play a bit with Ubuntu but I used the HTC G1 which is not so powerful and it lagged a bit, but it worked!
Unfortunately I don’t have screenshot but that has been a great goal! Even better than when I run Windows 3.1 on Nokia N81 with Dosbox… !