Place Ghantoos

Running Debian on a Samsung Galaxy under Android

Tagged:

I have read many tutorials that explain how to install a debian on the G1 phone (running Google’s Android too).

Here is a compilation of what I have done on my Samsung Galaxy (i7500) in order to get a root access and install a debian system on it.
1- Root access
2- Debian installation

1- Root access

In order to get the root access, I have followed the hacks discovered by drakaz here and here

NOTE FOR DEBIAN/UBUNTU USERS:
In order to get your Debian/Ubuntu OS to recognize the Galaxy Android phone, you’ll have to add the following rules to udev:
Add the following to /etc/udev/rules.d/50-android.rules :

# cat /etc/udev/rules.d/50-android.rules 
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"

And the following to /etc/udev/rules.d/90-android.rules

# vi /etc/udev/rules.d/90-android.rules 
SUBSYSTEMS=="usb", ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="6640", MODE="0660", OWNER="root", GROUP="androiddev", SYMLINK+="android%n"
SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"

Now reload your udev rules:

$ sudo invoke-rc.d udev reload

(In case, this doesn’t work, reboot your machine..)

Back to the Galaxy.
The steps to follow are quite straight forward:
1- Get the new recovery image built from the end of this post and follow the instructions.

NOTE (1): In order to boot in fastboot mode, you must start your phone by pressing on Call + Power buttons
NOTE (2): It is now possible get full root access on you phone following the drakaz’s tutorial above, in this case, skip the next 2 steps. I strongly recommend this option, I just tested it today, and it works great!

Nevertheless, if you still want to install su by yourself, you’ll have to follow drakaz method until step 7, then follow the steps below:

2 (optional) – Get adb & fastboot files from the end of this post and the su command from here (source)
3 (optional) – Once you have reboot in recovery mode (using Volume_Down & Call & Power), you can connect through adb to your phone as root! You will have to copy the su command (source):

$ wget http://www.magicandroidapps.com/su.zip
$ unzip su.zip
$ ./adb remount # this will remount de /system partition in read-write
$ ./adb push su /system/xbin/
$ ./adb shell
#
# chmod 6755 /system/xbin/su
# sync
# reboot

When your phone boots up, open a terminal (I use ConnectBot), and type:

$ ./adb shell
$ su
su: access granted, courtesy of www.magicandroidapps.com
# id
uid=0(root) gid=0(root) groups=1003(graphics),1004(input),1007(log),1011(adb),3001(net_bt_admin),3002(net_bt),3003(inet)

You are now root on your phone!
Now lets install debian.

2- Debian installation

As I said above, I mainly followed the articles about installing Debian on G1 phone running Android: here and here.

First, download the debian image here.

Unzip the file, and mount the debian.img somewhere on your system (this is the only file we will be using from this archive. We will also be using an updated version of bootdeb see below) :

$ sudo mount -o loop debian.img /mnt/
$ ls /mnt/
bin   dev  home  lost+found  mnt  proc  sbin     selinux  sys  usr
boot  etc  lib   media       opt  root  scripts  srv      tmp  var

Now, copy all the files to an external SD card.
WARNING: You must first format you card to ext2, _before_ copying the files.

If you can mount the SD card on you PC, you can use the following command to copy all the files from the mounted debian image to you external SD card:

$ sudo -s
# (cd /mnt/ && tar cfp - . ) | (cd /media/disk/ && tar xvpf -)

Else, you can use adb to send the files to the internal SD of the phone:

$ sudo ./adb push /mnt/ /sdcard/sd/

Now, in order to chroot inside the debian folder, I used busybox as the chroot application itself was not available on my Android.
You can get busybox from here:

$ wget http://cache.saurik.com/android/armel/busybox
(...)
2009-08-08 01:57:18 (1.63 MB/s) - `busybox' saved [1782264/1782264]
$ ./adb push busybox /data/
$ ./adb shell
(on the Galaxy now)
$ su
# export bin=/data/local/bin
# mkdir -p $bin
# mv /data/busybox $bin/ # if cp doesn't work try using cat)
# $bin/busybox uptime
 00:03:06 up  1:16, load average: 2.05, 2.15, 2.16

If the last command works, you can go on to the next step.

Download the updated bootdeb file from here then send it to your phone (the original file can be found in the archive here).

$ wget http://ghantoos.org/misc/scripts/bootdeb

Before sending the file to your phone, please verify what is your external SD card’s device name:

$ ./adb shell
$ mount
(...)
/dev/block/vold/179:9 /sdcard/sd ext2 rw,errors=continue 0 0

In my case, it is “/dev/block/vold/179:9″. If this is not your case, please edit the bootdeb file, and modify the “first” line and save the file:

mount -o remount,rw -t ext2 /dev/block/vold/179:9 /sdcard/sd

Once the bootdeb file is ok, send it to your phone:

$ ./adb push bootdeb /sdcard/
7 KB/s (1857 bytes in 0.256s)

You should now be able to chroot onto your debian SD card using the script above:

$ ./adb shell
$ su
su: access granted, courtesy of www.magicandroidapps.com
# sh /sdcard/bootdeb 

               a888a
             d888888b
             8P YP Y88
             8|o||o|88
             8.    .88
             8 ._.  Y8.
            d/       8b.
          .dP   .     Y8b.
         d8:         ::88b.
        d8             Y88b
       :8P             :888
        8a.    :      _a88P
      ._/ Yaa_ :    .| 88P|
      \    YP        | 8P  \.
      /     \._____.d|    .|
       --..__)888888P ._.|

mount: Device or resource busy
Custom Linux Pseudo Bootstrapper V2.1 - by Mark Walker
WEB: http://www.androidfanatic.com
EML: admin@androidfanatic.com

Running Linux Kernel
net.ipv4.ip_forward = 1
Type EXIT to end session
Make sure you do a proper EXIT for a clean kill of Debian!

kabriteh:/#  uname -a
Linux kabriteh 2.6.27 #1 PREEMPT Thu Jul 2 08:58:33 KST 2009 armv6l GNU/Linux

Here are the first things I did :)

# echo "nameserver 192.168.1.1" > /etc/resolv.conf
# apt-get update
# apt-get install ssh

Now I can now ssh on my Samsung Galaxy phone whenever I want!

I hope was useful (and clear)!

Thank you Mark Walker, Jay Freeman, drakaz, Steffen Lindner and magicandroidapps.com for your contributions!

Cheers,
Ignace M -ghantoos-

PS: Here are some screenshots!

Tagged:

24 Responses

  1. Sasha Sukhi says:

    Hi,
    Did you have solution for Ubuntu 9.04 (jaunty)?
    Thank you in advance
    Sasha.

  2. @Sasha
    Hello,
    You might want to take a look at Paolo Sammicheli’s post about installing Ubuntu Jaunty on an android.
    The ARM port of Ubuntu Jaunty can be found on Paolo’s website.

    Regards,
    Ignace M -ghantoos-

  3. Very nice! I’m planning to do the same on my phone.

    Only one question, since I do not find the answer on the sites of all these wonderful tutorials : did you run the adb commands from a x86_64 linux, or were you on a i386? The provided adb and fastboot are elf32 binaries, and I wonder if I have to install a linux or if can just use the lib32- that come with the android sdk in archlinux.

  4. @Christophe-Marie

    Thank you for your comment.

    I did the above procedure using a i686 machine. You can probably use the provided adb & fastboot binaries on your archlinux even it is installed in x86_64.

    Cheers,
    Ignace M -ghantoos-

  5. cscetbon says:

    I had an error with adb :(

    fastboot is working well, but adb does not found my phone after having boot it in mini recovery mode :

    ./adb push RECTOOLS.tar.gz /sdcard/
    error: device not found

    when I strace adb server it’s reading the device located in /dev/bus/usb/001/028 :

    lsusb|grep -i samsung :

    Bus 001 Device 028: ID 04e8:6603 Samsung Electronics Co., Ltd

    strace -p $adb_pid :

    open(“/dev/bus/usb/001/028″, O_RDWR|O_LARGEFILE) = 7
    read(7, “\22\1\2\2\2@\350\4\3f\1\3\2\1\1\t\2 \1\2\300\1\t\4\2\10″…, 256) = 50
    close(7) = 0

    Something is going wrong …

  6. @cscetbon

    Hey,

    Have you tried the use adb as root?

    $ sudo ./adb push RECTOOLS.tar.gz /sdcard/

    I had the same problem, using sudo(8) resolved the problem.

    Hope this helps,
    Cheers,
    Ignace M -ghantoos-

  7. cscetbon says:

    I was root when I did it :(

  8. cscetbon says:

    I tried with sudo and of course it said the same error :

    cyril@noraa$ sudo ./adb push RECTOOLS.tar.gz /sdcard/
    * daemon not running. starting it now *
    * daemon started successfully *
    error: device not found

  9. fiasko says:

    In first thanks for your tuto!

    I had tried but without succes for moment…

    I have some errors when i trying to copy the file (in the mounted image) to my external sd card(ext2)..some errors appears.

    What is the difference between those 2 things?:
    -copy files directly from /mnt/ directory to external sd by just copy/paste (i suppose?)
    -extract and copy files to external sd with this command line :(cd /mnt/ && tar cfp – . ) | (cd /media/disk/ && tar xvpf -)

    If i had understand i can also copy files by adb push command line.But to internal sd card in ext2??

    The “weight” of files in my external sd after copying is about 350 Mo and you?

    Finaly what i’m doing wrong??

    thanks and sorry for my bad english !

  10. fiasko says:

    bonjour,
    si vous parlez francais ça peut m’aider!!! :-)

    J’ai vu votre cv…

    merci

  11. alexombola@gmail.com says:

    Nice post. Thanks for sharing these tips.

  12. @fiasko

    Désolé pour le retard de cette réponse. J’ai cru comprendre sur un forum que tu avais finalement réussi à installer la debian ;)

    Si tu as toujours besoin d’aide, n’hésite pas à m’envoyer un mail.

    Cheers,
    Ignace M -ghantoos-

  13. PeLF says:

    Thank !
    Very good.

    Just, cp and mv havent dont work, but with cat /sdcard/xxxxx>/data/local/bin/xxxxx it’s work

  14. ivanjo10 says:

    Hi all,
    I have a problem with some steps. I managed to have a root access (everything went without a glitch) but now when I try to install busybox, I have a problem. When i try

    mkdir -p $bin

    i get an error = read only file system

    also when I do a ls -la i get

    -la No Such File Or Directory

    It seems that my firmware is a little shorter on commands (IG8 FW). Any ideas?

  15. Empas says:

    Hi. It is good tutorial, thanx!
    I want to try it on my Galaxy Spica. What do you think about it? I can’t see any steps specified to Galaxy and which can break my phone. I really want to hear your opinion about it =)
    Also i’m intersted about aircrack on it. Did you try it?
    Sorry for my english ;)

  16. Empas says:

    There is small problem….adb and my phone can’t see sdcard after converting to ext2. because of that i can’t do this “# sh /sdcard/bootdeb “

  17. masbikun says:

    if you know where I can get the Samsung Knack User Manual, I’ve been looking but have not found it

  18. sunb says:

    you are great!
    Thanks a lot!

  19. [...] halt euch mal auf dem Laufenden: ich habe unsere bereits funktionierende Debian-Konsole genommen ( Place Ghantoos Running Debian on a Samsung Galaxy under Android ) und dort mit demselben Trick (x11 und VNC) wie dieser von nexusonehacks.org eine LXDE-Umgebung [...]

  20. ech says:

    That was a fun afternoon project :)
    Thanks!

  21. Jesse Taylor says:

    Amazing tutorial. Thank you thank you thank you! I’ve been trying to figure out how to get Debian on my phone for a long time, and this was very helpful pointing me to what I needed to do.

  22. Joe says:

    The 50-rules at the top referring to 18d1 is for the google nexus, which makes the rule unnecessary. The 90-rules referring to 4e8 is where the udev actually uses the rule to recognize the samsung.

Leave a Reply

Archives