Installing Linux


tux




There are various methods on the web for installing Linux on Android tablets including:

http://androlinux.com/android-ubuntu-development/how-to-install-ubuntu-on-android/

which I couldn't get to work.
   
and this, which also includes an Ubuntu image:

http://forum.xda-developers.com/showthread.php?t=962023

which I also couldn't get to work. The problem with both seems to be the startup script.


This came close, with minor modifications:

http://www.slatedroid.com/topic/23241-installing-ubuntu-on-your-dropad-a8-herotab-c8/


This was what I did to install Ubuntu Maverick, starting, of course, with a PC running Linux:

1.  Root the tablet (method here)

2.  Enable USB debugging (and wifi) on the tablet.

3.  It may not be needed, but for debugging purposes it may be useful to install the linux version of the android sdk on the computer. Installation should include the platform-tools, which contains the adb command (allowing you to communicate with the tablet).  See here:

http://developer.android.com/sdk/installing.html


4.  Install rootstock on the computer (apt-get install rootstock).

5.  Do:

sudo rootstock --fqdn anyname --login username --password yourpassword --imagesize 3G --seed linux-image-omap,build-essential,tightvncserver,lxde

Replace anyname, username, yourpassword as needed.  The imagesize should be an integer multiple of 1G; i.e. 1G, 2G, 3G.... LXDE is the Light X-Windowing Desktop Environment.  I tried it with Gnome, but rootstock doesn't like that and fails.

6.  Create an empty image (we will fill it later):

dd if=/dev/zero of=ubuntu.img bs=1MB seek=yourseek count=0

yourseek should be 1024 for 1G, 2048 for 2G, 3072 for 3G, etc.

7.  Next, format the image as an EXT2 filesystem:

mke2fs ubuntu.img

Note that the original post uses the -F option, but this fails for me.  Instead, without it, mke2fs asks if you really want to go ahead, even though the image is not a block special device.  Answer yes.

8.  Create an empty directory called ubuntu.  Then:

sudo mount -o loop ubuntu.img ubuntu

9.  Extract the rootstock-generated TGZ file in the directory where the image is mounted. Replace the xxxxxxxxxxxx with the correct numbers.

sudo tar -C ubuntu -zxf armel-rootfs-xxxxxxxxxxxx.tgz

10.Unmount the image.

umount ubuntu

11.  To put ubuntu on an external SD, just copy ubuntu.img into a directory called ubuntu on the SD.

12.  You will need a terminal app like term.apk and a vnc client - AndroidVNC works well.  Both should be installed on your tablet.

13.  Place the following in a text file name bu, and copy it to /usr/bin on your tablet.  You can do this using the terminal, invoking superuser privilige with the command 'su.'


export kit=/external_sd/ubuntu
export bin=/system/bin

if [ ! -d /data/local/ubuntu ]
then
mkdir /data/local/ubuntu
fi

export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root

losetup /dev/block/loop1 /external_sd/ubuntu/ubuntu.img

mount -t ext2 /dev/block/loop1 /data/local/ubuntu
mount -t devpts devpts /data/local/ubuntu/dev/pts
mount -t proc proc /data/local/ubuntu/proc
mount -t sysfs sysfs /data/local/ubuntu/sys

sysctl -w net.ipv4.ip_forward=1
chroot /data/local/ubuntu /bin/bash


14.  Place the following in a text file name xu, and copy it to /usr/bin on your tablet.

umount /data/local/ubuntu/dev/pts
umount /data/local/ubuntu/proc
umount /data/local/ubuntu/sys
umount /data/local/ubuntu
losetup -d /dev/block/loop1

15.  You can now start Ubuntu with the command 'bu.'  You will find yourself in the root directory of the Ubuntu image.  You now need to add two script files to the directory /usr/bin.  It's probably easiest to do this with vi, even though vi is one of the most irritating text editors in existence.

16.  The first file should be named bu and should contain the following lines:

#!/bin/bash
export USER=root
vncserver -geometry 800x480

You need to make this executable by doing chmod 777 bu.

17.  The second file should be named xu and should contain the following lines:

#!/bin/bash
export USER=root
vncserver -kill :1
pkill gnome-keyring-d
pkill menu-cached
 shutdown now
exit

This also needs to be made executable by doing chmod 777 xu.

18.  At this point, you can install any Linux software you need, e.g.:

apt-get install openoffice.org-writer

apt-get install openoffice.org-calc

19.  Typing exit three times will get you out of the terminal.


You're now set up to run Ubuntu.  Note that the startup and exiting methods have to be followed exactly, or you will be in danger of leaving stray files around which will keep the vnc server from starting properly the next time.  If this happens, you will have to go searching for these files manually (in /tmp) and delete them.

To start Ubuntu:

1. Start the terminal

2. Type su

3. Type bu

4. When you get the Linux terminal prompt (root@localhost:/#), type bu again.  This starts up the vnc server.

5.  Return to the Android screen and start the VNC client.  Connect with the address 127.0.0.1 and port 5901.  Enter the password and user name and connect.

6.  It takes a while to start up, but you will now be on the Ubuntu desktop, and should be able to start any software that you've installed.


To exit:

1.  From the menu of the VNC client, hit disconnect.

2.  Return to the terminal and type xu at the Linux prompt.  It should tell you it is killing the vnc process.

3.  Type exit.  You should be returned to an Android prompt (just a #).

4.  Type xu.  This unmounts the Ubuntu image.

5.  Type exit twice.  This will bring you back to the Android GUI screen.