How to install ubuntu on the Droid 4

Search This thread

greekchampion04

Senior Member
Apr 6, 2011
141
22
How to install ubuntu on the Droid 4

Note to mods: this thread is a branch off of this thread

Huge thanks to zacthespack for creating the ubuntu installer app and original boot script and to zeroktal for modifying the script to work on the D4 and helping me get it working on my device.

I decided to take my experience in setting this up and put it into a how-to so that others could enjoy the experience of having ubuntu on the Droid 4. If zackthespac or zeroktal have any problems with me making and putting this guide up, please let me know and I will remove it.

Knowledge Required:
  • working knowledge of command line
  • working knowledge of vi
  • OR the ability to learn how to use both

Tools Required:

Step by Step:
  1. Install BusyBox, Terminal, and Android VNC Viewer
  2. Install and run Ubunutu Installer App
  3. Follow the on-screen instructions and click next
  4. Download either the Small or Large image to your phone, (use zeroktal's ubuntud4.zip file instead of the boot script provided in the guide) after the image downloads (will take a while because the file is HUGE) click next
  5. For this screen, the instructions differ from the app.
    1. With your D4 plugged into your PC in USB Mass Storage, create a directory (folder) called ubuntu in the EXTERNAL sdcard's root*
    2. Extract the image you downloaded to that directory
    3. Download and extract the attached .sh (ununtud4.zip) to that directory
    4. Disconnect your phone from your PC
    5. Open terminal and run the following commands:
    su [ENTER]
    mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext [ENTER]
    cd /mnt/sdcard-ext/ubuntu [ENTER]
    sh ubuntud4.sh [ENTER]
    960x540 [ENTER]**
    If you get an error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") see troubleshooting section below.​
    killall -TERM Xtightvnc [ENTER]
    vncserver :1 -geometry 960x540 [ENTER]**
    6. Open androidVNC app and enter the following settings:
    Nickname: Anything you want
    Password: ubuntu
    Address: localhost
    Port: 5901
    Color Format: 24-bit color (4 bpp)
    7. Hit connect
    8. Hit your menu soft button and then set input mode to touchpad
    9. You have ubuntu on your Droid 4!

To "shut down" ubuntu:
  • press the menu button, select disconnect in VNC
  • In terminal type this command 3 times (terminal will close itself when you are done):
    exit [ENTER]

To "start up" ubuntu again:
  • Follow steps 5-8 above

Troubleshooting:
If you get the error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") you are about to have fun with vi at the command line.

Do the following from inside terminal:
su [ENTER]
cd /mnt/sdcard-ext/ubuntu [ENTER]
vi ubuntud4.sh [ENTER]
If you see ^M or ^ at the end of any line (remember to scroll all the way to the right to see the end of long lines) remove it. once you do that, everything should work just fine. (See the Vi Cheat Sheet above for help with Vi)

Note: Vol Up + E is [ESC] by default in this terminal emulator

Notes:
* It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
*** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!
 

Attachments

  • ubuntud4.zip
    833 bytes · Views: 686
Last edited:

mccompunerd

Member
Oct 29, 2008
11
5
Vancouver, WA
Notes:
* It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
*** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!

I actually got it up and running on my internal sdcard partition. Pretty much just have to modify the Mount remount command, and a few lines in the script.
Here's the original command
Code:
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
And the modified one
Code:
mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard

Only things you have to change are the device location(179:57) and mount location(drop the -ext after sdcard)
Now, after that you also have to modify the script a bit. Just go through it, and anywhere that you see sdcard-ext, drop the -ext off the end.
 
Last edited:
  • Like
Reactions: greekchampion04

greekchampion04

Senior Member
Apr 6, 2011
141
22
thanks for putting that up for everybody! like i said, if you know what you are doing its not a hard swap to make.
 

djdarkside1983

New member
Feb 21, 2012
4
1
Is anyone else getting just a gray screen when they remote in? What could be causing this?
 

Attachments

  • 2012-02-27_11.42.01.jpg
    2012-02-27_11.42.01.jpg
    201 KB · Views: 979

greekchampion04

Senior Member
Apr 6, 2011
141
22
i had that same problem at first... did you use zeroktal's ubuntud4.zip file? or did you use the ubuntu.sh file included in the app?
 

djdarkside1983

New member
Feb 21, 2012
4
1
I used the sh file included. I did however fix the problem, when mounting at the start i confused vold with void. I did not get the file system mounted properly. This method does work!! however I am currently trying to get bash on my droid to replace sh as the shell. I've checked the forums but have not found anything yet about someone installing bash on the droid 4. With no way for nandroids I feel i should wait before I kill sh.

Sent from my DROID4 using XDA App
 

zeroktal

Senior Member
Nov 8, 2006
284
42
If you mod your init.sh in your root directory to the following, your vnc will work on startup without issue. It will also shutdown vnc on exit.



#!/bin/bash
#############################################
# Asks User to screen size and saves as REZ #
#############################################
#echo "Now enter the screen size you want in pixels (e.g. 800x480), followed by [ENTER]:"

#read REZ

##############################################
# Pick which desktop environment to use, this#
# is done by having a xstartup file for each #
# desktop, then renaming the one you want to #
# use to 'xstartup' before boot #
##############################################
echo "Please select which Desktop environment you want to use, type the number to select it then press [ENTER]"
echo "1 - LXDE"
echo "2 - Gnome"
echo "Make your Selection:"
read DESKTOP
if [ $DESKTOP == 1 ]
then
mv /root/.vnc/lxstartup /root/.vnc/xstartup
fi
if [ $DESKTOP == 2 ]
then
mv /root/.vnc/gxstartup /root/.vnc/xstartup
fi

###########################################
# Tidy up previous LXDE and DBUS sessions #
###########################################
rm /tmp/.X* > /dev/null 2>&1
rm /tmp/.X11-unix/X* > /dev/null 2>&1
rm /root/.vnc/localhost* > /dev/null 2>&1
rm /var/run/dbus/pid > /dev/null 2>&1

############################################################
# enable workaround for upstart dependent installs #
# in chroot'd environment. this allows certain packages #
# that use upstart start/stop to not fail on install. #
# this means they will have to be launched manually though #
############################################################
dpkg-divert --local --rename --add /sbin/initctl > /dev/null 2>&1
ln -s /bin/true /sbin/initctl > /dev/null 2>&1


###############################################
# start vnc server with given resolution and #
# DBUS server, (and optionally an SSH server) #
###############################################
dbus-daemon --system --fork > /dev/null 2>&1
/etc/init.d/ssh start
vncserver :1 -geometry 960x540
echo
echo "If you see the message 'New 'X' Desktop is localhost:1' then you are ready to VNC into your ubuntu OS.."
echo
echo "If VNC'ing from a different machine on the same network as the android device use the 1st address below:"
##########################################
# Output IP address of android device #
##########################################
ifconfig | grep "inet addr"

echo
echo "If using androidVNC, change the 'Color Format' setting to 24-bit colour, and once you've VNC'd in, change the 'input mode' to touchpad (in settings)"

echo
echo "To shut down the VNC server and exit the ubuntu environment, just enter 'exit' at this terminal - and WAIT for all shutdown routines to finish!"
echo

###############################################################
# Spawn and interactive shell - this effectively halts script #
# execution until the spawning shell is exited (i.e. you want #
# to shut down vncserver and exit the ubuntu environment) #
###############################################################
/bin/bash -i

#########################################
# Disable upstart workaround and #
# kill VNC server (and optionally SSH) #
# Rename used xstartup to its first file#
#########################################
killall -TERM Xtightvnc
/etc/init.d/ssh stop
 

zeroktal

Senior Member
Nov 8, 2006
284
42
Also save the follow lines between ### as remount.sh on your system partition. Then chmod 755 /system/remount.sh. Now you can just run run from a terminal /system/remount.sh and voila it remounts correctly and starts ubuntu(with the above fixes). Im still working on the unmounts.

####### for the internal sd card
mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard
/mnt/sdcard/ubuntu/ubuntu.sh
######

OR

####### for the external sd card
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
/mnt/sdcard-ext/ubuntu/ubuntu.sh
#######
 
  • Like
Reactions: greekchampion04

dopeismarcus

Member
Jan 28, 2009
38
6
QUESTION:

After I delete all the ^M and ^ what do i do next? I try to hit the command ":x" to exit and save changes but it just creates another line. Also when I press VOL UP + E to escape nothing happens.
 
Last edited:

dopeismarcus

Member
Jan 28, 2009
38
6
OK I fixed it but now its not letting me connect with androidVNC. All the settings entered is correct but when I try to connect it says:

"VNC connection failed!" localhost/127.0.0.1:5901 - Connection refused"
 

tallelf78

Member
Feb 28, 2012
9
1
ok, i've gone thru this a few times (slowly and deliberately) and must be missing something...the directions seem pretty straightforward! here's what i know...

busy/terminal/vnc are all installed
small 2.5gb image is unzipped in /sdcard-ext/ubuntu directory
the attached .sh file from page 1 is in the same directory
i removed all ^M using vi
but when I try sh ubuntud4.sh i get an error...

"mkdir failed for /data/local/mnt/ubun, No such file or directory"

(plus a few other errors)

should the directory be "ubun" or "ubuntu"? am I typing something incorrectly?
 

zeroktal

Senior Member
Nov 8, 2006
284
42
copy and paste new script

Copy and paste the new scripts I posted. They will fix your problem. Remember to use the remount script from /system/ the rest will work perfectly if you are root. I'll check back later on your progress.
 
  • Like
Reactions: tallelf78

tallelf78

Member
Feb 28, 2012
9
1
Ok, well I started from scratch (deleted both .img and .sh files) and it's still not working.

I have all the apps installed (and yes rooted, SU works just fine)
I used Ubuntu Installer app to download the image zip (tried both the large and small img)
I downloaded the .sh file from the first post
The /sdcard-ext/ubuntu/ folder now has two files: "ubuntu.img" and "ubuntud4.sh"
All ^M characters have been removed from .sh file
Still no joy...

Ideas? What am I missing?

In terminal, I can set SU permissions and the mount/cd commands work just fine...it's the last sh command that spits out a bunch of errors about not being able to create/find the directories.

I'm going to format the sdcard and try again...any help is appreciated.

Update: Even after re-formatting the SD and following the steps exactly, no luck!
 
Last edited:

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,827
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
Andbuntu will work much better than this method. It works on every single phone with modification to the "environmental variables".

http://code.google.com/p/andbuntu/

Follow the directions in the script to make the process much easier than the first post.

instructions:
generate an image with rootstock on an ubuntu computer.
put it on /sdcard/ubuntu/ubuntu.img
run the script on your phone with "sh /path/to/script"

Here is the script. http://andbuntu.googlecode.com/svn/trunk/uboot

Also, run "firstRun" to make things like terminals work properly.
 
Last edited:
  • Like
Reactions: russellvone

zeroktal

Senior Member
Nov 8, 2006
284
42
Adamoutler: That didnt work for me. The permissions were incorrect on the mounted partitions.

Sent from my DROID4 using XDA App
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    How to install ubuntu on the Droid 4

    Note to mods: this thread is a branch off of this thread

    Huge thanks to zacthespack for creating the ubuntu installer app and original boot script and to zeroktal for modifying the script to work on the D4 and helping me get it working on my device.

    I decided to take my experience in setting this up and put it into a how-to so that others could enjoy the experience of having ubuntu on the Droid 4. If zackthespac or zeroktal have any problems with me making and putting this guide up, please let me know and I will remove it.

    Knowledge Required:
    • working knowledge of command line
    • working knowledge of vi
    • OR the ability to learn how to use both

    Tools Required:

    Step by Step:
    1. Install BusyBox, Terminal, and Android VNC Viewer
    2. Install and run Ubunutu Installer App
    3. Follow the on-screen instructions and click next
    4. Download either the Small or Large image to your phone, (use zeroktal's ubuntud4.zip file instead of the boot script provided in the guide) after the image downloads (will take a while because the file is HUGE) click next
    5. For this screen, the instructions differ from the app.
      1. With your D4 plugged into your PC in USB Mass Storage, create a directory (folder) called ubuntu in the EXTERNAL sdcard's root*
      2. Extract the image you downloaded to that directory
      3. Download and extract the attached .sh (ununtud4.zip) to that directory
      4. Disconnect your phone from your PC
      5. Open terminal and run the following commands:
      su [ENTER]
      mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext [ENTER]
      cd /mnt/sdcard-ext/ubuntu [ENTER]
      sh ubuntud4.sh [ENTER]
      960x540 [ENTER]**
      If you get an error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") see troubleshooting section below.​
      killall -TERM Xtightvnc [ENTER]
      vncserver :1 -geometry 960x540 [ENTER]**
      6. Open androidVNC app and enter the following settings:
      Nickname: Anything you want
      Password: ubuntu
      Address: localhost
      Port: 5901
      Color Format: 24-bit color (4 bpp)
      7. Hit connect
      8. Hit your menu soft button and then set input mode to touchpad
      9. You have ubuntu on your Droid 4!

    To "shut down" ubuntu:
    • press the menu button, select disconnect in VNC
    • In terminal type this command 3 times (terminal will close itself when you are done):
      exit [ENTER]

    To "start up" ubuntu again:
    • Follow steps 5-8 above

    Troubleshooting:
    If you get the error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") you are about to have fun with vi at the command line.

    Do the following from inside terminal:
    su [ENTER]
    cd /mnt/sdcard-ext/ubuntu [ENTER]
    vi ubuntud4.sh [ENTER]
    If you see ^M or ^ at the end of any line (remember to scroll all the way to the right to see the end of long lines) remove it. once you do that, everything should work just fine. (See the Vi Cheat Sheet above for help with Vi)

    Note: Vol Up + E is [ESC] by default in this terminal emulator

    Notes:
    * It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
    ** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
    *** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!
    1
    Notes:
    * It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
    ** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
    *** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!

    I actually got it up and running on my internal sdcard partition. Pretty much just have to modify the Mount remount command, and a few lines in the script.
    Here's the original command
    Code:
    mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
    And the modified one
    Code:
    mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard

    Only things you have to change are the device location(179:57) and mount location(drop the -ext after sdcard)
    Now, after that you also have to modify the script a bit. Just go through it, and anywhere that you see sdcard-ext, drop the -ext off the end.
    1
    Also save the follow lines between ### as remount.sh on your system partition. Then chmod 755 /system/remount.sh. Now you can just run run from a terminal /system/remount.sh and voila it remounts correctly and starts ubuntu(with the above fixes). Im still working on the unmounts.

    ####### for the internal sd card
    mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard
    /mnt/sdcard/ubuntu/ubuntu.sh
    ######

    OR

    ####### for the external sd card
    mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
    /mnt/sdcard-ext/ubuntu/ubuntu.sh
    #######
    1
    copy and paste new script

    Copy and paste the new scripts I posted. They will fix your problem. Remember to use the remount script from /system/ the rest will work perfectly if you are root. I'll check back later on your progress.
    1
    Andbuntu will work much better than this method. It works on every single phone with modification to the "environmental variables".

    http://code.google.com/p/andbuntu/

    Follow the directions in the script to make the process much easier than the first post.

    instructions:
    generate an image with rootstock on an ubuntu computer.
    put it on /sdcard/ubuntu/ubuntu.img
    run the script on your phone with "sh /path/to/script"

    Here is the script. http://andbuntu.googlecode.com/svn/trunk/uboot

    Also, run "firstRun" to make things like terminals work properly.