Running Ubuntu Parallel to Android

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
This will not replace or break your Android install. These instructions will get Ubuntu to load parallel to your current system. You'll be able to access Ubuntu through the Android-VNC-Viewer or any network connected computer with a VNC client. I've only tested this on Froyo.

Things you need:
LG Optimus V
2 Gbs free on the SD card FAT partition
A computer connected to the same network as the phone
SSH Client
Android-VNC-Viewer from the market

Instructions:
  1. Root your phone.
  2. Download the Ubuntu Image here: Download ubuntu.zip for free on uploading.com
  3. Unpack it into your sdcard: /sdcard/ubuntu/
  4. ADB Shell then run these commands while your phone has an internet connection:
    Code:
    su
    cd /sdcard/ubuntu/
    sh ubuntu.sh
    bootubuntu
  5. At this point you'll have Ubuntu running if you get the prompt "root@localhost:/#". But lets load the interface you are familiar with.
  6. Type the following and enter "y" to any prompts: (Don't actually type the text in red)
    Code:
    apt-get update
    apt-get install openssh-server
    /etc/init.d/ssh start
    passwd
    [COLOR="Red"](Enter the password you want to use when connecting.)[/COLOR]
    ifconfig
  7. Now look for the IP address of your phone. Connect to your phone using the SSH client from a computer that is on the same network. Username: root
  8. Once you have successfully logged in type:
    Code:
    export LANG=en_US.UTF-8
    apt-get install tightvncserver 
    apt-get install lxde
    cat > /root/.vnc/xstartup
    #!/bin/sh
    xrdb $HOME/.Xresources
    xsetroot -solid grey
    icewm &
    lxsession
    [COLOR="Red"](After that last line, hit Ctrl + D twice.)[/COLOR]
    cat > front
    export USER=root
    cd /
    rm -r -f tmp
    mkdir tmp
    cd /
    vncserver -geometry 800x600
    [COLOR="Red"](After this last line, hit Ctrl + D twice.)[/COLOR]
    cat front /root/.bashrc > temp
    cp temp /root/.bashrc
    export USER=root
    vncserver -geometry 800x600
    [COLOR="Red"](Enter Password and Enter "no" to the prompt)[/COLOR]
  9. While all this has been happening, your phone has been happily sitting there. It should still be fully functional.
  10. Fire up the Android-VNC-Viewer app:
    Nickname: Ubuntu
    Address: 127.0.0.1
    Port: 5901
    Color Format: 24-bit color
  11. Hit connect and be amazed.
  12. Things will run somewhat sluggish. It should run faster if you connect via a desktop using a VNC client.
  13. After a reboot, if you want to run Ubuntu again, run the following command through any script or terminal:
    Code:
    bootubuntu

Current Bugs:
  • The soft keyboard isn't mapped correctly.
  • It slows down the system when it is running.

Now you have a full fledged linux server running on your tiny phone.
Enjoy!

Here is how you can make your own custom Ubuntu image: How to Build CHROOT ARM Ubuntu Images for Android!

Credit to this extremely long youtube clip: YouTube - How to Install Ubuntu on Android!

Originator of this: Debian & Android Together on G1 - Jay Freeman (saurik)
 
Last edited:

LeslieAnn

Android Developer
Feb 8, 2011
2,895
1,720
0
Visit site
Wow!,
Very nice.


By the way, you have an error here (unless I'm wrong):
"root@localhoat:/#"
Should be localhost, no idea how I caught that while glancing at it.
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Why not?

Even without the interface loaded, you can run anything you want. Hmmmm, one Idea I just had was to setup your own google voice client, but that might not be practical.
 

drezliok

Well-known member
Mar 12, 2011
451
54
0
Visit site
I just didn't see any practical application to losing 2gig on your SD card. What can the Ubuntu server do that an app from market can't do better? I have an FTP app to in-pocket sync with.
 
Last edited:

LeslieAnn

Android Developer
Feb 8, 2011
2,895
1,720
0
Visit site
I just didn't see any practical application to losing 2gig on your SD card. What can the Ubuntu server do that an app from market can't do better? I have an FTP app to in-pocket sync with.

You could run a torrent client, mini-web server, file server... anything you can do with Linux. Yes, I know Android can do most of that, but not all.

As for losing 2 gigs...
Many of us have plenty to spare.


I'm kind of curious why it's 2 gigs when a live/install disk is only 600megs or so.
 

00_wrath_00

Well-known member
Mar 11, 2011
657
82
0
Visit site
So this actually puts Ubuntu on our phones as a second os ? I'm a little confused. Sorry for the noob question but how else am I going to learn lol

Sent from my LG-VM670 using Tapatalk
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
You could run a torrent client, mini-web server, file server... anything you can do with Linux. Yes, I know Android can do most of that, but not all.

As for losing 2 gigs...
Many of us have plenty to spare.


I'm kind of curious why it's 2 gigs when a live/install disk is only 600megs or so.

The two gigs is a choice. You can actually make it smaller or bigger, but that is space set aside for your Ubuntu system. This is how android and Ubuntu are kept separate from one another.

@00_wrath_00
This runs Ubuntu on top of Android. So yes, it is a second OS, but it is running within the Android environment. This is actually perfect, because android provides all the drivers. It can use anything android uses.
 

drezliok

Well-known member
Mar 12, 2011
451
54
0
Visit site
The two gigs is a choice. You can actually make it smaller or bigger, but that is space set aside for your Ubuntu system. This is how android and Ubuntu are kept separate from one another.

@00_wrath_00
This runs Ubuntu on top of Android. So yes, it is a second OS, but it is running within the Android environment. This is actually perfect, because android provides all the drivers. It can use anything android uses.

That's awesome.

Might do it, for a Linux to Linux mount-able networking. The ftpserver is nice but I have to change my fstab everytime I reboot the router.
 

Liquidplacidity

Well-known member
Feb 8, 2011
153
20
0
Visit site
I was gonna post a tutorial on this a long time ago, but I had so many problems getting it set up, that I never did. It was giving me all kinds of errors, that took me 3 hours to fix. Definitely not for people new to linux. lol. Oh and as for building your own custom installation, you can ONLY do it with Ubuntu 8. Ubuntu 8 was the first with ARM processor support. Our processors are ARM6, Ubuntu 9 and up only support ARM7 processors. Just thought i'd save ya the time of finding that out yourself.
 
  • Like
Reactions: Lumify and mmarz
Feb 19, 2011
1,971
284
0
Visit site
Wondered about Ubuntu.
Been running Debian squeeze for a while on my V. Sid works too.
My setup is based much on Saurik's work too, but I suspect the loop-mounted filesystem image is slowing things down for you. I'm using an ext4 partition instead (started with ext2 but SD cards are cheap and I'd rather the journaling cause wear than get ext2 corruption in a crash.)
Since Android mostly lives in flash memory, I bind-mount everything into the root filesystem. Rare crashes don't seem to mess anything up.
Debian file-managers make a great root explorer in the VNC.
Main geeky uses are Firefox (actually Iceweasel) for browsing Android can't handle and saving web pages, file compression/decompression without picky semifunctional apps, the compilers, a real bash terminal... I'm sure I forgot something.
I started with a 2GB card and am now using an 8GB.
@OP: could you share your boot script seperate from the Ubuntu image?
and, are you able to successfully use unionfs? I'll share details too if there is interest
 

mmarz

Well-known member
Mar 9, 2011
1,130
447
0
Visit site
Wondered about Ubuntu.
Been running Debian squeeze for a while on my V. Sid works too.
My setup is based much on Saurik's work too, but I suspect the loop-mounted filesystem image is slowing things down for you. I'm using an ext4 partition instead (started with ext2 but SD cards are cheap and I'd rather the journaling cause wear than get ext2 corruption in a crash.)
Since Android mostly lives in flash memory, I bind-mount everything into the root filesystem. Rare crashes don't seem to mess anything up.
Debian file-managers make a great root explorer in the VNC.
Main geeky uses are Firefox (actually Iceweasel) for browsing Android can't handle and saving web pages, file compression/decompression without picky semifunctional apps, the compilers, a real bash terminal... I'm sure I forgot something.
I started with a 2GB card and am now using an 8GB.
@OP: could you share your boot script seperate from the Ubuntu image?
and, are you able to successfully use unionfs? I'll share details too if there is interest

You're right, it does slow things down. How much better is your setup?

Because it does slow things down, I never made a startup script. I would imagine that it would just be that single line "bootubuntu". The rest of it is set to autostart within the image.

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

And

Code:
export USER=root
cd /
rm -r -f tmp
mkdir tmp
cd /
vncserver -geometry 800x600

added to /root/.bashrc


...But I just realized now why it hasn't been working.

Code:
vncserver -geometry 800x600

prompts for a password. Dang! As you can see, I'm no expert.

I am very interested in your setup. If it runs faster, we should scrap what I stole from that video and go with yours.
 
Feb 19, 2011
1,971
284
0
Visit site
You're right, it does slow things down. How much better is your setup?

Because it does slow things down, I never made a startup script. I would imagine that it would just be that single line "bootubuntu". The rest of it is set to autostart within the image.
I meant the "bootubuntu" file as the startup script.
...But I just realized now why it hasn't been working.

Code:
vncserver -geometry 800x600

prompts for a password. Dang! As you can see, I'm no expert.
the first time you run vncserver, it wants you to set up the password to access the VNC from the app or another (remote) computer.
Saurik's page details that process well, after setting the password in linux you need to enter it in the VNCviewer.
edit:sorry, Saurik uses SSH. The best description I've found for the VNC is here: on xda
Your setup runs without a VNC password? Interesting.
I am very interested in your setup. If it runs faster, we should scrap what I stole from that video and go with yours.
I'd like to compare. Both should be somewhat similar since it's Saurik's pioneering which seems to have driven much of the "linux-on-devicex" work out there. And, both of our systems are Debian based, which should keep other differences to a minimum.
My current boot script needs reduced with a couple of loops, right now it's overly redundant for debugging and I never bothered to clean it up since it's working.
I'll post it relatively soon.
Another detail I forgot to mention, is I leave the root filesystem R/W since my version of this runs there instead of in an image. It also works ok with a chroot in the card partition, but I like the root access to everything from Debian which is trickier to manage running from the card instead of binding subdirectories into the / directory of Android.
 
Last edited:
Feb 19, 2011
1,971
284
0
Visit site
!WARNING! Nandroid backup recommended!

Standard disclaimer:
this script may bork your phone, trash your userdata, format system files, and etc., ad nauseum. Use at your own risk.
This script remounts / and /system both read/write and leaves them that way until you type exit in the bash shell of the chroot. Without r/w mounting, installing Debian packages gives some errors, since it's running in the real root filesystem.
All that aside, it's never hurt my device since beginning this experiment in early March, and I've had less than 5 crashes which required a reboot; no crashes at all since March.

Ok, enough suspense.
I've tested my condensed boot script for a day and can't find any obvious glitches, so here it is attached as boot.txt; the forum wouldn't let me attach it without an extension, so rename as boot with no extension.

I remount system r/w, copy the file to /system/xbin and chmod 4755 /system/xbin/boot

Assuming boot.txt is on your phone in /sdcard/download you can type this in a terminal:
Code:
su
mount -o remount /system /system
cp /sdcard/download/boot.txt /system/xbin/boot
chmod 4755 /system/xbin/boot
or with ADB, if boot.txt is in your current working directory
Code:
adb remount
adb push boot.txt /system/xbin/boot
adb shell
su
chmod 4755 /system/xbin/boot
exit

my Debian filesystem is on my 2nd sdcard partition. The comments in the script should explain how to use another partition if you have apps2sd running or somesuch (I don't have many Android apps on my phone so don't need/use apps2sd function)

to use the script as-is, your linux flavor should be in the 2nd card partition.
open a terminal and type
Code:
su
boot
don't kill the terminal app... leave it running in the background.
when you're finished with linux, reopen the same terminal and type
Code:
exit
to cleanly dismount your linux. No reboot required!

notes:
after much experimentation, I prefer the shell in SL4A for a terminal (even though the devs say it's old connectbot) because it runs the terminal as a service rather than just a process. It seems to be less likely for Android's oom killer to terminate that way.

hopefully this helps someone else out. I spent quite a while getting it just how I wanted it, many googlings and picking bits from here and there.
edit: just FYI, I tested this with Cyanogen and AOSP ROMs, with busybox symlinked to the commands it replaces. Doesn't work with stock ROM or others where you have to type things like 'busybox mount -o /system /system'
Also, I initially copied all files from overlapping Android directories into their Debian counterparts, with no overwrites, BEFORE running the boot script (this only needs to be done once AFAIK)
Code:
yes n | cp -aiv /etc/* /sd-ext/etc
 yes n | cp -aiv /root/* /sd-ext/root
 yes n | cp -aiv /sbin/* /sd-ext/sbin
 yes n | cp -aiv /sys/* /sd-ext/sys
 
Last edited:

Forum statistics

Threads
942,987
Messages
6,916,732
Members
3,158,763
Latest member
alfatv