Ubuntu running alongside Android on Android phones

Linux based operating system for mobile phones.
Post Reply
User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Ubuntu running alongside Android on Android phones

Post by Void Main » Wed Nov 03, 2010 5:09 pm

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):
http://forum.xda-developers.com/showthread.php?t=823370

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 ]
then
mkdir /data/local/ubuntu
fi
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

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

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Thu Nov 04, 2010 7:48 pm

Screenshot of Ubuntu running on my myTouch (vnc'd into it):

Image

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Re: Ubuntu running alongside Android on Android phones

Post by X11 » Mon Nov 14, 2011 6:59 pm

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.

Post Reply