[Nexus One Android Development] houzuoguo:
Run Ubuntu 10.10 on Nexus One

--------------------------------

Background:

In June 2010, XDA zedomax got Ubuntu 9.04 running on Nexus One, tutorial is available at this thread:

http://xdaforums.com/showthread.php?t=718952

I continued studying the tutorial and worked out a way to make Ubuntu 9.04 running better, smoother and cause less error, here's my post:

http://xdaforums.com/showthread.php?t=815532

Recently HTC_Linux team has released version 0.3 of their Ubuntu image, compare to the original guide provided by zedomax, the v0.3 release is based on the latest Ubuntu 10.10. So I thought about making this tutorial to guide you to run Ubuntu 10.10 on your Nexus One.

--------------------------------

What benefits will you get from running Ubuntu 10.10 on Nexus One (at least):

1. Fully functional Linux terminal, with all standard Linux command line utilities

2. Fully functional desktop browser Firefox 3.6.13

3. Ability to compile and run native Linux applications

4. Bunch of graphical Internet and utility applications as shown in the screenshots

--------------------------------

Credit:

Thanks to the great XDA-developers community.

Thanks to Zedomax for providing the original tutorial of running Ubuntu on Nexus One.

Thanks to HTC_Linux team for creating the optimised Ubuntu 10.10 image file.

--------------------------------

Now the tutorial starts.

Preparation:

1. A micro SD card at least 4GB in capacity, 8GB/16GB is recommended

2. (Optional) If you're using Froyo App2SD, move all your applications which are on SD card back to Internal Storage, or you may also uninstall all applications that are on SD card. If you fail to do so, you won't be able to enter Ubuntu. However I've discovered a way that you won't need to move or uninstall apps on SD card, will discuss later.

3. Basic Linux shell knowledge

Then:

1. Get Ubuntu 10.10 from this post (file name: hd2-ubuntu_0.3.zip): http://xdaforums.com/showthread.php?t=889433

2. Download attached scripts.zip

3. On your computer, make a directory on a partition that has more than 3.5GB available space, name the directory “ubuntu” (case-sensitive!)

4. Extract three scripts (b, e, u) from scripts.zip to the directory ubuntu

5. Once you finish download hd2-ubuntu_0.3.zip, extract linux/rootfs.ext2 to the directory ubuntu

6. In your ubuntu directory, rename rootfs.ext2 into ubuntu.img (case-sensitive!)

7. Now verify that you have the following files in your computer's ubuntu directory: b, e, u, ubuntu.img

8. Copy the whole ubuntu directory onto your SD card, put the SD card back to your phone

9. Power up your Nexus One

Now we have some script work:

1. Run a terminal application from your phone (e.g. Android Terminal, Better Terminal Emulator)

2. type “cd /sdcard/ubuntu” (enter)

3. type “sh u” (enter)

4. If you see “Type 'b' to boot Ubuntu”, then you're almost there!

5. Type “b” (enter)

6. If you see “root@localhost:/#” (like shown in screenshot) Congratulations! Now you're running Ubuntu 10.10 on your Nexus One!

Whenever you want to enter Ubuntu again, simply type “b” (enter) in your Android Terminal.

To properly exit from Ubuntu, you must type “exit” from Ubuntu terminal.

If your Android terminal application gets killed by Android system (i.e. you lost Ubuntu terminal), you need to go back to Android terminal, type “e” (enter), that will properly unmount Ubuntu.

Very often that you can get “loop device busy” error when exiting from Ubuntu, in that case, type “e” (enter) multiple times (it's harmless to run “e” script multiple times, don't worry). If still you get “loop device busy” error, don't worry, ignore it then.

--------------------------------

(Optional) If you would prefer working with GUI, now let's do some extra script work:

1. Install “android-vnc-viewer” from Market (freeware)

2. Enter Ubuntu terminal

3. Make sure that you have network connection (Wi-fi recommended)

4. type “apt-get update” (enter), and wait till it finishes

5. type “apt-get install tightvncserver” (enter) and answer “y” to the question

6. After installed tightvncserver, type “cd /bin” (enter)

7. Type the following commands (all are case-sensitive!):

“cat > x” (enter)

“rm -r -f /tmp” (enter)

“mkdir /tmp” (enter)

“chmod 777 /tmp” (enter)

“export USER=root” (enter)

“export XKL_XMODMAP_DISABLE=1” (enter)

“vncserver -geometry 1024x800” (enter)

(enter)

(press and hold trackball and click D on keyboard)

“chmod 777 x” (enter)

8. The above procedure makes a script named “x”, whenever you want to start GUI, you need to type “x” (enter).

Notice that the first time (only the first time) you run “x” script you'll be prompt to enter a password for VNC connection, then you'll be asked whether to create a “view-only” password, since it is not necessary, answer “n” to the question.

9. Start “android-vnc-viewer”, create a new connection with the following settings:

Nickname: (anything you like to identify the connection)

Password: the VNC connection password that you created when ran the “x”script

Address: localhost

Port: 5901

Color format: 24-bit color (4 bpp)

Click “Connect” button, and in about a minute, you'll see your Ubuntu 10.10 desktop!

10. We still need to create one final script called “s”, now go back to your Ubuntu terminal and type:

“cd /bin” (enter)

“cat > s” (enter)

“export USER=root” (enter)

“vncserver -kill :1” (enter)

“vncserver -kill :2” (enter)

“sudo reboot” (enter)

“sudo halt” (enter)

(enter)

(press and hold trackball and click “D” on keyboard)

“chmod 777 s” (enter)

11. If you have GUI running, you * MUST * type “s” (enter) to stop VNC server before you exit from Ubuntu terminal!

In case that your Android kills your Android Terminal application and you still have VNC server running, do the following steps:

a. Start Android Terminal

b. type “b” (enter) to bring back Ubuntu terminal

c. type “s” (enter) to stop VNC server

d. type “exit” (enter) to exit from Ubuntu terminal

Fail to do so you will have problem with VNC connection next time you use it.

--------------------------------

What are not working in Ubuntu:

1. Sound

2. Some applications may not run (I guess, due to Android memory management mechanism)

--------------------------------

A little trick to access SD card from your Ubuntu:

1. Install “SwiFTP” from Market (freeware)

2. Set up FTP server using SwiFTP

3. In Ubuntu, “Places → Connect to Server” then:

Service type: FTP (with login)

Server: localhost

Port: (port number specified in SwiFTP, default is 2121)

Folder: /

User Name: (user name specified in SwiFTP)

Then press “Connect” and enter your password specified in SwiFTP. Now feel free to access your phone's file system!

--------------------------------

How to bring up Ubuntu if you have applications installed on SD card using Froyo App2SD:

1. Make sure that your Android Terminal application is installed in Internal Storage

2. Put a shortcut to Android Terminal application on your home screen

3. Make sure you have got ubuntu directory and all its contents on SD card

4. Reboot your phone (stay sharp, these following steps require perfect timing!)

5. Once you enter lock screen, Immediately unlock it.

6. Enter Android Terminal and type “b” as quick as possible, do not press Enter yet!

7. Pay close attention to your notification bar, as soon as the “SD: Checking for errors” notification disappears (the little SD icon disappears), Immediately press Enter.

8. Now you should be in Ubuntu terminal, wait 1-2 minutes before you do anything else.

9. After 1-2 minutes, you may do whatever you want.

With some applications installed on SD card, you must do the procedure above to bring up Ubuntu terminal each time you reboot your phone.

--------------------------------

That's it! Thank you for reading this tutorial. Please feel free to make any comment or ask any question!