[G2 and Desire Z Android Development] teh5abiking:
So, for all of you guys down here that are Debian junkies, then you're gonna love this. I managed to get Ubuntu Karmic Koala on my G2 after a bit of messing around with adb. This is my first tutorial on xda-developers, so please tell me how I'm doing. Remember to hit the Thanks button at the bottom if you're satisfied :D

#Your warranty has been voided
#I am not the cause of any damage done to your device
#Should you accuse me, I will laugh at you

Reasons why you should follow this tutorial:

- It allows you to make use wide array of applications available in Debian/Ubuntu's repos.

- It doesn't overwrite the current Android operating system.

- It'll allow you to turn your G2, Desire Z, etc. into more than just a sub-par cellphone.

- If you're developing software/applications, this will give you the proper environment for you test them on, if you don't care for Virtualbox or don't have access to a computer at the current moment.

- This tutorial will make the best use of Android and Linux's open-source nature.

Please note that this

DOES NOT

replace Android nor is it a port of Ubuntu/Debian. Ubuntu/Debian support ARM EABI which is the underlying architecture of Android.

READ EVERYTHING BEFORE DOING ANYTHING. I KNOW IT'S LONG, I WROTE THIS TUTORIAL

For those of you that can't use, can't set it up, or don't care for adb, you can still get Ubuntu to work on your device using a Terminal Emulator app, but you're probably gonna be stuck at the command line. I haven't actually tried setting up the GUI using the Terminal, so I'm not 100% sure. Now, before I start the tutorial, you NEED to be rooted.

NOTE: Whenever you see a $ or a # sign, those are indicators for the next command. Please do not enter them as you're typing in the commands. The same goes for the "root@localhost:/#" sign.

Before we begin we will need the following:

On your phone, have the following installed and/or readily available

-androidVNC application

-Terminal Emulator app (use this to boot into Ubuntu shell)

-Busybox (preferably, the latest one. If you rooted your phone using the method on the xda wiki OR your custom ROM has it pre-installed, then continue)

- At least 2GB space free on your microSD card

- Loopdevice support for your ROM. I think Cyanogen and another kernel should do the trick.

On your computer have the following installed and/or on the desktop:

-Ubuntu Karmic Koala image. If you don't have it, download it from this link ->http://bit.ly/moghJ3

-adb installed and fully functioning on your computer

EDIT 4 June, 2011

: For those of you having troubles getting the shell to boot up, I found an alternative bootubuntu file. Extract it and replace the one that comes with the image with this one http://bit.ly/j7zORF

Let's begin, shall we?

Step 1: Connect your phone to your computer. Make sure you have "USB Debugging" checked off in "Settings -> Applications -> Development", then mount your sd card.

Step 2: Transfer the extracted "ubuntu" folder to the root of your sd card [NOT IN ANY FOLDERS, JUST the sd card itself, for those of you who don't know]. It might take a few minutes, so you might wanna make yourself a little snack for the wait.

Step 3: When the file transfer is done, disable the USB connection, so we can make use of adb. This is where USB Debugging is CRUCIAL. Open up a command window/terminal, go to where adb is located and enter the following commands:

$ adb shell
$ cd /sdcard/ubuntu
# su
# sh ./ubuntu.sh
# bootubuntu

At this point, you've set up the Ubuntu shell, as indicated by the "root@localhost:/#" sign.

However, our shell is still incomplete. We're gonna need a GUI for actual usage. If you're fine with using the command line then stop here. If you want to give yourself a PC-like experience, then please continue. You might wanna connect to WiFi if you're in an area where your mobile data is inconsistent or restricted to an EDGE connection.

Step 4: With the command prompt/terminal window that contains your adb/ubuntu shell, let's continue entering some commands to get our GUI set up.

root@localhost:/# apt-get update
root@localhost:/# apt-get install tightvncserver
root@localhost:/# apt-get install lxde
root@localhost:/# export USER=root
root@localhost:/# vncserver -geometry 1024x800

After entering the last command, you'll be prompted to enter a password. It'll ask you to set up a second one, just press "n" then continue.

For the second and third commands, press "y" when prompted to then hit ENTER, so you can install the packages. The reason why we set the VNC server's resolution is because even though the G2/Dz's resolution is 800x480, a higher resolution will provide a better viewing experience. If you want it set up to your phone's resolution, then swap it with "800x480" to scale the server's resolution to your phone's screen size.

Step 5: Enter the following commands. After entering the first command, you'll notice there's no user indicator at the left side. DON'T PANIC. Just continue entering the following commands:

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

Then, press Ctrl+D twice and press enter. You'll be back at "root@localhost:/#" (Conversely, if you're on Mac OS or Linux, just press Ctrl+D once)

Step 6: Go to your phone, and open up the androidVNC app. We're gonna need this to view our desktop. set the nickname to "root" and enter the password you set earlier. Set the port to "5901" and press connect.

Step 7a: And bam! You've got your own cool GNOME desktop! (Though in my experience, it switches over to lxde after a few uses.) Now, we need to get the VNC app to open up every time we boot into our shell. We need to enter a few more commands (yeah I know, it's getting a bit tedious at this point.)

root@localhost:/# cat > front
export USER=root
cd /
rm -r -f tmp
mkdir tmp
cd /
vncserver -geometry 1024×800

Again, you can replace "1024x800" with any screen resolution you desire.

Step 7b: Enter just a few more commands [trust me, we're almost done :)]

root@localhost:/# cat front /root/.bashrc > temp
root@localhost:/# cp temp /root/.bashrc

Step 8: To check that everything is working, enter the following commands in your command prompt/terminal window that contains our adb/ubuntu shell that I hope you kept open all this time.

root@localhost:/# exit
# bootubuntu

And you're done! Give yourself a round of applause and a pat on the back, because now you have Ubuntu Linux running alongside Android. Yay!!!!!!

To boot into your shell AFTER you're done, use the Terminal Emulator app to access your shell:

$ su
# bootubuntu

That's it, you're finished.

Now, I don't know why this happens, but after rebooting your phone, it'll take a few extra seconds for your devices to start up. I think it's because of all the files that are in the phone's internal memory. I'm not sure. Also, the VNC server might not open up after you're done with the tutorial. It's only a minor setback, you can still manually open it yourself which is in itself relatively quick.

When you're done with the tutorial, be sure to type in "exit" in the terminal and press enter for a clean kill of Ubuntu. Otherwise, you're gonna have to redo the entire procedure.

If you have any questions, please email me at teh5abiking@gmail.com

FAQ

- I don't have adb, can I still follow this tutorial?

A: Yes you can. However, you're probably going to be stuck at Step 3 with the command line. You can still use the shell, but you won't have a GUI.

- Why does my phone show a black screen after rebooting?

A: It's probably because of all the modding that's a result of the commands we entered.

Don't worry, Your phone will boot up normally. However, if this goes on longer than usual, you might have to install a different ROM. I've tested it on CM7 (Stable and Nightly), Stock G2 ROM, Virtuous 1.0.2, Virtuous G-Lite 1.0.2, and their respective ROM bases with no problems.

- I get an error that won't let me boot into the Ubuntu shell. Help me!!!!!

A: Yeah, you probably either downloaded an incomplete image OR you entered an important command wrong. I suggest deleting the ubuntu image from your sdcard and then copy the image you extracted onto your sdcard. Then what you have to do is redo the entire tutorial.