Page 1 of 1

Ubuntu running alongside Android on Android phones

Posted: Wed Nov 03, 2010 5:09 pm
by Void Main
I'm able to run Ubuntu on my myTouch slide including X. You can then VNC or SSH to it. Basically it's as simple as copying a file system image of an ARMS based Ubuntu installation to your sdcard, mounting it along with the proc, dev, sys file systems and chrooting. You end up with something very similar to an Ubuntu VM running that has network access, you can apt-get install stuff, run X apps, etc.

Here is a link to a HOWTO (not the one I used but looks better):

Now, I am using a rooted CYANOGEN ROM on my phone (basically not all that much different than the stock 2.1-update1 but rooted) but it should work on any rooted Android phone as long as your kernel has ext2 built in or has a module (it's built in on mine) and you have access to the mount and chroot commands.

You also want to set a few variables so I'll post my startup script that you run from the "adb shell" prompt. My ubuntu disk image is called /sdcard/ubuntu/ubuntu.img and I create a mount point directory /data/local/ubuntu. Here's the script that will give you a root shell in the new environment:

I created a /data/bin directory and created the script /data/bin/ubuntu:

Code: Select all

export kit=/sdcard/ubuntu
if [ ! -d /data/local/ubuntu ]
mkdir /data/local/ubuntu
export mnt=/data/local/ubuntu
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export USER=root
export TERM=linux
export HOME=/root
mount -t ext2 -o loop,noatime $kit/ubuntu.img $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
sysctl -w net.ipv4.ip_forward=1
chroot $mnt /bin/bash

#After exit command is executed clear it all up
echo " "

echo "Shutting down Ubuntu"
umount $mnt/dev/pts
umount $mnt/proc 
umount $mnt/sys 
umount $mnt
After running that script you should get a root prompt and be chrooted to the Ubuntu install. You will probably want to set the root password (passwd root) and then you can start up sshd (/etc/init.d/ssh start) or vncserver (vncserver start). Don't forget to set your vncpassword with "vncpasswd". From there you can connect to localhost 5901 (or 5902, or whatever depending on what vncserver starts up on :1 = 5901, :2 = 5902, etc) from your android vnc client app or ssh to localhost from connectbot.

Personally, rather than trying to remote control the Ubuntu installation from the little screen and keyboard on your phone you can connect to it over the wireless connection with vncviewer or ssh client from your Linux (or Windows) PC. Or you can use the adb command to forward ports to your PC over the USB debug connection. Here is an example of forwarding 22 to your localhost:2222 on your local PC with adb server running:

Code: Select all

./adb forward tcp:2222 tcp:22
ssh root@localhost -p 2222
(run in your adb tools directory) Have fun!

Posted: Thu Nov 04, 2010 7:48 pm
by Void Main
Screenshot of Ubuntu running on my myTouch (vnc'd into it):


Re: Ubuntu running alongside Android on Android phones

Posted: Mon Nov 14, 2011 6:59 pm
by X11
There is an installer in the Market for Ubuntu and Debian called "Linux Installer," which does all of this for you. Consider the howto a no-gainer. I have debian sid running, vncserver, tor, and firefox. The iptables settings are really annoying, keep posted if you find a way to get rid of them.