Monday 30 July 2012

Installing Ubuntu On Android



This guide will get you running Ubuntu 9.10 on your android device the right and easy way. This is based on several guides put together, and changed in some areas by ΛθƉ
 . So lets start.

Step 1
Rooting Your Device

Before starting anything, you need to make sure your device is rooted. This procedure varies between devices, so I won't include a guide for it here, there are MANY guides out there for this.

I used this to root Samsung Galaxy Player 5.0 :

http://www.unlockroot.com/index.htm

Step 2
Testing Loop Support

In order for this to work your device MUST have support for loop devices. You can test it by running this in a terminal emulator app, or over an adb console:

Code:
su
losetup


If running the command losetup comes back empty, then your good. However, if it returns:

Code:
losetup :not found

Then leave now, because this isn't going to work for your device.

Step 3
Getting Files and Preparing Device

Now we need to grab some files and prepare our device. We are going to need to download the ubuntu image and android scripts. Download this here:

Code:
http://downloadandroidroms.com/files/get/Nhi9EJWSw7/ubuntu.zip

While that's downloading, you MUST have busybox installed on your device. So head over to the android market and search for busybox and download and install it.

After you finished downloading the ubuntu.zip, extract the folder onto your device. I extracted it to:

Code:
/sdcard/ubuntu/

I will be assuming you choose this directory through the rest of this guide.

Step 4
Starting Up Ubuntu

Now its time to get Ubuntu actually running! First we need to find a empty loop device. Some devices will auto mount process to loop devices. The script is configured to use loop1, but we may need to change that. So, run this command:

Code:
su
losetup /dev/block/loop1
losetup /dev/block/loop2
losetup /dev/block/loop3
etc.

Keep doing through these until the return is something like:

No device Exsists

If you get this on running losetup /dev/block/loop1, then you don't need to change anything. 
If it is however, you need to edit the bootubuntu file in the /sdcard/ubuntu directory. The original file looks like this:

PHP Code:
#modprobe ext2mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
export kit
=/sdcard/ubuntu
export bin
=/system/binif [ ! -/data/local/ubuntu ]then
mkdir 
/data/local/ubuntu
fi
export mnt
=/data/local/ubuntu
export PATH
=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM
=linux
export HOME
=/root
mknod 
/dev/loop1 b 7 0
losetup 
/dev/block/loop1 /sdcard/ubuntu/ubuntu.img
mount 
-t ext2 /dev/block/loop1 /data/local/ubuntu#mount -o loop,noatime -t ext2 $kit/ubuntu.img $mntmount -t devpts devpts $mnt/dev/pts
mount 
-t proc proc $mnt/proc
mount 
-t sysfs sysfs $mnt/sys
sysctl 
-w net.ipv4.ip_forward=1echo "Setting /etc/resolv.conf to Google Open DNS 8.8.8.8 and 8.8.4.4"echo "nameserver 8.8.8.8" $mnt/etc/resolv.confecho "nameserver 8.8.4.4" >> $mnt/etc/resolv.confecho "Setting localhost on /etc/hosts "echo "127.0.0.1 localhost" $mnt/etc/hostsecho "READY TO ROCK AND ROLL BABY! "echo "Brought to you by NexusOneHacks.net and the open source community! "echo " "chroot $mnt /bin/bash#After exit command is executed clear it all upecho " "echo "Shutting down Ubuntu"umount $mnt/dev/pts
umount $mnt
/proc
umount $mnt
/sys
umount $mnt
losetup 
-/dev/block/loop1 

Change all the loop1 to whatever loop was empty. Example:

Code:
losetup /dev/block/loop1 /sdcard/ubuntu/ubuntu.img

Would become:

Code:
losetup /dev/block/loop5 /sdcard/ubuntu/ubuntu.img

Now that's done, its time to get it running. Run these commands:

Code:
su
cd /sdcard/ubuntu
sh ./ubuntu.sh (This will return some errors, this is normal)
bootubuntu

If you are greeted with:
root@localhost

Then you are now running Ubuntu on your device! To shutdown Ubuntu, just type exit, and to start it up, just type bootubuntu in the terminal from any directory.

Additional
The things listed here are universal with Ubuntu, so I won't go into to much detail on these.

Before installing anything, make sure you run:

Code:
apt-get update
SSH
You will almost certainly need ssh support with this, so run these commands (after running bootubuntu on device):

Code:
apt-get install openssh-server

Now your going to need to set a password for the root user, run:

Code:
passwd

and enter in your new password. Now run:

Code:
service ssh start

You can now connect to the server from your device with a ssh app like connectbot (coonect to root@127.0.0.1), or over wifi.

Getting A GUI

If you want a GUI, you first want to install LXDE:

Code:
apt-get install lxde

Now edit /root/.vnc/xstartup to this:

Code:
cat > /root/.vnc/xstartup
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
icewm &
lxsession

Now install tightvncserver:

Code:
apt-get install tightvncserver

Then run:

Code:
export USER=root
vncserver -geometry 1024x800

and enter a password at the prompt. You can now vnc into it with a vnc app, or a vnclient. 

Fixes
Errors During apt-get install

If you get:

Code:
Err http://ports.ubuntu.com karmic/main Packages
404 Not Found
Err http://ports.ubuntu.com karmic/universe Packages
404 Not Found
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/karmic/main/binary
-armel/Packages.gz 404 Not Found

W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/karmic/universe/bi
nary-armel/Packages.gz 404 Not Found

Then change /etc/apt/sources.list to:

Code:
deb http://old-releases.ubuntu.com/ubuntu/ karmic main universe

Not Enough Free Space

The default ubuntu.img doesn't include much free space, so you can follow this guide here to fix that:

Code:
http://forum.xda-developers.com/showthread.php?p=16494694

Quick note: If you get an error running mke2fs ubuntu.img then try:

Code:
mke2fs -F ubuntu.img


This Tutorial is From ΛθƉ (HF).

Enjoy :)

No comments:

Post a Comment