DEVELOPMENT : Ubuntu Lucid CHROOT: updated scripts

Search This thread

anantshri

Senior Member
Feb 22, 2011
687
320
Bangalore
anantshri.info
*********************************************************
For LXDE : check Update 12 April 2011
For netbook launcher : Check update 13 April 2011
for Dropbox Links : check Below. : UPDATE : DROPBOX LINKS MIGHT BE BLOCKED
Screenshots : POST no 5
*********************************************************

Hi All
I am a linux user and have been trying to get my phone to run linux too... so finally after a lot of messing around i got Ubuntu 10.04 aka Lucid runing on my phone.

I used a stack image provided by https://code.google.com/p/android-cruft/ This image is a stripped down version of the Ubuntu img file and hence a good setup for customization.

However the problems i had with this as well as other images so far was following.

1) 2GB is very small when you want and LXDE to run : good for showoff not good for actual working conditions.
2) bootubuntu or bootdebian scripts won't let me keep the system mounted.. as soon as i exit the shell my ubuntu gets unmounted.
3) All the scripts wont play well with APP2SD or simmilar applications.

REQUIRED:

  1. Rooted and busybox installed phone.
  2. Android terminal software would be needed for commands.
  3. Android VNC Viewer.
Alternate Download link (mirror provided by husseinb )
LXDE.7z.001 http://glycogen.net/download/3/
LXDE.7z.002 http://glycogen.net/download/4/

NETBOOK_parts.7z.001 http://glycogen.net/download/5/
NETBOOK_parts.7z.002 http://glycogen.net/download/6/
NETBOOK_parts.7z.003 http://glycogen.net/download/7/
NETBOOK_parts.7z.004 http://glycogen.net/download/8/



DROPBOX Links as alternate download option

NOTE : please use them for alternate download only I have already got one warning for excessive usage.

LXDE
LXDE part 1 : MD5 : 82af57faf360b3f1921b6def4acfe466
LXDE part 2 : MD5 : a59025db138780db79d69f417c4e9f91
NETBOOK
NETBOOK part 1 : MD5 : 08818edcb1b3fff293557d8e56a65bc4
NETBOOK part 2 : MD5 :
58f0561ed74f0f815f045b9014895313
NETBOOK part 3 : MD5 :
4dd9da548d04d7dece03468959a6993a
NETBOOK part 4 : MD5 :
345804d086054bd446397384245ac2db

UPDATE : 13 April 2011

first Post cleared with all old data and only new updated images kept now.

NETBOOK LAUNCHER PRECONFIGURED IMAGES : http://www.megaupload.com/?d=I3V10B4I


UPDATE : 12 April 2011

LXDE preinstalled package : http://www.megaupload.com/?d=657SPCB5

These file contains all the stuff you need.

GUIDE FOLLOWS BELOW

************* USER PORTION START HERE ******************

******STEPS TO FOLLOW ****************


1) extract the content and copy then to /sdcard/ubuntu
2) run 'sh ubuntu.sh' only once.
3) run 'starttux' (is now made to work without userinput so if needed you can place it is startup using gscripts.)
4) run 'tuxcmd'

a) 'ui' inside tuxcmd to start vnc server
to use GUI use any vncviwer and connect to localhost:5901
NOTE : VNCPASSWORD : 12345678
b) to kill vnc server : use 'killui'
5) when you want to stop ubuntu 'stoptux'

********** STEPS END HERE ************

********** THINGS TO KNOW ************


The whole script portion visible is divided into 4 scripts.

  1. Ubuntu.sh <- setup script required to be run once in whole lifecycle.
  2. starttux <- chroot setup script required to be run after every reboot.
  3. tuxcmd <- script to get console based access to ubuntu
  4. stoptux <- script to stop linux.
Besides these 4 files two important commands are available when you login to tuxcmd.

  1. `ui` <- used to start the vnc server
  2. `killui` <- used to stop the vnc server
once you have the image inside tuxcmd you can run vncpasswd to change password.
to use GUI use any vncviwer available in android market.
point it to localhost:5901.
NOTE : VNC PASSWORD : 12345678
******************* USER PORTION END HERE ***************


******************* DEVELOPER SECTION ********************

below i have provided code for all the files mentioned above

Note : I will keep updating the code as and when i do the updation.

UBUNTU.SH
Code:
echo " "
echo "Ubuntu Chroot v0.2-anant-netbook"
echo "This process does NOT damage Android OS!"
echo " "
echo "Original Script by Charan Singh"
echo "Modified for Ubuntu Chroot by Max Lee at NexusOneHacks.net"
echo "Xperia Customized by Anant shrivastava http://anantshri.info "
echo " "
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
echo "Cleaning up old Chunks . . ."
rm /system/bin/tuxcmd
rm /system/bin/starttux
rm /system/bin/stoptux
echo "Creating necessary directories"
if [ ! -d /data/local/mnt ]
then
mkdir /data/local/mnt
fi
#copy the files to places
echo "Setting up files"
cp -f starttux /system/bin
cp -f stoptux /system/bin
cp -f tuxcmd /system/bin
echo "Ubuntu is now configure!"
echo " "
echo "to Start ubuntu type 'starttux'"
echo "once ubuntu started use tuxcmd to gain shell"
echo "when you want to shutdown type 'stoptux'"
STARTTUX

Code:
#Mount SYSTEM RW
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
#exporting useful variables
export kit=/sdcard/ubuntu
export bin=/system/bin
export mnt=/data/local/mnt
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
# Mounting Image to the farthest loop point
# FIXME : check if mount sucessfull otherwise abort whole process.
mknod /dev/block/loop255 b 7 255
busybox losetup /dev/block/loop255 $kit/ubuntu.img
busybox mount -t ext2 /dev/block/loop255 $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
# Mounting SD Card inside the CHROOT
busybox mount -o bind /sdcard /data/local/mnt/sdcard
#seting environment
sysctl -w net.ipv4.ip_forward=1
echo "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.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "Setting localhost on /etc/hosts "
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "Brought to you by NexusOneHacks.net and the open source community! "
echo "Customized by Anant shrivastava http://anantshri.info"
echo "Ubuntu configured to use it just type 'tuxcmd'"
TUXCMD
Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
export kit=/sdcard/ubuntu
export bin=/system/bin
export mnt=/data/local/mnt
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
echo "Brought to you by NexusOneHacks.net and the open source community! "
echo "Customized by Anant shrivastava http://anantshri.info"
echo " "
busybox chroot $mnt /bin/bash
STOPTUX
Code:
#Cleanup
#After exit command is executed clear it all up
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
export kit=/sdcard/ubuntu
export bin=/system/bin
export mnt=/data/local/mnt
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
echo "Cleaning the Ubuntu leftover and returning back the memory to Android."
echo "by Anant Shrivastava http://anantshri.info "
echo "Shutting down Ubuntu"
sync
busybox umount -l $mnt/sdcard
busybox umount -l $mnt/dev/pts
busybox umount -l $mnt/proc 
busybox umount -l $mnt/sys 
busybox umount -l $mnt
busybox losetup -d /dev/block/loop255
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
echo " "
echo "Please reboot to properly unmount Ubuntu"
echo "Specially If you recieved an error before this line"
UI <- available inside chroot

Code:
if [ `pgrep Xtightvnc` ]
then
    echo "VNC SERVER Already running"
else
    vncserver -geometry 850x480
fi
KILLUI
Code:
kill -KILL `pidof Xtightvnc` 
rm /tmp/.X11-unix/X1 
rm -rf /tmp/.X1-lock
These launcher Settings are obtained using VNC xstartup file
so posting some sample xstartup files

for default GNOME UI
Code:
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
"$VNCDESKTOP Desktop" &
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
for LXDE same startup file becomes
Code:
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
icewm &
lxsession
for netbook i am using this xstartup
Code:
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
"$VNCDESKTOP Desktop" &
x-window-manager &
export XKL_XMODMAP_DISABLE=1
maximus &
netbook-launcher-efl &

**************** DEVELOPER SECTION END *****************
 
Last edited:

anantshri

Senior Member
Feb 22, 2011
687
320
Bangalore
anantshri.info

Thanks

would love to see a video

I am weak at video's so that might take some time.

or maybe screenshots,

this sounds very well:D

Screenshots I will keep adding here

Standard Command prompt
5602932946_16349f5d81_d.jpg


LXDE running
5602932934_64967894b0_d.jpg


a bonus which i am working on right now
Metasploit unleashed on Xperia
5602348661_8431392e72_d.jpg


Netbook Launcher
5615673790_31c9a40c7e_d.jpg
 
Last edited:

DooMLoRD

Inactive Recognized Developer
Jul 27, 2010
13,191
39,709
Pune
try running them before the OS boots...

u can test this by adding the commands to the file /system/bin/chargemon

*** this is a major system modification and can break recovery/OS booting ***
 
  • Like
Reactions: anantshri

Yperion

Senior Member
Nov 4, 2010
135
24
Agrinio
try running them before the OS boots...

u can test this by adding the commands to the file /system/bin/chargemon

*** this is a major system modification and can break recovery/OS booting ***

I have tried on my mini pro with the debian port, but dont work because the linux cannt use the screen or any other device on the phone. We must port the drivers first and then try this...
 

anantshri

Senior Member
Feb 22, 2011
687
320
Bangalore
anantshri.info
this looks awesome :p so i dont completely follow your guide ... is this stuff dual bootable?

Sorry not yet a dual boot ... would love to do that though.

the GUI you see is a VNC view of the machine.

try running them before the OS boots...

u can test this by adding the commands to the file /system/bin/chargemon

*** this is a major system modification and can break recovery/OS booting ***

Right now Xperia is my one and only handset so playing a bit safe..

also right now trying to understand the whole bootloader bypassing concept and then only will try dual booting also..


I have tried on my mini pro with the debian port, but dont work because the linux cannt use the screen or any other device on the phone. We must port the drivers first and then try this...

I read some discussion somewhere about the meego or meamo porting to xperia those code base do have all such support.
 

RaDi

Senior Member
Aug 8, 2010
558
100
can any one make a scarpit for all this ? ?

thanx

anantshri , nice one sir :)
 

DooMLoRD

Inactive Recognized Developer
Jul 27, 2010
13,191
39,709
Pune
....

Right now Xperia is my one and only handset so playing a bit safe..

also right now trying to understand the whole bootloader bypassing concept and then only will try dual booting also..
...

luckily the Xperia androids are pretty much un-brickable...

:)

u can always use SEUS to repair device OR flashtool to flash stock ROM...
 

anantshri

Senior Member
Feb 22, 2011
687
320
Bangalore
anantshri.info
  • Like
Reactions: Meikrekel

Top Liked Posts

  • There are no posts matching your filters.
  • 29
    *********************************************************
    For LXDE : check Update 12 April 2011
    For netbook launcher : Check update 13 April 2011
    for Dropbox Links : check Below. : UPDATE : DROPBOX LINKS MIGHT BE BLOCKED
    Screenshots : POST no 5
    *********************************************************

    Hi All
    I am a linux user and have been trying to get my phone to run linux too... so finally after a lot of messing around i got Ubuntu 10.04 aka Lucid runing on my phone.

    I used a stack image provided by https://code.google.com/p/android-cruft/ This image is a stripped down version of the Ubuntu img file and hence a good setup for customization.

    However the problems i had with this as well as other images so far was following.

    1) 2GB is very small when you want and LXDE to run : good for showoff not good for actual working conditions.
    2) bootubuntu or bootdebian scripts won't let me keep the system mounted.. as soon as i exit the shell my ubuntu gets unmounted.
    3) All the scripts wont play well with APP2SD or simmilar applications.

    REQUIRED:

    1. Rooted and busybox installed phone.
    2. Android terminal software would be needed for commands.
    3. Android VNC Viewer.
    Alternate Download link (mirror provided by husseinb )
    LXDE.7z.001 http://glycogen.net/download/3/
    LXDE.7z.002 http://glycogen.net/download/4/

    NETBOOK_parts.7z.001 http://glycogen.net/download/5/
    NETBOOK_parts.7z.002 http://glycogen.net/download/6/
    NETBOOK_parts.7z.003 http://glycogen.net/download/7/
    NETBOOK_parts.7z.004 http://glycogen.net/download/8/



    DROPBOX Links as alternate download option

    NOTE : please use them for alternate download only I have already got one warning for excessive usage.

    LXDE
    LXDE part 1 : MD5 : 82af57faf360b3f1921b6def4acfe466
    LXDE part 2 : MD5 : a59025db138780db79d69f417c4e9f91
    NETBOOK
    NETBOOK part 1 : MD5 : 08818edcb1b3fff293557d8e56a65bc4
    NETBOOK part 2 : MD5 :
    58f0561ed74f0f815f045b9014895313
    NETBOOK part 3 : MD5 :
    4dd9da548d04d7dece03468959a6993a
    NETBOOK part 4 : MD5 :
    345804d086054bd446397384245ac2db

    UPDATE : 13 April 2011

    first Post cleared with all old data and only new updated images kept now.

    NETBOOK LAUNCHER PRECONFIGURED IMAGES : http://www.megaupload.com/?d=I3V10B4I


    UPDATE : 12 April 2011

    LXDE preinstalled package : http://www.megaupload.com/?d=657SPCB5

    These file contains all the stuff you need.

    GUIDE FOLLOWS BELOW

    ************* USER PORTION START HERE ******************

    ******STEPS TO FOLLOW ****************


    1) extract the content and copy then to /sdcard/ubuntu
    2) run 'sh ubuntu.sh' only once.
    3) run 'starttux' (is now made to work without userinput so if needed you can place it is startup using gscripts.)
    4) run 'tuxcmd'

    a) 'ui' inside tuxcmd to start vnc server
    to use GUI use any vncviwer and connect to localhost:5901
    NOTE : VNCPASSWORD : 12345678
    b) to kill vnc server : use 'killui'
    5) when you want to stop ubuntu 'stoptux'

    ********** STEPS END HERE ************

    ********** THINGS TO KNOW ************


    The whole script portion visible is divided into 4 scripts.

    1. Ubuntu.sh <- setup script required to be run once in whole lifecycle.
    2. starttux <- chroot setup script required to be run after every reboot.
    3. tuxcmd <- script to get console based access to ubuntu
    4. stoptux <- script to stop linux.
    Besides these 4 files two important commands are available when you login to tuxcmd.

    1. `ui` <- used to start the vnc server
    2. `killui` <- used to stop the vnc server
    once you have the image inside tuxcmd you can run vncpasswd to change password.
    to use GUI use any vncviwer available in android market.
    point it to localhost:5901.
    NOTE : VNC PASSWORD : 12345678
    ******************* USER PORTION END HERE ***************


    ******************* DEVELOPER SECTION ********************

    below i have provided code for all the files mentioned above

    Note : I will keep updating the code as and when i do the updation.

    UBUNTU.SH
    Code:
    echo " "
    echo "Ubuntu Chroot v0.2-anant-netbook"
    echo "This process does NOT damage Android OS!"
    echo " "
    echo "Original Script by Charan Singh"
    echo "Modified for Ubuntu Chroot by Max Lee at NexusOneHacks.net"
    echo "Xperia Customized by Anant shrivastava http://anantshri.info "
    echo " "
    mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
    echo "Cleaning up old Chunks . . ."
    rm /system/bin/tuxcmd
    rm /system/bin/starttux
    rm /system/bin/stoptux
    echo "Creating necessary directories"
    if [ ! -d /data/local/mnt ]
    then
    mkdir /data/local/mnt
    fi
    #copy the files to places
    echo "Setting up files"
    cp -f starttux /system/bin
    cp -f stoptux /system/bin
    cp -f tuxcmd /system/bin
    echo "Ubuntu is now configure!"
    echo " "
    echo "to Start ubuntu type 'starttux'"
    echo "once ubuntu started use tuxcmd to gain shell"
    echo "when you want to shutdown type 'stoptux'"
    STARTTUX

    Code:
    #Mount SYSTEM RW
    mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
    #exporting useful variables
    export kit=/sdcard/ubuntu
    export bin=/system/bin
    export mnt=/data/local/mnt
    export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
    export TERM=linux
    export HOME=/root
    # Mounting Image to the farthest loop point
    # FIXME : check if mount sucessfull otherwise abort whole process.
    mknod /dev/block/loop255 b 7 255
    busybox losetup /dev/block/loop255 $kit/ubuntu.img
    busybox mount -t ext2 /dev/block/loop255 $mnt
    mount -t devpts devpts $mnt/dev/pts
    mount -t proc proc $mnt/proc
    mount -t sysfs sysfs $mnt/sys
    # Mounting SD Card inside the CHROOT
    busybox mount -o bind /sdcard /data/local/mnt/sdcard
    #seting environment
    sysctl -w net.ipv4.ip_forward=1
    echo "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.conf
    echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
    echo "Setting localhost on /etc/hosts "
    echo "127.0.0.1 localhost" > $mnt/etc/hosts
    echo "Brought to you by NexusOneHacks.net and the open source community! "
    echo "Customized by Anant shrivastava http://anantshri.info"
    echo "Ubuntu configured to use it just type 'tuxcmd'"
    TUXCMD
    Code:
    mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
    export kit=/sdcard/ubuntu
    export bin=/system/bin
    export mnt=/data/local/mnt
    export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
    export TERM=linux
    export HOME=/root
    echo "Brought to you by NexusOneHacks.net and the open source community! "
    echo "Customized by Anant shrivastava http://anantshri.info"
    echo " "
    busybox chroot $mnt /bin/bash
    STOPTUX
    Code:
    #Cleanup
    #After exit command is executed clear it all up
    mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
    export kit=/sdcard/ubuntu
    export bin=/system/bin
    export mnt=/data/local/mnt
    export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
    export TERM=linux
    export HOME=/root
    echo "Cleaning the Ubuntu leftover and returning back the memory to Android."
    echo "by Anant Shrivastava http://anantshri.info "
    echo "Shutting down Ubuntu"
    sync
    busybox umount -l $mnt/sdcard
    busybox umount -l $mnt/dev/pts
    busybox umount -l $mnt/proc 
    busybox umount -l $mnt/sys 
    busybox umount -l $mnt
    busybox losetup -d /dev/block/loop255
    mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
    echo " "
    echo "Please reboot to properly unmount Ubuntu"
    echo "Specially If you recieved an error before this line"
    UI <- available inside chroot

    Code:
    if [ `pgrep Xtightvnc` ]
    then
        echo "VNC SERVER Already running"
    else
        vncserver -geometry 850x480
    fi
    KILLUI
    Code:
    kill -KILL `pidof Xtightvnc` 
    rm /tmp/.X11-unix/X1 
    rm -rf /tmp/.X1-lock
    These launcher Settings are obtained using VNC xstartup file
    so posting some sample xstartup files

    for default GNOME UI
    Code:
    #!/bin/sh
    xrdb $HOME/.Xresources
    xsetroot -solid grey
    "$VNCDESKTOP Desktop" &
    export XKL_XMODMAP_DISABLE=1
    /etc/X11/Xsession
    for LXDE same startup file becomes
    Code:
    #!/bin/sh
    xrdb $HOME/.Xresources
    xsetroot -solid grey
    icewm &
    lxsession
    for netbook i am using this xstartup
    Code:
    #!/bin/sh
    xrdb $HOME/.Xresources
    xsetroot -solid grey
    "$VNCDESKTOP Desktop" &
    x-window-manager &
    export XKL_XMODMAP_DISABLE=1
    maximus &
    netbook-launcher-efl &

    **************** DEVELOPER SECTION END *****************
    5

    Thanks

    would love to see a video

    I am weak at video's so that might take some time.

    or maybe screenshots,

    this sounds very well:D

    Screenshots I will keep adding here

    Standard Command prompt
    5602932946_16349f5d81_d.jpg


    LXDE running
    5602932934_64967894b0_d.jpg


    a bonus which i am working on right now
    Metasploit unleashed on Xperia
    5602348661_8431392e72_d.jpg


    Netbook Launcher
    5615673790_31c9a40c7e_d.jpg
    2
    Update 12 April 2011

    ubuntu image preinstalled with LXDE uploaded and linked on first page.

    this image and scripts have been cleaned a lot and updated based on simmilar efforts on other platforms...

    Note : SDCARD is now properly mounted inside chrooted environment @ /sdcard folder.


    @DoomLord,
    killui has not yet been updated coz i am not sure if direct kill could have an adverse effect on vncserver.
    the command could well be replaced by
    kill -KILL `pidof Xtightvnc`
    2
    suggestion for mounting /data & /system partitions

    @anantshri
    there are various partition layouts (MTD device blocks are different) for X10... so /system partition might not be at /dev/block/mtdblock3 for some X10 models (X10HD has confirmed different partition layout and some others have a different layout)...

    from xRecovery:
    ...

    0.3-release: unified version for all X10 variants and partition layouts

    ...



    use the following workaround to avoid any such issues:

    for remounting /system partition use:
    Code:
    mount -o remount,rw -t yaffs2 `mount | busybox grep /system | busybox awk '{print $1}'` /system


    for remounting /data partition use:
    Code:
    mount -o remount,rw -t yaffs2 `mount | busybox grep '/data yaffs2' | busybox awk '{print $1}'` /data
    2
    http://forum.xda-developers.com/showthread.php?t=962023 can this be done on the x10i...sorry for the noob question...but has any1 tried this???
    Hi varunoza,

    This is exactly what you have pointed.

    we are running ubuntu 10.04 LTS release for better stability.

    However my approach has some salient features.
    1) runs without any trouble even with phones using APP2SD or simmilar softwares. (testing with less then 99 apps installed.)
    2) no need to keep the shell running in background to use the GUI.
    3) once mounted anytime shell could be gained using tuxcmd command.
    4) GUI is not on by default and hence good for those who prefer not to have GUI.
    although its just one command away. all you need to do is "ui" and gui is started.

    hope this clears your doubt.

    Right now i am focusing on
    1) creating a 2-3 step process to set all this up for the first time.
    2) trying to see if i am use chargemon script to perform any of this.
    3) also trying to read how can we go ahead with meego porting to Xperia.