FORUMS
Remove All Ads from XDA

[GUIDE] Running Debian Linux on Xperia X8 (chroot)

31 posts
Thanks Meter: 16
 
By krzysiek_grucha, Member on 8th September 2011, 07:33 PM
Post Reply Email Thread
First of all please notice, that this is not my own development project, it is just a port of the guide for HTC G1 from http://pdaclub.pl/forum/htc-dream/%2...a-%28na-g1%29/ for Xperia X8.

Please be aware, that this solution has been only tested with one Xperia X8 device running Floyo 0.30 (thanks to Racht for this great ROM !). I cannot guarantee that it will work on every other custom ROM as well as on the stock Xperia X8 ROM's.
Please also notice, that instructions in this tutorial in some cases can brick Your phone. I'm not responsible for any damage to the software or hardware caused by this tutorial. You can follow the instructions from this guide but only at Your own responsibility!


Please also notice, that I'm not an Android Developer. I'm just a user with some knowledge about Unix, so don't blame me if this tutorial won't work for You. You can post Your problems and we'll try to solve it together.

OK, I think that's all for the intro .

TABLE OF CONTENTS:
1) The purpose of this guide
2) Requirements
3) Things to prepare
4) Installation
5) Some known bugs
6) Some little tips

1) The purpose of this guide.

This guide reffers to the newbie users who want to run Debian Linux on their Xperia X8. Step by step I'll try to explain how to run Debian simultaneously (at the same time) with Android. To gain that we'll use a program/command chroot (http://en.wikipedia.org/wiki/Chroot) which will allow us to Run Debian in Android as something similiar to "virtual machine" on PC.

You may ask why to run Debian on Android device ?
There are several answers to that question:
a. For testing...
b. ...developing applications in for e.g. C/C++ for ARM platform and try to run them on Android OS.
c. Installing Linux applications (like web servers, WiFi cracking software) and test what is working and what isn't.
d. For fun

For those who are asking what Debian actually is - please refer to the page http://en.wikipedia.org/wiki/Debian.

2) Requirements.

Before continuing check if You and Your device meet the following requirements:

a. ROOTED Xperia X8 device (I recomend to have Floyo 0.30 by Racht ROM installed, because it was tested on this ROM. I don't know if it'll work on different ROM's.)
b. At least 800MB space free on Your SD Card
c. Access to PC computer
d. Basic knowledge about Windows command line and Linux shell
e. About 1 hour of free time to set up everything

3) Things to prepare.

a. Download one of the following packages:
or
These are the packages containing Debian drives image as well as all other files needed to install Debian on Android. The only difference is that the first one is 750MB and the second is 1,5GB. The second one is for bigger SD Cards, you'll get more free space in Your "virtual machine" after running it.
b. ADB Shell (can be found in Android SDK in folder platform-tools\ - http://developer.android.com/sdk/index.html)
c. SSHDroid from Market (only if You're planning to connect to Your Debian via SSH)
d. PuTTY for Windows (only if You're planning to connect to Your Debian via SSH - http://www.chiark.greenend.org.uk/~s.../download.html)
e. ConnectBot or Terminal Emulator from Market (it's a good terminal application)

The bold items are necessary.

4) Installation.

PERFORM A FULL SYSTEM BACKUP USING XRECOVERY BEFORE PROCEEDING ANY FURTHER !

Now the best part !
There are several ways to install Debian:
1) Some are using Terminal Emulator application (preinstalled in Floyo 0.30)
2) Others are connecting with phone via SSH
3) But some are using adb shell command from Android SDK and that's the way we'll do this, because I know there are some differences between using adb shell and other ways. I tested it with adb and it is working so I think it is the right choice.

First, unpack the *.rar file of Your choice (debian750.rar or debian1.5.rar) to Your hard disk on a PC.

Replace file bootdeb which can be found in Debian folder after unpacking the archive with the one from bootdeb.zip file attached to this post. You need to do this, because the bootdeb file which is in the archive won't let You boot Debian correctly. It'll only cause Xperia X8 to restart after few seconds since execution. The file in bootdeb.zip has been corrected by me and it allows to boot Debian without any (known ) bugs.

Copy the Debian folder from the archive directly to the SD Card (also known as a root directory of Your SD Card). You should have the following directory tree on Your SD Card visible in Xperia X8:
Quote:

/sdcard/Debian/bootdeb
/sdcard/Debian/debian.img
/sdcard/Debian/installer.sh
etc...

Enable USB Debugging in Xperia X8. To do this go to Settings->Applications->For programmers and check USB Debigging.

Connect Your phone via USB and don't mount the SD Card (just like You want to charge the phone via USB).

On Your PC click Start->Run, type cmd and cd to the directory where You installed Android SDK, then cd to platform-tools and execute command adb shell. After execution You should see a # symbol in the command line window like on a below screenshot:



Now execute the following commands in ADB ahell on PC:
Quote:

su
cd /
sh /sdcard/Debian/installer.sh

And You shoul get something like this:
Quote:

VERSION 2.1
Custom Debian Bootloader is now installed! Quick huh?
etc...

And it's done ! Debian Linux has been installed.
Type in ADB Shell command
Quote:

exit

As many times (I guess 3) until command line window disappears. Disconnect Your phone from PC and unplug the USB cable.

Now let's try to run Debian - on Xperia X8 run ConnectBot or Terminal Emulator and type:
Quote:

su
sh /sdcard/Debian/bootdeb

Remember to allow the terminal application to run as a superuser.

After a while You should see a screen similar to the below screen shot:



I removed the lines (blured section) which You won't see after first boot. I have them, because I installed Apache Web Server and it is starting at the logon .
As You can see we are logged into Debian Linux !

Now, execute the following command:
Quote:

/scripts/onetime.sh

It's necessary only after first logon. It'll let You to set up root password (only for Debian, not for Android) and do some more stuff (actually I didn't even check what this script is doing - forgive me).

And it's done... Now You are on Your own with Debian installed ! Go, play around, because it is a fully functional operating system for Your demand .

What about the performance ?
My Debian is still working since one day in the background (minimize the Terminal Emulator window after logging in) and I haven't suffer any problems with the low performance yet. I even set up an icewm window manager and VNC Server to be able to log in to my machine via VNC client and see the desktop and it isn't too laggy . But that's only a stupid future. The most power we get because of the access to Linux Shell (the command line which let us to use Linux applications on our Xperia X8).

4) Some known bugs.

For Your own safety read this short section.

1) Better don't try to unmount the SD Card from Xperia X8 (for e.g. when mounting the phone to the PC) when Debian is running. I didn't try this yet, but the bootdeb script is creating something called loop device in the Android system which should be properly unmounted. If this device will wanish due to some user activity the phone may not boot correctly any more.

2) When You finish playing with Debian always use the exit command to safely unmount the loop filesystem. After exit Your phone needs to be rebooted, better don't try to override this setting.

3) If somehow You will loose connection with Debian in Terminal Emulator You always can run:
Quote:

sh /sdcard/Debian/bootdeb

And log in again. You'll just receive several errors on the boot screen, because the script will try to mount already mounted file system.

5) Some little tips.

1) After first logon execute the following commands:
Quote:

cd /etc/apt
nano sources.list

And in the opened text editor add these lines (do not overwrite the file contents):
Quote:

deb http://ftp.debian.org/debian lenny main contrib non-free
deb-src http://ftp.debian.org/debian lenny main contrib non-free

After this execute the command:
Quote:

apt-get update

It will update Your applications repository available for Debian.

2) Running Apache Web Server:

Execute command:
Quote:

apt-get install apache2

To install Apache Web Server. When the installer asks You if You want to proceed with the installation type Y.
After installation run command:
Quote:

/etc/init.d/apache start

And then You can try to connect to Your phone on port 80 using HTTP browser and see if there's a message It works! .

3) Uploading files to Your Debian "virtual machine":

Install SSHDroid from Android Market.
Download program WinSCP and connect to Your device on port 22 using root as a user name and admin as a password.
After connection open location /data/local/mnt and You'll see Your Debian file system.

I think that's all for now.
I hope this guide will help "newbie" users to run Debian on their phones.
If You have any more questions or problems please let me know.

Regards,
Chris.
Attached Files
File Type: zip bootdeb.zip - [Click for QR Code] (1.1 KB, 272 views)
The Following 6 Users Say Thank You to krzysiek_grucha For This Useful Post: [ View ] Gift krzysiek_grucha Ad-Free
12th September 2011, 02:44 PM |#2  
kingsize623's Avatar
Senior Member
Flag genemuiden
Thanks Meter: 11
 
More
you should post this on development!
12th September 2011, 03:51 PM |#3  
Senior Member
Thanks Meter: 14
 
More
At the moment it's a little fiddling. Start phone -> connect bot -> su -> sh /sdcard/Debian/bootdeb -> from there I should be able automat anything

How can I use some kind of autostart?

Why I lose connection in ConnectBot when I disable mobile internet connection? Doesn't make sense to me. Mobile internet has nothing do do with local shell, or?

Quote:
Originally Posted by kingsize623

you should post this on development!

He should. This is GREAT!
12th September 2011, 04:12 PM |#4  
kingsize623's Avatar
Senior Member
Flag genemuiden
Thanks Meter: 11
 
More
hello,
if i typ
su
sh /sdcard/Debian/bootdeb
and then come some text
and my phone does reboot.
what am i doing wrong?
12th September 2011, 04:22 PM |#5  
Senior Member
Thanks Meter: 14
 
More
Quote:
Originally Posted by kingsize623

hello,
if i typ
su
sh /sdcard/Debian/bootdeb
and then come some text
and my phone does reboot.
what am i doing wrong?

I also had this problem. But try using ConnectBot - this is known for me to work.
12th September 2011, 04:54 PM |#6  
krzysiek_grucha's Avatar
OP Member
Flag Żywiec
Thanks Meter: 16
 
More
Quote:
Originally Posted by kingsize623

hello,
if i typ
su
sh /sdcard/Debian/bootdeb
and then come some text
and my phone does reboot.
what am i doing wrong?

Hi kingsize623!

As I said at the begining this script is highly ROM-dependent. It can run on some ROM's, but on the others there will be many problems.
I suggest You to edit file /sdcard/Debian/bootdeb in some text editor (I suggest Notepad++), locate the line:
Quote:

busybox mount -o loop,noatime $kit/debian.img $mnt

(it should be line 47), and change it to:
Quote:

mount -o loop,noatime $kit/debian.img $mnt

This should help. If it won't, there can be a lack of some module in Android on Your device which will prevent the script from running (no loop support for e.g.).
If You'll face some further problems let me know.
12th September 2011, 05:02 PM |#7  
kingsize623's Avatar
Senior Member
Flag genemuiden
Thanks Meter: 11
 
More
Quote:
Originally Posted by bagers

I also had this problem. But try using ConnectBot - this is known for me to work.

i've treid
and make a printscr

http://imageshack.us/photo/my-images...842466117.png/
http://imageshack.us/photo/my-images...842470958.png/
12th September 2011, 05:10 PM |#8  
krzysiek_grucha's Avatar
OP Member
Flag Żywiec
Thanks Meter: 16
 
More
Quote:
Originally Posted by bagers

At the moment it's a little fiddling. Start phone -> connect bot -> su -> sh /sdcard/Debian/bootdeb -> from there I should be able automat anything

How can I use some kind of autostart?

Why I lose connection in ConnectBot when I disable mobile internet connection? Doesn't make sense to me. Mobile internet has nothing do do with local shell, or?


He should. This is GREAT!

Hi bagers!

Thanks for the comments on this post !
First of all, You're right, maybe I should post it on Dev section, but I didn't use XDA-DEVELOPERS much in the past, so I was afraid I may get kicked because of such information from "newbie user" in Dev section. This section (in my understanding) is for Android guru's, and I'm not one of them .

As for the autostart: the only thing You can automate in my opinion is the part where You type:
Quote:

su
sh /sdcard/Debian/bootdeb

The only thing You need to do is to write a simple script which will look like the following:
Quote:

su
cd /sdcard/Debian/
sh bootdeb

or
Quote:

su
sh /sdcard/Debian/bootdeb

Name it for e.g. startdeb and place it in /system/bin for e.g. (I think bash will look for files in this directory by default, but I'm not sure about that).
Now, everytime when You'll try to run Debian, just open ConnectBot and type startdeb - this should automatically make You su and execute the startup script.

As for the dissconnections issue:
As far as I can see this problem exists on Floyo 0.30 as well. I'm not yet sure why it acts like that.
The Following User Says Thank You to krzysiek_grucha For This Useful Post: [ View ] Gift krzysiek_grucha Ad-Free
12th September 2011, 05:13 PM |#9  
krzysiek_grucha's Avatar
OP Member
Flag Żywiec
Thanks Meter: 16
 
More
Quote:
Originally Posted by kingsize623

i've treid
and make a printscr

http://imageshack.us/photo/my-images...842466117.png/
http://imageshack.us/photo/my-images...842470958.png/

As I wrote in previous post - try modyfying the startup script.
You also should have Busybox installed (if You don't have it download it from Market).
12th September 2011, 07:53 PM |#10  
Senior Member
Thanks Meter: 14
 
More
I installed also sshdroid and connected to the phone from Windows 7 using Putty. But, when I disconnect putty, then I will also see this "Rebooting device to ensure clean takedown.".

Ehrm, I just wanted to disconnect putty, not to shut down debian. Another bug?

Can you disable all this "Rebooting device to ensure clean takedown.", it's really disturbing.

Quote:
Originally Posted by krzysiek_grucha

As for the autostart: the only thing You can automate in my opinion is the part where You type:

The only thing You need to do is to write a simple script which will look like the following:

or

Name it for e.g. startdeb and place it in /system/bin for e.g. (I think bash will look for files in this directory by default, but I'm not sure about that).
Now, everytime when You'll try to run Debian, just open ConnectBot and type startdeb - this should automatically make You su and execute the startup script.

Okay, I done that and something really strange happened.
I made a files called "sd" in /system/bin with content:
su
sh /sdcard/Debian/bootdeb

Like you said.... But when I type sd in ConnectBot then, debian will start, and then the phone will restart...

But, when I type su and sh /sdcard/Debian/bootdeb, manually in ConnectBot, then debian will start with no error. Strange, huh? Any idea? Bug?

Quote:
Originally Posted by krzysiek_grucha

As for the dissconnections issue:
As far as I can see this problem exists on Floyo 0.30 as well. I'm not yet sure why it acts like that.

Please add it to the bug list. Maybe later someone will have an insight.
12th September 2011, 08:14 PM |#11  
krzysiek_grucha's Avatar
OP Member
Flag Żywiec
Thanks Meter: 16
 
More
Quote:
Originally Posted by bagers

I installed also sshdroid and connected to the phone from Windows 7 using Putty. But, when I disconnect putty, then I will also see this "Rebooting device to ensure clean takedown.".

Ehrm, I just wanted to disconnect putty, not to shut down debian. Another bug?

Can you disable all this "Rebooting device to ensure clean takedown.", it's really disturbing.


Okay, I done that and something really strange happened.
I made a files called "sd" in /system/bin with content:
su
sh /sdcard/Debian/bootdeb

Like you said.... But when I type sd in ConnectBot then, debian will start, and then the phone will restart...

But, when I type su and sh /sdcard/Debian/bootdeb, manually in ConnectBot, then debian will start with no error. Strange, huh? Any idea? Bug?


Please add it to the bug list. Maybe later someone will have an insight.

Hi again !

There are lots of bugs as I can see . But... If You're connecting from Putty don't be surprised that the phone is rebooting after closing Putty window. It works like that:
1)You're running the sh /sdcard/debian/bootdeb from Putty - Putty is the only terminal for the script.
2)When You dissconnect suddenly the only terminal which was preventing the bootdeb script from running wanishes so the script continues working (so it's jumping to reboot section). That's not a bug, it was written to work like that.
I don't suggest You to disable the rebooting - it helps You to have a clean unmount. If You override this, strange things may happen when You'll boot for the next time, but it is not sure for 100% - check it for Yourself .

As for the not working script file - I thought that su command won't work in the script. That's why the bootdeb script doesn't already have it included.

If You want to know about some more bugs:
Don't try to set up OpenSSH on Debian - it won't work.
Don't run FTP server like proftpd or vsftp - port 21 is forwarded correctly, but port 20 is not, and that's why FTP is not working.

There are many bugs, but if You'll follow simple rules You won't have any problem with using Debian.
The Following User Says Thank You to krzysiek_grucha For This Useful Post: [ View ] Gift krzysiek_grucha Ad-Free
Post Reply Subscribe to Thread

Tags
debian linux xperixa x8

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes