全部博文(322)
分类: LINUX
2011-03-15 09:56:10
This guide is for those of you who want to install Ubuntu as a sub-system under your Nexus One or any other rooted Android smartphone, I’ve tried to make it easy as possible for everyone.
UPDATE:
As you can see, I’ve used a rooted Nexus One here but you could have trouble with other Android phones as not all Android phones are built exactly alike but might work well also, you never know until you try it.
I am also working on Ubuntu on my rooted HTC Evo 4G, that should be available later this month over at .
You could probably also run Ubuntu directly off your Nexus One/Android phone but that probably means not being able to use it as a phone and you probably would lose your camera.
To be on the practical side, I think it’s ideal to run Ubuntu along with your Nexus One/Android phone as I will be showing you here.
This Ubuntu install will not affect your existing Android system, the Ubuntu terminal will run in the background while the Ubuntu X11 graphical user interface will run as an app under Android VNC app.
Why are you installing Ubuntu on your Nexus One/Android phone?Being able to have Ubuntu on your Nexus One/Android phone means that you can run native Ubuntu/linux applications off your phone!
I also see many uses in college engineering classes when they are studying Ubuntu/linux. Instead of heading to the lab or having dual-boot on their computer, students will be able to use their Nexus One/Android phone as a test device.
Even for web designers, their Android phone can become a portable test web server to test out their new designs.
The list will go on and there’s absolutely no reason why we shouldn’t run Ubuntu or other linux systems on Android phones.
Lastly, for open-source people like me, free code is priceless, it’s going to be what’s driving the world in the next 10-20 years, if it ain’t already.
I don’t want to bore you with my philosophy so let me show you step-by-step how to install Ubuntu on your Nexus One.
How to Install Ubuntu on your Nexus One/Android Phone!Before anything, download ubuntu.zip and unzip it:
(Please feel free to mirror other places if you’d like!)
1. First, you will need a rooted Nexus One/Android phone. If you have a Nexus One,
UPDATE: Also, you need to install the latest Busybox, try this guide here to install Busybox.
2. Once you have a “rooted” Android phone, you will be able to run Ubuntu under Chroot.
What is Chroot?
I just found about this myself the other day while doing this but Chroot in layman’s terms is basically the ability to run other operating systems under your current system (in this case Android). Chroot was initially developed to test new operating systems in a virtual environment but will work perfectly in this case for our project here as it will allow us to use Ubuntu as a “virtual” machine under Android system. Yes, just think of it like Sun Virtualbox or VMWare for Android and other linux systems.
On one more note, you can only “chroot” another operating system made for your system’s architecture. For example, most new Android smartphones including Nexus One, HTC Evo 4G, and Droid X all use ARM architecture CPU, meaning you can only use ARM-based linux systems/ports.
In this case, we are lucky because Ubuntu has an ARM-port. It’s most likely the case that you can also “chroot” other linux devices that support ARM. I am also working on chrooting other popular distros like Fedora, Gentoo, and more.
3. Now you understand what Chrooting is, let’s copy over the files we need for chroot. These files include an image file of Ubuntu ARM (basically root filesystem that can be mounted onto Android phone using the command mount), setup script file (ubuntu.sh), chroot boot/launch file (bootubuntu), unionfs, fsrw, and mountonly.
Copy these six files over into your SD card’s root folder under folder name “ubuntu“. Or you can just unzip the file I provided and copy the ubuntu folder over to your SD card’s root folder.
(Yup, I am already working on other Linux distros! But Ubuntu is my favorite.)
The script files were modified (by myself) from other instructions on the web on installing Debian to a G1 phones (thanks to Saurik). Btw, Debian and Ubuntu are pretty much the same linux as Ubuntu is just an extension of Debian so you should be able to easily run Debian too using the same method, just change the file names.
4. Before we go any further, make sure to “Turn off USB storage” on your phone so we can access the SD card from ADB Shell. Let’s also make sure your USB Debugging mode is checked underSettings->Applications->Development. (And yes, don’t forget to connect your Nexus One/Android phone to your computer via USB!)
5. I am assuming you’ve already installed the Android SDK (while you were rooting your phone) so let’s head to your Android SDK directory and load up ADB Shell.
For Windows, go to your Android SDK Tools directory such as c:\sdk\tools and type “adb shell“.
(FYI, cd is the command you can use to browse to your sdk\tools directory. For Windows, do cd \sdk\tools and for Mac/Linux, do cd /sdk/tools.
For linux and Mac, go to your Android SDK Tools directory such as /sdk/tools and type “./adb shell” or it can also be “sudo ./adb shell” for Ubuntu.
6. Once you are in the ADB shell, you should see a “#”symbol. Great, let’s start bootin’ Ubuntu right away.
7. Type “su” to enter superuser mode. Btw, if you get error on this part, that means you have not rooted your phone! (or you might have to installed a rooted ROM.)
8. Next, type “cd /sdcard/ubuntu“, which will take you to the directory where you’ve copied the Ubuntu files over to.
9. Type “sh ./ubuntu.sh” to run the setup script. You only have to run this once or whenever you change the script file bootubuntu.
10. Once that completes, type “bootubuntu” to “chroot” or boot into your new Ubuntu on your Android!
If you get the “localhost” sign, congratulations! You’ve just installed Ubuntu on your Nexus One/Android phone!
If you didn’t get that and you got an error falling back to the ground at 200MPH back at the “#” symbol, don’t worry, I did that about a thousand times for 2 days straight, you are not alone.
Try rebooting your phone and repeat steps 5 through 10 CAREFULLY and I am sure you will get it working. A lot of times, our eyes can lie to us while following step-by-step directions, really!
Also, if you are not using a Nexus One here, you could be running into other problems as I have still not yet been able to chroot into Ubuntu on my HTC Evo 4G.
How to Get X11 GUI up and running on your Nexus One/Android Phone!11. I actually prefer the command line over GUI because it saves so much memory and I am pretty proficient doing things in the terminal but the GUI gives you a full desktop experience over Ubuntu so first, you will need to in form of .apk file. After downloading it on your phone (or copy it over to your SD card after you download it on your computer), open it up and install the app.
12. You will next need to install some files via Ubuntu apt-get installer. Go back to the chrooted Ubuntu terminal and type:
apt-get update
to update your Ubuntu packages then:
apt-get install tightvncserver
to install the TightVNCServer and:
apt-get install lxde
to install the LXDE.
13. Next type:
export USER=root
vncserver -geometry 1024×800
Here you can set your password to VNCserver like I did as “123123123“.
*Note – You can also change 1024×800 to the exact resolution of your Android phone’s LCD resolution but I found that a bit higher resolution gives you better display, so the Nexus One has 800×480 but I set it to 1024×800 for better viewing.
Next, we are going to add the following to /root/.vnc/xstartup file using cat command:
cat > /root/.vnc/xstartup
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
icewm &
lxsession
Then hit Ctrl+D twice and Enter key.
14. Next open up the Android VNC app on your Nexus One/Android phone and enter the password you set earlier in step 13 and set the Port to 5901.
15. Next hit connect and voila, you should get something like this, a cool GNome Ubuntu screen!!!
16. Now, let’s setup your chrooted Ubuntu so you can make the VNCserver run everytime you start the chrooted Ubuntu.
17. Next, let’s add some code to the /root/.bashrc file, which runs at every boot of your Ubuntu so the VNCServer runs automatically when you start the Ubuntu.
cat > front
export USER=root
cd /
rm -r -f tmp
mkdir tmp
cd /
vncserver -geometry 1024×800
Then hit Ctrl+D twice and Enter key.
Next, we will concatenate the file we just made front and /root/.bashrc into a new file called temp:
cat front /root/.bashrc > temp
Then we will copy the new file temp over the existing /root/.bashrc.
cp temp /root/.bashrc
(I used Windows command.com terminal, which keeps echoing things twice. It only happens on Windows because of echo!)
*Note – The reason why I used cat command to do everything here is for Windows users because the vi text editor doesn’t function correctly within Windows shell. But you can always just use your favorite Ubuntu text editor if you are using Linux or Mac. (Just add contents of file frontinto the beginning of /root/.bashrc This way, I only have to write one howto manual that works for every platform. For Windows users, you can also install SSH (do “apt-get install openssh-server“) and use an SSH client such as .)
To check that it’s working you can exit out of Ubuntu back into Android shell:
exit
then boot Ubuntu back up:
bootubuntu
Now everytime you chroot/boot your Ubuntu, the VNCServer is start automatically at start-up.
You can use Terminal Emulator app (freely available on Android market) to start the Ubuntu chroot by entering:
su
bootubuntu
so you don’t need to connect to ADB shell to launch Ubuntu, giving you the freedom to use Ubuntu along with Android whereever you go.
That’s it!
BOOTUBUNTU UPDATE FIXUPDATE: For people having trouble getting it to work (thanks to people testing it at XDA Developers), try downloading the new then:
Go run the ubuntu.sh by doing on ADB shell:
su
cd /sdcard/ubuntu
sh ./ubuntu.sh
then
bootubuntu