[HOWTO] openvpn on samsung galaxy i5800 - Android Software/Hacking General [Developers Only]

step by step guide how to install openvpn on the galaxy 3 i5800, android 2.1 (eclair), linux kernel 2.6.29
requirements: rooted galaxy i5800 and busybox installed in /system/xbin, adb from android sdk, phone conntect via usb, usb-debugging mode turned on
install attached tun.ko (I compiled this from the original samsung kernel sources, see opensource.samsung.com)
Code:
adb push tun.ko /sdcard/tun.ko
adb shell
su
mount -o remount,rw /dev/block/stl6 /system
cp /sdcard/tun.ko /system/xbin/
create symlinks for busybox route and ifconfig (required by openvpn)
Code:
cd /system/xbin
mkdir bb
cd bb
ln -s ../busybox ./ifconfig
ln -s ../busybox ./route
create directory for openvpn config files
Code:
mkdir /sdcard/openvpn
create symlink for cp (unix command for copy). otherwise the install-script of the OpenVPNInstaller (see below) will fail!!!
Code:
ln -s /system/xbin/busybox /system/xbin/cp
download OpenVPNInstaller from Android Market
run and configure OpenVPNInstaller
specify directories: busybox is in /system/xbin, ifconfig and route are in /system/xbin/bb
copy vpn-config files (config, certs, key) to /sdcard/openvpn (i.e. via adb push or mounting the phone as a mass-storage unit)
download OpenVPN Settings from Android Market
run and configure OpenVPN Settings
activate "load tun kernel module"
Tun module settings:
- Load module using insmod (instead of modprobe!!)
- Path to tun module: /system/xbin/tun.ko
Path to configurations:
/sdcard/openvpn
Path to openvpn binary
/system/xbin/openvpn

Excellent. Worked on my Galaxy 3 Apollo (i5800L)
Thanks!

tun.ko for galaxy s 9000 android 2.2 froyo
hi,
I also compiled the tun.ko device driver for the galaxy s 9000 running android 2.2 froyo. I took the sources from see opensource.samsung.com (GT-I9000_OpenSource_Froyo_update_JPM.zip).
have fun...
best regards sukkubus

Trying this but get an error about ifconfig failed and could not execute an external program... Anyone have any ideas?

here is a portion of the logs
Code:
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-daemon-stdout(11804): Sat Nov 13 15:12:48 2010 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 172.16.27.1,route 172.16.27.1,topology net30,ping 10,ping-restart 60,ifconfig 172.16.27.206 172.16.27.205'
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-daemon-stdout(11804): Sat Nov 13 15:12:48 2010 OPTIONS IMPORT: --ifconfig/up options modified
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-daemon-stdout(11804): Sat Nov 13 15:12:49 2010 /system/xbin/bb/ifconfig tun0 172.16.27.206 pointopoint 172.16.27.205 mtu 1500
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-daemon-stdout(11804): Sat Nov 13 15:12:49 2010 Linux ifconfig failed: couldnot execute external program
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-mgmt(11804): >FATAL:Linux ifconfig failed: could not execute external program
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-daemon-stdout(11804): Sat Nov 13 15:13:57 2010 PUSH: Received control messag
e: 'PUSH_REPLY,redirect-gateway def1,dhcp-option DNS 172.16.27.1,route 172.16.27.1,topology net30,ping 10,ping-restart 60,ifconfig 172.16.27.206 172.16.27.205'
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-daemon-stdout(11804): Sat Nov 13 15:13:57 2010 OPTIONS IMPORT: --ifconfig/up options modified
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-daemon-stdout(11804): Sat Nov 13 15:13:57 2010 /system/xbin/bb/ifconfig tun0 172.16.27.206 pointopoint 172.16.27.205 mtu 1500
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-daemon-stdout(11804): Sat Nov 13 15:13:57 2010 Linux ifconfig failed: could not execute external program
D/OpenVPN-DaemonMonitor[/sdcard/tmp/blackvpn_uk.conf]-mgmt(11804): >FATAL:Linux ifconfig failed: could not execute external program

I appear to very nearly have this working
Turns out my busybox is in /sbin and if you link from /system/xbin/bb/(ifconfig or route) directly to /sbin/busybox then the ifcong and errors are removed.
It now states I am connected to another network, however my local IP is still showing at the other end point... so close but not quite yet.
ln -s /sbin/busybox /system/xbin/bb/ifconfig
ln -s /sbin/route /system/xbin/bb/route
EDIT: FIXED..
Ok, so the link for route doesnt work at all, route add and route delete fails, however the sym link for ifconfig to /sbin/busybox does work.
So for route, I copied the entire busybox binary to /system/xbin/bb and named it route
cp /sbin/busybox /system/xbin/bb/route
that now works !! Took a reboot and some time for it all to sync up, but now connecting perfectly.
You also need to find the static openvpn binary and replace the obe the comes with the openvpn installer. Also find the correct tun file for your Android build.
But can confim it does work, so worth messing around, you will get there
BYW, this is on an Samsung Galaxy S i9000

busybox
hi adiep,
you may not use the pre-installed busybox from samsung (which is found in /sbin). It is a reduced version of busybox that does not include suitable ifconfig- and route-commands for openvpn. thus you have to install a full version of busybox... normally this is done, when you root your phone according to descriptions found in this forum.
you can alternatively install titanium backup (which installs its own busybox) and copy the "full" busybox from titanum backup to /system/xbin.
best regards,
sukkubus

cifs.ko for mounting windows (aka smb) shares
hi,
just in case someone needs this: i compiled the cifs.ko kernel module for the galaxy i5800 phone.
with this module you can mount windows network shares (aka samba, smb, cifs). for instance CifsManager (see android-store) is a suitable app/frontend for doing this (hint for galaxy i5800: switch to insmod instead of modprobe in the CifsManager-settings for the proper use of the module).
best regards,
sukkubus

sukkubus06 said:
hi,
just in case someone needs this: i compiled the cifs.ko kernel module for the galaxy i5800 phone.
with this module you can mount windows network shares (aka samba, smb, cifs). for instance CifsManager (see android-store) is a suitable app/frontend for doing this (hint for galaxy i5800: switch to insmod instead of modprobe in the CifsManager-settings for the proper use of the module).
best regards,
sukkubus
Click to expand...
Click to collapse
I've just copied cifs.ko to /system/lib and choose insmod with cifs.ko path is: /system/lib/cifs.ko
but when do the mounted share i just got the "mount:Invalid Agrument" error, Pls help!
P/S: my mount point already change to /sdcard/cifs/xxx ... do we need any chmod for specific folder or .ko module?

Done for 2.1, just make sure apply the user name and password inside each connection otherwise the "invalid argument" issue stop you there.
Do we have any update about the modules cifs.ko for FROYO 2.6.32 kernel?
TIA

will this work on the nexus one?

tun.ko and cifs.ko for android froyo (2.2.) galaxy gt i5800
kenblat said:
Done for 2.1, just make sure apply the user name and password inside each connection otherwise the "invalid argument" issue stop you there.
Do we have any update about the modules cifs.ko for FROYO 2.6.32 kernel?
TIA
Click to expand...
Click to collapse
here you go... tun.ko and cifs.ko for froyo!
best regards
sukkubus

I have a question about media streaming from a linux media shared folder to my gt-i5800
I managed to open the share through cifs.ko + cifs manager + es explorer (enabled root)!
My problem is that the player i'm using doesn't support superuser access to open the files in that share (rock player lite)
I have full access through a windows PC to that linux share with the same user/pass i'm loggin from my galaxy3...
Any ideas?

I have Galaxy 3 i5800 with Froyo 2.2 installed.
Which version should I use?

Related

extended Desire console with bash,sshd,samba,mc and more: update 09.06.10

(c) by m0narx
Moscow,Russia
Small console extension for rooted ROMs:
What you get:
- bash
- samba - complete CIFS server, discover you Desire as windows share from the box
- sshd - SSH server
- mc - Midnight Commander
- htop - process manager
- tree - directory tree
- screen
- cpulimit
- zip
- colored bash prompt /sdcard/data/root/.bashrc
and more (iftop, opkg, pppd)
!!!UPDATE 09/06/10!!!
D/L smallupdate.zip below -before setup you should have latest console.zip already installed
!add - nano editor
!fix - usbnet minor fixes
!!!UPDATE 08/06/10!!!
!fix - bash grep incorrect option bug fixed
!add - SCP enabled, still no SFTP yet...
!add - root, var and tmp are moved to EXT partition to mount during boot time(works only with app2sd)
!add - you may put your personal init scripts to /system/sd/init.d
they will be launched just the same manner as from /system/etc/init.d
!add - to autostart samba and sshd - just run "samba auto" or "sshd auto"
to turn autorun off just run "samba auto" or "sshd auto" again
!add - usbnet command (it's not necessary to connect in internet sharing mode any more), run in console:
"usbnet on" - turn on with IP: 192.168.100.1
"usbnet off" - self describing
"usbnet auto" - turn on IP and run samba & sshd
How to:
1. D/l console.zip ( 10.19 MB ) below
!!!UPDATE!!! 08/06/10
http://files.mail.ru/X44YRN
http://rapidshare.com/files/396639709/console_new.zip.html
MD5: 27636042F84D55A813C14AD1063E88B7
2. Reboot your phone in FASTBOOT connected by USB to PC
3. launch update-eng.cmd or update-rus.cmd
4. Phone will reboot in recovery - wait 'till windows will recognize it and then press any button.
5. Wait for the update to come and after that it'll reboot in normal mode
6. You're good to go
Can some one develop an APP or widget to control those daemons with current status?!
after reboot to start SSH server:
1. launch terminal from your phone (ConnectBot или BetterTerminal)
or ADB shell from PC
2. type
su
bash
sshd start
Connect phone to PC in Shared Internet mode
or
get a IP address by WIFI from your LAN
launch Putty (included in archive)
in HOST type in your IP
click open
on "Login as:" prompt enter root, and "root's password" is also root
type bash and ENTER
now you have complete console with MC and even mouse working
you may also start smbd daemon by
samba start
after that you may access you Desire by entering it's shared folders:
\\192.168.100.254(your Desire's IP)
shares can be changed in /data/etc/samba/smb.conf
normal colored ADB FIX for WINDOWS:
1. copy *.* from winupdate folder to your C:\Windows\system32\
2. open CMD and launch
ansicon -i
3. now you have colored ADB
Sounds pretty interesting
This works brilliantly - thanks. Can you confirm whether I need to run the commands each time the phone reboots. It would be nice if we could get it to start samba automatically on reboot if not. Great work, thanks.
Can you confirm whether I need to run the commands each time the phone reboots.
Click to expand...
Click to collapse
Restart your phone and find out.
If it doesn't there's a free app on the marker called 'autostarts(root)' that does exactly what is says on the tin.
manks said:
This works brilliantly - thanks. Can you confirm whether I need to run the commands each time the phone reboots. It would be nice if we could get it to start samba automatically on reboot if not. Great work, thanks.
Click to expand...
Click to collapse
for now it isnt! i wonder if we could use this autostarts app mercianary mentioned! i'll try it later today.
also i wonder if additional system services will eat more juice?!
Also other suggestions are appreciated...
do your update.cmd in fastboot usb in my win7 notebook,it tell me device not found。could you provide a zip file that I could flash in the recovery?
Same Happened to me. If You put your phone in recovery first then run it it should work.
Awesome... thanks!!! Will try it out.
Hope you can update the scripts and apply everything automatically on each boot.. will be awesome
EDIT:
Tested and everything works... Samba is OK, I can copy files... but I only get speeds like 500kb/s over wireless... should be more!
Also I can't delete files... but permissions seems fine?
Conf:
[SDCARD]
comment = Internal micro secure digital card
path = /sdcard
browseable = yes
available = yes
public = yes
writable = yes
read only = no
create mask = 0777
directory mask = 0777
create mode = 0777
guest ok = yes
guest only = yes
2ND EDIT:
Tested ssh, works fine, but how can we enable SCP/SFTP?
d3sm0nd said:
Tested and everything works... Samba is OK, I can copy files... but I only get speeds like 500kb/s over wireless... should be more!
Click to expand...
Click to collapse
How are the load averages and IO stats while the transfer is in progress?
Just tested and it's really great but it's really really slow for me when I connect via ssh or use samba.
Anyone having the same issue?
emontes said:
Just tested and it's really great but it's really really slow for me when I connect via ssh or use samba.
Anyone having the same issue?
Click to expand...
Click to collapse
yes it is slow but it works!
I cant figure how to make samba and ssh start at boot.
I downloaded autostart from market and it told me to make an executable file named autostart.sh at /data/opt/
I created file autostart.txt and put some commands in there and renamed it to autostart.sh (changed extension, not just changed name) and chmod-ed it in ssh putty (bash mc) and so on.
but it still doesnt work...
maybe kernel needs to be tweaked??
Re: extended Desire console with bash,sshd,samba,mc and more...
Do you guys use apps2sd? I think it might be slow because of it...
------------------------------------
Sent via the XDA Tapatalk App
Actually, this doesn't work at all for me, maybe because I'm using Defrost that doesn't really work with any networking app I know (Swift, quicksshd for instance)
Can't access samba / can't even start ssh
Above SCP / SFTP, I still did not work (((In the nearest future to get to work NMBD.
If you want to run SSHD automatically on boot, you must create a file "98sshd" in the folder /system/etc/init.d with the following content:
Code:
#!/system/bin/sh
/data/xbin/sshd start
If you want to run SMBD automatically on boot, you must create a file "97samba" in the folder /system/etc/init.d with the following contents:
Code:
#!/system/bin/sh
/Data/xbin/samba start
P.S. download these files to the phone can only help RECOVERY console, using "adb push"
Don't forget chmod +x on /system/etc/init.d/97samba and /system/etc/init.d/98sshd
Sorry for my english
m0narx said:
Sorry for my english
Click to expand...
Click to collapse
Wow! the developer himself finally appeared!
We'll work together to fix stuff, he'll make changes - i'll translate 'em and collect suggestions - so bad english is not a prob. desire - that's what counts! ) (i sense play on words here! )
StrongOneX said:
yes it is slow but it works!
Click to expand...
Click to collapse
Didn't say it doesn't work did I?
M0narx,
Great one, mate. Really useful one.
Keep up the good work
m0narx said:
P.S. download these files to the phone can only help RECOVERY console, using "adb push"
Don't forget chmod +x on /system/etc/init.d/97samba and /system/etc/init.d/98sshd
Click to expand...
Click to collapse
Hey M0narx,
Tried to do an auto restart but it didn't work.
Went in recovery, pushed the files to init.d, chmod`ed 777 but no joy.
Even trying with autostart from Market Place but don't know why, it doesn't autostart for me
Any hint?
Cheers.
i'm not sure whether it works or not...
chmoded to 777, samba sshd mods are 777 also.
may be it's forbidden to run from /data/xbin on boot?
i think samba does not start at boot cause there are no IP addresses during boot time.
but still sshd is running due to ps:
Code:
ps w | grep ssh
128 root 528 S /system/xbin/dropbear -A root -N root -C root -U 0 -G 0 -a -P /sdcard/data/var/run/sshd.pid -b /data/etc/
i'm not sure what does dropbear process mean either.
and also there are .pid files in /sdcard/data/var/run/ for sshd and samba with nonexistent PIDs
Code:
# sshd start
sshd start
Starting SSH server... /system/xbin/dropbear is already running
also netstat:
Code:
# netstat -na
netstat -na
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:16650 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5037 0.0.0.0:* LISTEN
tcp 0 0 :::7890 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
and ifconfig
Code:
# ifconfig
ifconfig
eth0 Link encap:Ethernet HWaddr 00:23:76:D8:94:52
inet6 addr: fe80::223:76ff:fed8:9452/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:87 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5046 (4.9 KiB) TX bytes:492 (492.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:24 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1832 (1.7 KiB) TX bytes:1832 (1.7 KiB)
EDIT:
i found out that grep in not working in bash any more complaining about unrecognized option (it's for colored grep output)
Code:
[04:23:28 /data/local]# ps w | grep sshd
/system/xbin/grep: unrecognized option `--color=auto'
BusyBox v1.16.0 (2010-01-29 22:31:34 CET) multi-call binary.
Usage: grep [-HhrilLnqvsoeFEABC] PATTERN [FILE]...
Search for PATTERN in each FILE or standard input
Options:
-H Prefix output lines with filename where match was found
-h Suppress the prefixing filename on output
-r Recurse
-i Ignore case distinctions
-l List names of files that match
-L List names of files that don't match
-n Print line number with output lines
-q Quiet. Return 0 if PATTERN is found, 1 otherwise
-v Select non-matching lines
-s Suppress file open/read error messages
-c Only print count of matching lines
-o Show only the part of a line that matches PATTERN
-m N Match up to N times per file
-F PATTERN is a set of newline-separated strings
-E PATTERN is an extended regular expression
-e PTRN Pattern to match
-f FILE Read pattern from file
-A N Print N lines of trailing context
-B N Print N lines of leading context
-C N Print N lines of output context
Can I use pubkey auth with this sshd?

A Real Linux Android System

Before reading.
This article requires that your phone is Rooted and has Busybox installed.
HTC owners, S-off your phone as well.
Android is a great operating system for SmartPhones. Only problem with it (From a more technical users point of view) is the small useless bad excuse of a linux system running behind the UI. Some of the smaller issues can be fixed by installing Busybox that provides a better basic set of tools to work with, but it's not enough. What I would like is to be able to use almost any real linux cli application, daemon, library etc. Also some compilers would be great. I'm using an HTC desire which has more than enough power to do things like compiling (I know, I have done it.), and so has a lot of other SmartPhones. Why would one need this when there is cross compilers you can use on regular and faster machines? Well, because It's fun, why else. I did not spend all that money on a SmartPhones just to make a few phone calls and write a few text messages. My old Sony Ericsson did that quite well. I spend that money to get a phone with many possibilities that I could play with.
I tried to search the web for some helping instructions on how to port a real linux system to this phone. What I mostly got, was people who ported linux systems that would run as an extra OS on the phone, some even with an Xserver accessible via VNC. Sounds fun, but not what I was after. I did not want an extra OS using CPU and unnecessary RAM. I just wanted some extra tools, libs etc to work with and the regular linux user management. I managed to find an old article from someone using Debians armel version on an old G1 phone. I thought that if it worked on that phone, it would be possible to do so on mine. So I started playing around with that.
The way this works is by installing a bare minimum debian on an second partition. This will not boot anything up since it will just work as extra tools and lib using the already booted android linux system.. You will still only have one OS but more tools (Including the nice APT package system) to work with.
Now there is two ways of using debian on android.
The first way is to setup the Debian in an chroot environment. This has some flaws like I have not yet been able to make the chroot start second jobs, which means that you will be able to start applications and daemons running in the current shell session. But you will not be able to make them run in the background. But as an development environment it will still work great, as you will be able to use the Debian libs and compilers.
The second way (The way I was after) is to setup Debian using the UAFS kernel module. This is used to merge directories into one with different rules for each. For an example you would be able to merge /debian_root/etc and /system/etc into a shared /etc with RW on Debians etc and RO on Androids forcing any changes to be made in /debian_root/etc. Using this option you will use Debian to extend the Android Linux part. Android UI with Debian Shell.
This article is split into 3 parts. The first part is the setup of Debian. Must be done whether you want chroot or a merged system. In the second part we will cover the setup of the chroot environment.
The third part is the setup of the merged system. This will require one thing in order to work.
You will need a kernel with the uafs module which is not default in most android kernels. You will need to compile your own kernel. People using the Thalamus kernel, can download a kernel with this module kernel-2.6.37.2_AUFS.zip. A big thanks to Thalamus for providing this. Note that this kernel was a special request from me that he was kind enough to provide. It comes with absolutely no guaranties. Do not email spam him about errors you might encounter using it as this is not an official release.
Note that once you mount the Debian system, you will not be able to mount the SD Card when connecting it to your PC. You can download the App “Multi Mount SD-Card” from Market which will be able to mount your SD Card on your PC while mounted on your phone. This app should also speed up transfers on 2.6.37 kernels, or so I have heard.
Part 1: Building Debian
We are going to run debian from a file containing a ext2 filesystem. If your SD Card is big enough you might be able to create an extra partition and force it to mount as something else other than ext-sd, but in this article we are going to use a partitioned file.
Also, this will require that you have the tool “debootstrap” on your PC. This is found in Ubuntu and Debian, dont know about other Linux distro's or Operating systems. If you don't use Linux or an distro with debootstrap you can download a Ubuntu Live CD from the Ubuntu website. This can be run on CD, DVD and USB disks without installing it. For this article I have used Ubuntu 10.10.
Open a terminal on your Ubuntu/Debian/LiveCD PC and cd to the folder where you want to temp. store your debian. I will call this path “debian_dir”
The first thing we will do is to create the partitioned file.
I'm creating a file with 1.5GB of space. You can create the size you want.
Don't use 0 in the size, dd don't like that.
Code:
cd debian_dir
dd if=/dev/zero of=debian.img seek=1499999999 bs=1 count=1
mke2fs -F debian.img
mkdir debian
mount -o loop debian.img debian/
Now that we have created the file and mounted it, we should download and place debian inside of it. First we will install debootstrap.
Code:
apt-get install debootstrap
debootstrap --arch armel --foreign squeeze debian http://ftp.us.debian.org/debian
umount debian/
Debian Squeeze is Debian 6.0 which replaces the old Lenny.
Copy the debian.img file to your SD Card on your phone. I placed mine in the root of the SD Card.
Now open a terminal on your phone. You can download one from market. There are some free once, but the paid “Better Terminal” is the best to work with in my opinion.
Note: All shell work is done on the phone from now on.
First we need some temp. exports.
Type the fallowing:
Code:
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
export HOME=/root
export TERM=linux
export DM=/data/local/debian
export DI=/sdcard/debian.img
Now we will create the Debian dir and then create a loop device which we will use to mount the Debian image to the Debian dir.
Code:
mkdir -d $DM
mknod /dev/loop0 b 7 0
mount -o loop,noatime $DI $DM
Now that we have debian mounted in our debian folder, we need to finalize the installation. Not all files as been installed yet. Don't forget to activate Mobile Network or Wifi.
chroot $DM /debootstrap/debootstrap –second-stage
We also need to insert the debian repository and a DNS (I use OpenDNS).
You can use whatever you want for the DNS, you routers IP for an example. It should have some default Ips configured.
Code:
echo “deb http://ftp.us.debian.org/debian squeeze main contrib non-free” > $DM/etc/apt/sources.list
echo “208.67.222.222” > $DM/etc/resolv.conf
Now change the root to the debian dir and set a root password and make sure that certain folders already exists.
Code:
chroot $DM /bin/bash
passwd root
mkdir root
exit
Now we need to make sure that certain variables exists and that the values is as they should be. So we will alter the /system/bin/sh that android uses as login shell.
Code:
cd /system/bin
mv sh sh0
Create a new /system/bin/sh file with the fallowing content.
This will ensure that these variables is created and/or changed every time you enter a new shell session. You can call another shell like bash or ash instead /system/xbin/sh, just make sure to use ash or sh at the top, since bash does not seam to understand [email protected]
Warning: It is very important that the /system/bin/sh file is made correct. Android will not boot if anything is wrong with this file. It should be exactly like the one I posted, and you cannot make it on your PC and push it to the phone. Don't know why, it works fine with other shell scripts, but not that one.
Enter an adb shell from your PC and use vi or nano (You can download nano here here) to copy and paste the content directly into the ADB Shell.
Note: ADB from the recovery will always work. It does not use /system/bin/sh
Code:
#!/system/xbin/sh
/system/xbin/sh --login [email protected]
Make sure that it has execute rights. Then type sh in the terminal to make sure that it works before you close your ADB Shell session.
Code:
chmod a+x /system/bin/sh
sh
sh0 will not be used, it's up to you wether you want to save it or not. Just make sure that /system/xbin/sh exists, otherwise
copy /system/bin/sh0 to /system/xbin/sh.
Now we need the profile file that is needed by this method. This file will make sure that we have all our variables and the data that they should contain.
Android does not keep very good track of these things. Place this data in the file /system/etc/profile
Code:
export TERM=linux
export TERMINFO=/etc/terminfo
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/vendor/bin:/system/bin:/system/xbin
if [ "$EUID" == "0" ]; then
if [ -z "$HOME" ] || [ -z "$USER" ] || [ -z "$GROUPS" ]; then
export HOME=/root
export USER=root
export GROUPS=0
fi
else
# Make sure that this user id variable exists.
if [ -z $EUID ]; then
export EUID=$(echo $(id | cut -d "(" -f 1) | cut -d "=" -f 2)
fi
# If we have an /etc/passwd file available,
# we should also make sure to get name, group and home info from that file and
# store in the default linux variables.
if [ -f /etc/passwd ]; then
# Create the user info variables based on user id and /etc/passwd
export USER=$(grep "x:${EUID}:" /etc/passwd | cut -d : -f 1)
export GROUPS=$(grep "x:${EUID}:" /etc/passwd | cut -d : -f 4)
export HOME=$(grep "x:${EUID}:" /etc/passwd | cut -d : -f 6)
fi
fi
export ADID=$EUID
if [ "$PS1" ]; then
if [ "$BASH" ]; then
# The file bash.bashrc already sets the default PS1.
if [ ! -z $HOME ] && [ -f $HOME/.bashrc ]; then
. $HOME/.bashrc
elif [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
else
export PS1='\h:\W\$ '
fi
else
if [ "$EUID" == "0" ]; then
PS1='\w # '
else
PS1='\w $ '
fi
fi
else
PS1='\h:\W\$ '
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
We will also need an /etc/bash.bashrc which is needed because /etc/profile not always gets executed.
Code:
if [ "$ADID" != "$EUID" ]; then
# Some times /etc/profile is not executed (For an example when using Androids su command).
# /etc/bash.bashrc however it used instead. So we just execute it manually in these cases.
# If you create a local bashrc ($HOME/.bashrc), remember to include this check.
# /etc/bash.bachrc is not used when a local file exists.
if [ -f /etc/profile ]; then
. /etc/profile
# Since /etc/profile links back to this file,
# we will make sure not to start an unending loop.
# the profile file should update this, but it's better to be on the safe side.
if [ "$ADID" != "$EUID" ]; then
export ADID=$EUID
fi
fi
fi
PS1='\h:\W\$ '
And last we have some user and group configurations in order to make Debian better work with Android. Open your Android terminal emulator and make sure it opens as user and not root. Now type "/system/xbin/id".
What we need here is the uid, gid and the ids of each accosiated groups along with the names of it all. In my terminal I have "uid=10048(app_48) gid=10048(app_48) groups=1015(sdcard_rw),3003(inet)".
What we will do it create this user along with the groups in our Debian inveroment. However, I use the uid name and gid name "bterm" instead of app_48, but still with the original IDs. The inet and sdcard_rw groups will be created as system groups. Do the same for your app user and group if you don't want any login possibilities with this user. I however have assigned home and password to this user.
This needs to be doen in chroot
Code:
chroot $DM /bin/bash
groupadd --system --gid 1015 sdcard_rw
groupadd --system --gid 3003 inet
groupadd --gid 10048 bterm
adduser --home /home/bterm --gid 10048 --uid 10048 bterm
gpasswd -a bterm sdcard_rw
gpasswd -a bterm inet
exit
Now your ready for the next step. Remember that the user you have created, is the user used by your terminal emulator when you are not logged on as root. This ID is only assigned to that specific app, if you install another terminal, it will get another ID.
Part 2 – Setting up a chroot environment
The best way of doing this is to make two small scripts and place them in /system/bin or /system/xbin. One script for doing the mount after phone boot. And one script for entering the chroot when open a new shell session.
Here is the mounting script that I call mkdebian.
This needs to be executed once every time the phone has rebooted. If your ROM supports init scripts, you can add it there for auto-mount on boot.
Code:
#!/system/bin/sh
export DM=/data/local/debian
export DI=/sdcard/debian.img
# Create the loop device and mount the debian image
mknod /dev/loop0 b 7 0
mount -o loop,noatime $DI $DM
# Let's make sure that we can access our sd card from within the chroot
if [ ! -d "$DM/mnt/sdcard" ]; then
mkdir $DM/mnt/sdcard
fi
mount --bind /mnt/sdcard $DM/mnt/sdcard
# Now we make sure that the chroot has access to all the device maps
if [ ! -d "$DM/dev" ]; then
mkdir $DM/dev
fi
mount --bind /dev $DM/dev
# We also need to make proc, sys etc available from within the chroot
chroot $DM mount -t proc proc /proc
chroot $DM mount -t sysfs sysfs /sys
# And last fix the mtab
chroot $DM rm -f /etc/mtab
chroot $DM ln -s /proc/mounts /etc/mtab
echo “Debian was mounted in $DM/”
Now for the script that I called “debian”.
This script will make you enter the chroot environment using one single command. Every time you exist the debian chroot, you can enter back using the command “debian”.
Code:
#!/system/bin/sh
chroot /data/local/debian/ /bin/bash
And that is it. Open a terminal, type debian and start using your debian environment. It might be a good idea to run aptitude update or apt-get update before you start using the package manager.
Part 3 – Settings up a merged Android/Debian environment
This is the fun part to play with. A merged Android/Debian environment without the usage of chroot. This only requires a script to be executed at boot, or after boot.
Remember that this will not work unless your kernel has the aufs module.
Code:
#!/system/xbin/sh
export DM=/data/local/debian
export DI=/mnt/sdcard/debian.img
# Now we mount the debian image to our debian folder.
mknod /dev/loop0 b 7 0
mount -o loop,noatime $DI $DM
# These two directories exists in both android and debian,
# so these are going to be merged together.
mount -t aufs -o dirs=$DM/etc=rw:/system/etc=ro aufs /system/etc
# For some reason, mounting /sbin with aufs does not work.
# So we make a little cheat with symbolic links instead.
mount -o remount,rw /
mv /sbin /sbin0
ln -s $DM/sbin /
rm -rf /sbin/adbd
rm -rf /sbin/ueventd
ln -s /sbin0/adbd /sbin/
ln -s /sbin0/ueventd /sbin/
# Let's get all the debian root directories out to the real root dir.
rm -rf /root
for x in tmp root lib bin boot home media opt selinux srv usr var
do
ln -s $DM/$x /
done
if [ -f /system/xbin/bash ]; then
mount --bind /bin/bash /system/xbin/bash
mount --bin /system/xbin/bash /system/xbin/sh
else
mount --bind /bin/bash /system/xbin/sh
fi
echo "Debian has been merged with Android..."
Run this at startup and start using all of debians possibilities (Don't run it yet).
The / dir is left with RW permissions. If this is set to RO then apt-get will not work. It writes tmp log files to this dir when running. It does not matter since all changes to this dir is restored to default on every boot.
Also dont forget to run apt-get update or aptitude update to update the package list.
You are now able to install and run almost anything (CLI Only) that runs on debian systems and other linux dists. Personally I'm currently running OpenSSH Server and Lighttpd with PHP. A perfect small transportable web server.
You can use either /etc/init.d/[your service] start
or
service [your service] start
to start daemons you have installed.
Now you can use the "mkdebian" command to merge your new Debian with Android.
Note: The command “su” from debian works differently than the android “su” command.
The debian command uses the regular linux management to provide access which means that it will ask for your root password that you created in the first part. The android command will just provide you with su rights without a password. Both commands provides su rights to both android and debian, so it is possible to remove the android command and create a new Android/Java based SU app for the Android UI that will require root password.
Note: There is a small problem with the Android "su" command. It does not recheck the /etc/profile.
That means that if you log on using the regular user, and then uses the "su" command, user variables does not get updated with su paths.
Using the Debian "su" command will work fine, just note that this command will promp for password. Also logging in using the root account
directly works fine.
Good luck
[Edit: 2011-03-09 11:06]
- Changed the /etc/profile script in Part 1
- Added /etc/bash.bashrc script in Part 1
- Changed User and Group setup and moved it from Part 3 to Part 1
- Fixed error in /system/bin/sh
All of this will fix some permission problems with Debian
[Edit: 2011-03-08 11:21]
- Fixed problems with user management by adding an /etc/profile and changing /system/bin/sh and the debian merge script. Using the "login" command is no longer needed.
[Edit: 2011-03-07 08:49]
- Fixed bug in Part 1 sh script.
[Edit: 2011-03-07 00:20]
- Added a new /system/bin/sh script to Part 1
- Added the way we create missing users and groups in Part 3
[Edit: 2011-03-06 19:36]
- Inserted a warning text in part 1 about avoiding problems when creating a new /system/bin/sh.
Applying Host name
If you want to set a custom hostname for your phone, you can create an init script (If your ROM supports it).
Code:
#!/system/bin/sh
# Get the hostname if it exists, or set it to localhost
if [ -f /system/etc/hostname ]; then
_HOSTNAME=$(cat /system/etc/hostname)
if [ -z $_HOSTNAME ]; then
_HOSTNAME=localhost
fi
else
_HOSTNAME=localhost
fi
# Update the Hostname
echo "$_HOSTNAME" > /proc/sys/kernel/hostname
# Update the hosts file
echo "127.0.0.1 localhost.localdomain localhost" > /etc/hosts
# If the hostname is not localhost, we add one more line to the hosts file
if [ "$_HOSTNAME" != "localhost" ]; then
echo "127.0.0.1 $_HOSTNAME" >> /etc/hosts
fi
This will look in /system/etc/ for the regular linux hostname file. If it exists, it will take the hostname from that file and set as the global hostname.
If it does not exist, "localhost" is used instead. Also it creates the /system/etc/hosts file.
Add or Edit your hostname like this.
Code:
echo "myhostname" > /system/etc/hostname
Note: Remember to delete the hosts and hostname files in your debian /etc/ dir when using merged environment. Otherwise they will overwrite the once in /system/etc/ as debian has first priority.
Manipulating the Android Permissions
Androids permissions works by providing a User ID for each application. This user (Application) can then get a range of different permissions by being added to groups with the permissions required by the app. For an example an app that needs to write to the SD Card, should be a member of Androids sdcard_rw group which translates into 1015 in a Linux group id. Using the numeric values of the Android groups, we can assign these permissions to shell users, daemons etc.
An example:
I had problems with my Http Server because I wanted my www folder on my sdcard. But, the www-data user and group could not be allowed to write to the SD Card, which I needed it to do, because Android controls what permissions the SD Card should have, not even root can change that.
What I did was creating a system group that I named sdcard_rw (Same name as the android, just to better keep track of the groups) with the same Id as the Android sdcard_rw (1015). I then assigned that group to my www-data user (gpasswd -a www-data sdcard_rw) and now my lighttpd had Read/Write access to my sdcard.
You can use the same example for creating a regular SSH User by using the Android shell group or for any other type of user that needs some Android permissions to work properly.
[Edit: 2011-03-08 21:13]
- Added an permission example
Great...
I was just looking into this myself for the last few days.
strange how there isn't more of this being talked about.
at least I have been unable to find anything.
Omg this sounds awesome,
Will try this when u get home and will report back
Sent from my Nexus One using XDA App
I'm still trying to work out some problems with User Rights on SD Card. Can't get lighttpd to be allowed to create files in my SD Card www dir (Does not matter what user and group I set it to use). I can't even get the root account to be allowed to change permissions on SD Card files and folders. It's not the biggest problem, but will report back when I figure it out.
Nice! I've been constantly disappointed for the past year at how un-Linuxy Android is under the hood and unimpressed with the old chroot tricks. This looks much better and I'll try it soon.
I have added a new /system/bin/sh script that can be found in Part 1. This script will automatically look for bash and, if that exists, try to find bash.bashrc, .profile or .bashrc in /etc or the users home dir. If bash does not exist, it looks for sh instead. If you have both one of the Android specific compiled bash, then Debians bash is used when available as this is made to work in a real linux environment. Android bash does not seam to work that way. Also debians packages gets updates via APT.
Also I changed the way groups and users is created in Part 3. Manually inserting them to /etc/passwd, /etc/shadow and /etc/group did not seam to be enough. The users and groups where only half registered. For an example the command "login" gave me a lot of errors, and i had problems with user rights. By using adduser and addgroup in a chroot before the first merge, the user management seams to work as it should now.
I was playing with Debian on my phone just a few days ago too. I've found that same G1 article you mentioned, and installed Lenny in a chroot environment. Background daemons work fine for me, I've installed OpenSSH and I'm using ConnectBot connecting to 127.0.0.1 to get a terminal, so I don't have to chroot every time. I even have X with tightvnc server + android-vnc-viewer. Running the desktop Firefox on my phone is fun Although not very useful. I'm still thinking about what awesome things we could do with this that we couldn't otherwise.
Anyway, great howto.
Do you have any details on the Thalamus kernel? What phone is it for? Overclocked, audio hack, etc? Or is it just a vanilla kernel with the extra module?
What applications can we dream up?
The first thing that springs to mind is could this be used to create a low power server running bittorrent and the like?
Would a cheap device like the Vodafone 845 be under-powered for this?
Can you connect to a usb hub to allow multiple devices to be connected to it? I'm thinking usb network adapters, external storage, etc.
How much additional effort on top of this guide would be needed?
Just curious...
will not... - -!
Well I learned one thing. Don't make Shell scripts when you are tired. I started a shell loop on phone bootup with my /system/bin/sh fix (Which had been changed). When using the merged environment, you need (for now) to enter /bin/login when you open a new shell and login as user with the password you created in Part 3. This will make Debian take over the user management which among other things will make sure that the right variables etc. exists. I have tried to locate where android controls new shell sessions, but I cant seam to find it.
When you make Debian take over, you can use your Linux shell as any other. .bashrc, .profile, /etc/bash.bashrc, /etc/profile files, change default shell (bash, sh, ash) in /etc/passwd and so on.
#9 Well the kernel is the same that is found in the Oxygen 2.0.1, so it's an gingerbread rom (2.3.3). If it works only in Oxygen, I don't know but I don't think so.
#10 He he, Could not say. For now I'm just trying to make it work as I want it to work. After that I might start playing around with different things.
The "login" command is no longer needed. I finally found a way to successfully control user variables and management, making Android and Debian work together as one when merging the two.
This is amazing. Totally going to do this later tonight when I get home.
If you merge using AUFS instead of making a chroot, you should perhaps use the system user (Id: 1000, Group: 1000) as the regular user.
There are only two static users in Android, 0 and 1000.
Android just isn't made to work as an multi-user system. This is how the Java UI is made, and we really need to Linux part to be compatible with that part of the OS. Instead of multi-users, android uses it's apps as users. Each app works as one user with different id. So the 10048 I used as regular user is just the ID of mine "Better Terminal". Switching to another terminal app changed the EUID.
Use the root and only root to work with in the shell. And then delete Debians "su" command and stick with the one from android. Debians need all users that execute "su" to be written to the /etc/passwd.
All GNU tool and library, that's Great. thanks a lot.
I have added an example of how to apply Android rules to shell users, daemons etc. Some daemons will need this in order to function.
I have added this in Thread 2 below the hostname example.
I also changed the main Thread. Found a fix for the rest of the permission problems, including the Android "su" command issue.
I have tested this Android/Debian merge using several methods (ADB, SSH, different local terminals) and it worked on most. I had one problem with one local terminal app that did not execute /etc/profile and some Debian users in /etc/passwd that didn't either.
To fix this I changed /system/bin/sh from using "/system/xbin/sh --login [email protected]" to instead use "/system/xbin/sh --rcfile /system/etc/profile [email protected]". I then moved the Debians /bin/bash to /usr/bin/bash and made a similar script file in /bin/bash > "/usr/bin/bash --rcfile /etc/profile [email protected]". You can make the same for /bin/sh if you don't like using bash for your /etc/passwd users.
Remember to change the bash bind mount in the mkdebian script from /bin/bash to /usr/bin/bash
Use whatever method works on your phone.
This looks like a ton of fun, and could be very useful. I'd like to try this on my NookColor (N2Acard, CM7.1), probably using The Guardian Project's lilDebi image as a base. They go the chroot route with their installer, and I'm going to have to do some hacking on their scripts to make them work with the NookColor. I figure if I'm going to have to hack on it, I might as well put my efforts toward a more ideal solution.
Question: It doesn't look like the CM7.1 kernel supports aufs. That is,
Code:
cat /proc/filesystems
doesn't return aufs as one of the supported filesystems.
Aside from a lack of elegance, is there any reason we can't apply your /sbin workaround to "merging" the whole filesystem? [I recognize there's a certain amount of ignorance behind the question; I figure there's only one way to cure that: Ask.]
OR, how difficult might it be to take a complete CM7.1 kernel and add aufs support to it?
'preciate any help I can get!
mailman1175 said:
This looks like a ton of fun, and could be very useful. I'd like to try this on my NookColor (N2Acard, CM7.1), probably using The Guardian Project's lilDebi image as a base. They go the chroot route with their installer, and I'm going to have to do some hacking on their scripts to make them work with the NookColor. I figure if I'm going to have to hack on it, I might as well put my efforts toward a more ideal solution.
Question: It doesn't look like the CM7.1 kernel supports aufs. That is,
Code:
cat /proc/filesystems
doesn't return aufs as one of the supported filesystems.
Aside from a lack of elegance, is there any reason we can't apply your /sbin workaround to "merging" the whole filesystem? [I recognize there's a certain amount of ignorance behind the question; I figure there's only one way to cure that: Ask.]
OR, how difficult might it be to take a complete CM7.1 kernel and add aufs support to it?
'preciate any help I can get!
Click to expand...
Click to collapse
here's where you get aufs patches.
you'll have to build the kernel yourself to make it work.
to the OP:
using the aufs mount method instead of a chroot...
I have a small problem, I don't know if it shows up with your .img filesystem method, but with an sd-ext partition used intead of the .img file, apt-get fouls massively when trying to update/upgrade libc6.
it complains about the libc6*.so existing in two places at once, and requests the existing one be removed. If it's removed, then nothing in the Linux install works, because just about everything is compiled against libc. I can use busybox to manipulate files with the libc6 removed or hidden away, but can't seem to get past the error since dpkg and apt don't work without some version of libc installed.
Any hints/suggestions? I like your scripts a lot better than the chroot ones I cobbled together from everyone else's work last year for similar purposes before I got aufs working in a kernel.

Ubuntu 10.10 Up & Running On HTC Inspire 4G

First off i wanna say i take know credit at all for this i did not write the commands and i did not figure out how to do it i found this in the Desire HD thread and figured i would share it with all the HTC Inspire 4G people. This is a very simple process and within minutes your up and running Linux Ubuntu 10.10. Below i will post all the requirements, the steps, and the commands. Enjoy guys and girls and if you need any help with this just post to the Thread. Thanks Donny
Requirements:
​*A rooted HTC Desire HD. For rooting instructions, see how to permanently root HTC Inspire 4G.
*A microSD card with 3 GB or more free space.
*Other custom kernel with LoopBack support
*Ubuntu image and required scripts
*Android Terminal Emulator app (install from the Android Market)
*Android VNC Viewer app (install from the Android Market)
*Before proceeding, move all your apps back to Internal Storage if you have moved them to SD using App2SD.
*An active internet connection on your phone (Wi-Fi is recommended).
Procedure:​
1 – Installing Ubuntu:
*Create a folder called ‘ubuntu’ on the root of your SD card.
Extract the contents of the downloaded Ubuntu.tar file and transfer them to the folder from Step 2.
*Launch Terminal Emulator and enter these commands:
su
pm setInstallLocation 1
cd sdcard/ubuntu
sh ubuntu.sh
bootubuntu
If all goes well, you should see “[email protected]:/#” now, indicating you are now running Ubuntu.
Entering Ubuntu at any time:​
*To enter Ubuntu terminal at any time from now onwards, you only have to launch Terminal Emulator, get su privileges, cd to the ubuntu directory and type ‘bootubuntu’:
su
cd sdcard/ubuntu
sh ubuntu.sh
bootubuntu
Configuring the Gnome Desktop GUI:​
*Now that you have Ubuntu 10.10 running, the next step would be enabling the Gnome Desktop GUI.
*If you aren’t already in the Ubuntu terminal, enter it using the above-mentioned instructions.
*Make sure that your phone’s internet connection is active and enter the following commands. Wait till each one finishes and enter ‘y’ (for yes) to confirm any prompt that you get:
apt-get update
apt-get install tightvncserver
cd /bin
cat >x
rm –r –f /tmp
mkdir /tmp
chmod 777 /tmp
export USER=root
export XKL_XMODMAP_DISABLE=1
vncserver –geometry 1024x800
Press Enter once more after entering the last command.
*Now you must configure your volume-down key as Ctrl in Terminal Emulator. Simply go to Menu > Preferences > Control Key and select Volume-Down key.
*Go back to the command line once done.
*Hold the Volume-Down key and press ‘d’. (This will basically enter Ctrl+D.)
Now enter these commands:
chmod 777 x
x
*This ‘x’ script basically lets you start the Gnome GUI. As this is the first time you are running this script, it will ask you to set a password for the VNC connection. Set a password of your choice.
*It will also ask you to set a password for “view-only” mode, which isn’t required so answer ‘n’ for no.
*Now launch Android VNC Viewer and create a new connection with the following settings:
*Nickname: Anything of your choice.
*Password: The password you set in Step 6.
*Address: localhost
*Port: 5901
*Color format: 24-bit color (4bpp)
*Now click ‘Connect’. In a minute or so, you should see your Ubuntu 10.10 Gnome desktop!!!
Links​
*Get the Ubuntu Files from the link below and install in Utorent
http://www.addictivetips.com/mobile/how-to-install-ubuntu-linux-on-htc-desire-hd/
Sounds funny!But I won't try it now. maybe latter...
Haha...,Up you!
Ice done this already and its definitely cool yo have and could come in useful. Its similar to having what the atrix has.
Sent from my Desire HD using XDA App
We need w7 ROM port yo inspire.
Sent from my Inspire 4G using XDA Premium App
Any phones with.the same hardware currently running it?
Sent from my Desire HD using XDA App
I've followed this guide to the letter and I can't seem to get past the "cat >x" command. I even tried it using ADB remote from my computer, I get the exact same results as when I use the terminal emu.
*Other custom kernel with LoopBack support
How do we find out if the kernel has loopback support?
Can someone get a alternate mirror for the ubuntu image and scripts? the torrent is dead.
I made a quick torrent and i'll seed a bit.
I too wonder about loopback support, how do we find out if our kernel has it (aside from checking the thread, since it didnt come up)
tried with cm7 stock kernel, didn't work
will try with lordmod hd 4.5
download the zip, extract, load torrent.
EDIT:
Okay, it worked with LORDMOD HD 4.5, may work on CM7 also, not sure,
what i did was: (taken from androlinux.com)
root explorer to sdcard/ubuntu
open the bootubuntu script
change the loop1 to loop7 (should be 3 of them to change)
save and exit
su
cd sdcard/ubuntu
sh ubuntu.sh (not sure if thats needed again, but just to be safe, i did it again)
bootubuntu
Also, gnome is nice, but why not run lxde?
sudo apt-get install lxde
etc etc: here: lol http://androlinux.com/android-ubuntu-development/how-to-install-ubuntu-on-android/
The only way to check for loop support is to check config.gz
adb shell
cp /proc/config.gz /data/config.gz
busybox gunzip /data/config.gz
grep CONFIG_BLK_DEV_LOOP /data/config
It will either say y or is not set.
If you are using terminal emulator, you will need to su before typing in the commands.
Sent from my HERO200 using XDA App
dacket84 said:
I've followed this guide to the letter and I can't seem to get past the "cat >x" command. I even tried it using ADB remote from my computer, I get the exact same results as when I use the terminal emu.
Click to expand...
Click to collapse
no space cat>x
then follow the directions.
what if it does not ask for a password i followed all of the steps and when i typed x at the end it never asked me to create a password
Is there a mirror for this file? I'm getting at the most about 10 kbps down and that is just taking forever...
Sent from my Inspire 4G using Tapatalk
Psionfenix said:
I made a quick torrent and i'll seed a bit.
I too wonder about loopback support, how do we find out if our kernel has it (aside from checking the thread, since it didnt come up)
tried with cm7 stock kernel, didn't work
will try with lordmod hd 4.5
download the zip, extract, load torrent.
EDIT:
Okay, it worked with LORDMOD HD 4.5, may work on CM7 also, not sure,
what i did was: (taken from androlinux.com)
root explorer to sdcard/ubuntu
open the bootubuntu script
change the loop1 to loop7 (should be 3 of them to change)
save and exit
su
cd sdcard/ubuntu
sh ubuntu.sh (not sure if thats needed again, but just to be safe, i did it again)
bootubuntu
Also, gnome is nice, but why not run lxde?
sudo apt-get install lxde
etc etc: here: lol http://androlinux.com/android-ubuntu-development/how-to-install-ubuntu-on-android/
Click to expand...
Click to collapse
I tried "sudo apt-get install lxde". It appears that the source files are no longer available. "apt-get update" fails also.
any screenshots?
justFaisal said:
any screenshots?
Click to expand...
Click to collapse
+1
justFaisal said:
any screenshots?
Click to expand...
Click to collapse
^^^ what he said...
The code doesn't work for Jellytime?
unCoRrUpTeD said:
The only way to check for loop support is to check config.gz
adb shell
cp /proc/config.gz /data/config.gz
busybox gunzip /data/config.gz
grep CONFIG_BLK_DEV_LOOP /data/config
It will either say y or is not set.
If you are using terminal emulator, you will need to su before typing in the commands.
Sent from my HERO200 using XDA App
Click to expand...
Click to collapse
I checked for loop and am using JellyTime 4.2 R2 from this link: http://forum.xda-developers.com/showthread.php?t=1778202
I also checked the loopback support and it said yes. I tried changing the loop in the script firl to loop7, but it never generated the file folders. As you can see I did this multiple times to no avail.
Here is the script that was Generated by CMD under ADB Shell:
Code:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\sdk\platform-tools>adb shell
# cp /proc/config.gz /data/config.gz
cp /proc/config.gz /data/config.gz
# busybox gunzip /data/config.gz
busybox gunzip /data/config.gz
# grep CONFIG_BLK_DEV_LOOP /data/config
grep CONFIG_BLK_DEV_LOOP /data/config
CONFIG_BLK_DEV_LOOP=y
# su
su
[email protected]:/ # cd /sdcard
cd /sdcard
[email protected]:/sdcard # cd ubuntu
cd ubuntu
[email protected]:/sdcard/ubuntu # sh ubuntu.sh
sh ubuntu.sh
modprobe: module 'ext2' not found
←[H←[Jmkdir failed for /data/local/mnt, File exists
←[H←[JUnable to chmod bootubuntu: Operation not permitted
←[H←[J
Ubuntu Chroot Bootloader v0.1
Ubuntu Bootloader is now installed!
This process does NOT damage Android OS!
Original Installer by Charan Singh
Modified for Ubuntu Chroot by Max Lee at AndroLinux.com ,G2Hacks.com and NexusOn
eHacks.net
To enter the Ubuntu Linux console just type 'bootubuntu'
[email protected]:/sdcard/ubuntu # bootubuntu
bootubuntu
mknod: /dev/loop1: File exists
losetup: /dev/block/loop1
mount: Device or resource busy
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
net.ipv4.ip_forward = 1
Setting /etc/resolv.conf to Google Open DNS 8.8.8.8 and 8.8.4.4
/system/bin/bootubuntu[22]: can't create /data/local/ubuntu/etc/resolv.conf: No
such file or directory
/system/bin/bootubuntu[23]: can't create /data/local/ubuntu/etc/resolv.conf: No
such file or directory
Setting localhost on /etc/hosts
/system/bin/bootubuntu[25]: can't create /data/local/ubuntu/etc/hosts: No such f
ile or directory
READY TO ROCK AND ROLL BABY!
Brought to you by NexusOneHacks.net and the open source community!
chroot: can't execute '/bin/bash': No such file or directory
Shutting down Ubuntu
failed: No such file or directory
failed: No such file or directory
failed: No such file or directory
failed: Invalid argument
losetup: /dev/block/loop1: Device or resource busy
127|[email protected]:/sdcard/ubuntu # bootubuntu
bootubuntu
mknod: /dev/loop1: File exists
losetup: /dev/block/loop1
mount: Device or resource busy
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
net.ipv4.ip_forward = 1
Setting /etc/resolv.conf to Google Open DNS 8.8.8.8 and 8.8.4.4
/system/bin/bootubuntu[22]: can't create /data/local/ubuntu/etc/resolv.conf: No
such file or directory
/system/bin/bootubuntu[23]: can't create /data/local/ubuntu/etc/resolv.conf: No
such file or directory
Setting localhost on /etc/hosts
/system/bin/bootubuntu[25]: can't create /data/local/ubuntu/etc/hosts: No such f
ile or directory
READY TO ROCK AND ROLL BABY!
Brought to you by NexusOneHacks.net and the open source community!
chroot: can't execute '/bin/bash': No such file or directory
Shutting down Ubuntu
failed: No such file or directory
failed: No such file or directory
failed: No such file or directory
failed: Invalid argument
losetup: /dev/block/loop1: Device or resource busy
A Little progress...
I was able to initialize the Ubuntu.sh by granting SU in Terminal Emulator. Now the When I go to update with apt-get update i receive error 404: url not found. This is getting frustrating.
I think I found a fix for the image file because the one that was loaded into the Ubuntu.zip had broken links for the apt-get command on the package links. Here is the link to the thread.
http://forum.xda-developers.com/showthread.php?t=1223128
After i get off of work tonight I will upload a hybrid of the two if it works.

BackTrack 5 for Android Smartphones - VERY UNSTABLE

WARNING: THIS IS NOT FOR THE FAINT OF HEART
UPDATE: My goal was to create a version of BackTrack 5 for ARM that was easy to use and install. As of this time, that IS NOT the case! The versions posted here are **probably not** going to work straight out of the box. If you know what you are doing in a Linux environment, you'll probably be able to get it working.
Because of this, the project is currently completely unsupported. You are free to dive in, but you are doing so with no support for me, and I'm not liable for any damage that might be done to your device's ROM.
I encourage you to pass this up unless you know what you are getting yourself into!
If you were referred here from the XDA-Developers.com article...
Hi there! Let's get one thing on the record here... this is *not* a native client! This is the chroot + VNC method that we'd been using to get Ubuntu running with Android for a while. The article makes it sound like that's the case, but sadly it's not. However, with the chroot + VNC method we can really run BackTrack 5 on an Android device, and it really does work. This takes some technical skills, and isn't for the non-Linux experienced user.
Requires a rooted device!
BackTrack 5 installation guides are making their way around this forum. I've tried to synthesize it all, but I've also added my own touches to help with usability and features, along with a workaround for the "ioctl LOOP_SET_FD failed" error message some people have been getting.
In theory this build is nearly universal, so if you have an Android device it should work. I've put it all in one zip file that you can download directly from my website, no hassles or wait timers.
If you are interested have a look, feel free to re-post. Credit goes to the BackTrack team and xda member anantshri (he's got skills, give him props guys), who built the base image file.
Information, download link, and installation guide at:
(SERVER OFFLINE, SEE BELOW)
If you like what you see help me out, hosting is expensive!
http://www.mattslifebytes.com/donate
(alternatively, you can show interest in the products and services featured on my website, if you know what I mean )
msullivan said:
If you don't know what BackTrack is, you probably don't want it
BackTrack is an operating system based on Ubuntu Linux that is used for security testing (aka hacking) and digital forensics. I'm a master's degree student in computer security, so I love this OS... it can do awesome things. Turn on your Wi-Fi and you can do advanced network scans and tests right from your phone, no laptop required. For me this is hella-useful.
But besides just being an OS for hacking ****, it's also fully Ubuntu-based, so you can run it like a desktop, including running Firefox and other Linux applications.
Click to expand...
Click to collapse
Well guys my server had hardware failure (lol, my luck), so here's the website's content:
msullivan said:
The Download
This installation of BackTrack 5 is available as a compressed file that will need to be extracted. I recommend downloading this using Chrome or Firefox. Internet Explorer often doesn’t play well with large HTTP downloads.
The root account’s password and the VNC server password are both set to ‘root’ by default!
Mirror 1
Part 1: http://www.mediafire.com/?1z5sbxdxv3naxp1
Part 2: http://www.mediafire.com/?0zz1vac0k59d58p
Part 3: http://www.mediafire.com/?kxpb7ug0x55ppde
Mirror 2
http://www.megaupload.com/?d=M6YCKZLR
Mirror 3 (Provided by shenshang)
http://www.shenye.co.uk/files/BackTrack5ForARM-MattsLifeBytesEditionv2.zip
Mirror 4 (Provided by brilldoctor)
http://brilldoctor.co.cc/Files/BackTrack5ForARM-MattsLifeBytesEditionv2.zip
Mirror 5 (Thanks for uploading, PIIcoding)
Part 1: https://rapidshare.com/files/3602140493/BackTrack5ForARM-MattsLifeBytesEditionv2.part1.rar
Part 2: https://rapidshare.com/files/2384880899/BackTrack5ForARM-MattsLifeBytesEditionv2.part2.rar
Part 3: https://rapidshare.com/files/3314159192/BackTrack5ForARM-MattsLifeBytesEditionv2.part3.rar
Part 4: https://rapidshare.com/files/3073073580/BackTrack5ForARM-MattsLifeBytesEditionv2.part4.rar
Part 5: https://rapidshare.com/files/2486943841/BackTrack5ForARM-MattsLifeBytesEditionv2.part5.rar
Part 6: https://rapidshare.com/files/3545372402/BackTrack5ForARM-MattsLifeBytesEditionv2.part6.rar
Part 7: https://rapidshare.com/files/2371728719/BackTrack5ForARM-MattsLifeBytesEditionv2.part7.rar
Part 8: https://rapidshare.com/files/1437974805/BackTrack5ForARM-MattsLifeBytesEditionv2.part8.rar
Part 9: https://rapidshare.com/files/1758571109/BackTrack5ForARM-MattsLifeBytesEditionv2.part9.rar
The Description
If you want to run BackTrack 5 on your Android-powered device, read on, you’re in the right place! So the big news is that BackTrack 5 runs on Android phones. We’ve been able to run Ubuntu on these devices for quite some time too, but admittedly BackTrack on a smartphone is just awesome.
Anyway, files for using BackTrack 5 on an Android phone have been running around the internet, but sadly it’s kind of a mish-mash of links saying, “go download this, then get this, to then this, blah blah blah”. Too confusing for my simple brain, so I’ve rounded it all up and posted it in one place… right here. The version posted here has everything you should need to run BackTrack 5 on your Android device. I’ve also added a lot of goodies to help with the user experience that the other offerings don’t include:
Works around the ioctl LOOP_SET_FD failed error that many people have been receiving on Galaxy S devices (and others)
Asks the user if they want a VNC session upon start-up
Starts the SSH service automatically and displays device IP on start-up
Enables the Ubuntu repositories to Aptitude, so you can do package installation
Adds vim. Really, what distribution doesn’t come with vim by default? Seriously…
Sets the screen resolution to 800×480 default (should be compatible with most smartphone devices)
SU
This requires root!
You must be able to "su" at terminal. This ability is usually provided by software for rooting your phone. To see if you have rooted your phone correctly and it's working, go to your terminal emulator and type "su" <enter>. If it is working, you'll probably get a prompt asking you if you want to allow your terminal emulator root access. Hit accept/yes. Now you'll be back in your terminal emulator. Type "whoami" <enter>. If it responds with "root" or "uid 0", then you are properly rooted.
Busybox
This requires Busybox!
I am no longer providing an installer for Busybox because of issues getting it to work universally, so instead YOU need to go get a working build and install it (I believe "Busybox Installer" will work, but not tested). If you want to know if you have Busybox and it's working, go to your terminal emulator and type "su" <enter>, then "busybox ls" <enter>. If you get a printout of all the files in your current directory, then your Busybox will likely work with BackTrack 5 just fine. If you get an error, "busybox: not found", that means you either do not have Busybox, or it is not properly installed.
WARNING FOR CyanogenMod USERS
Before doing ANYTHING, please test for ext2 support by running (as root, at terminal) --> "modprobe ext2" <enter>
If this fails probably your device lacks ext2 support and the whole thing will screw up if you try to run it! Support for ext2 in CM is being worked on.
The Installation Guide
Enable Wi-Fi and connect to a Wi-Fi access point (* not required, but BT5 cannot use your data plan for internet access)
Download the zip file, extract anywhere
After extraction you’ll have one folder “bt5″; copy this folder to the root of your phone’s SD Card
Put card back in phone and/or unplug from USB
In a terminal emulator, type “su” <enter>, “cd /sdcard/bt5″ <enter>
Now you are ready to rock and roll, so issue “sh bt” <enter> (in the future to start BT5 skip the line above and come straight to this command)
If all is well you’ll now be running BackTrack 5 on your Android device; you can SSH to it via Wi-Fi (password ‘root’), or access it from VNC if you said “Yes” to the prompt asking if you wanted a VNC session
To get a GUI for BackTrack on your smartphone’s screen, download a VNC viewer from the market (many are free), then connect to host “127.0.0.1″, port “5901″, password “root”
Enjoy, boys and girls.
The Credits
The BackTrack 5 Development Team
anantshri on xda-developers (his blog: http://blog.anantshri.info/) for creating the image file to fit FAT32 filesystems
anantshi's original thread where it all began: http://forum.xda-developers.com/showthread.php?t=1074169
Click to expand...
Click to collapse
Known Incompatibility
Voodoo lagfix kernel (possibly? reported, not confirmed)
Hi thanks for the great work, I try it on my HTC WildFire with CyanogenMod7 2.3 CFW
this what i got when try it install it from the terminal:
$ su
# id
uid=0(root) guid=0(root)
#
# cd /sdcard/bt5
# sh installbusybox
installbusybox: 14: Syntax error: end of file unexpected (expecting "fi")
#
# sh bt
bt: 36: Syntex error: end of file unexpected (expecting "then")
#
Click to expand...
Click to collapse
Which terminal emulator are you using?
Terminal emulator
Open up "installbusybox" in a text editor and axe the first two lines, then try again.
Hrm... I failed when packaging the version that got put up online (sorry). I'm fixing now, will update shortly.
ok i remove the first two lines, and i got:
# sh installbusybox
BeginningBusyBox installation...
mount: mounting /dev/block/mtdbloc faild: No such file or directory
/sdcard/busybox: No such file or directory
cd:can't cd to /data/local
installbusybox: ./busybox: permission denied
cd:can't cd to /system/xbin
: No such file or directory
installbusybox: ./busybox: permission denied
If there were no error messages given above then installation was successfull
#
Click to expand...
Click to collapse
not sure why when i try to chmod 755 busybox nothing change!
msullivan said:
Hrm... I failed when packaging the version that got put up online (sorry). I'm fixing now, will update shortly.
Click to expand...
Click to collapse
aha, ok thanks again
Awesome.
Sent from a super smooth captivate running andromeda
Old news...
Btw.. if you're having problems, migrate apps from SDCard to Internal memory.
edit: Just realized this came off kinda ****-like... So here http://forum.xda-developers.com/showpost.php?p=13924701&postcount=109
AdamOutler said:
Old news...
Click to expand...
Click to collapse
News isn't that BT5 runs on these; the news is that my builds resolve a lot of issues and makes it as simple as dropping in the files and saying go.
Fixed version now posted at the website.
http://www.mattslifebytes.com/?p=456
export PATH=/data/local/bin:$PATH
$ $su
# cd /sdcard/bt5
# sh bt
mkdir failed for /data/local/mnt, File exists
mount: No such device
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
net.ipv4.ip_forward = 1
bt: cannot create /data/local/mnt/etc/resolv.conf: directory nonexistent
bt: cannot create /data/local/mnt/etc/resolv.conf: directory nonexistent
bt: cannot create /data/local/mnt/etc/hosts: directory nonexistent
Ubuntu is configured with SSH and VNC servers that can be accessed from the IP:
eth0: No such device
chroot: can't execute '/bin/bash': No such file or directory
Shutting down BackTrack ARM
failed.
failed.
failed.
failed.
losetup: /dev/loop7: No such device or address
#
I have this error when i try
Sent from my A953 using Tapatalk
Motodoido said:
export PATH=/data/local/bin:$PATH
$ $su
# cd /sdcard/bt5
# sh bt
mkdir failed for /data/local/mnt, File exists
mount: No such device
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
net.ipv4.ip_forward = 1
bt: cannot create /data/local/mnt/etc/resolv.conf: directory nonexistent
bt: cannot create /data/local/mnt/etc/resolv.conf: directory nonexistent
bt: cannot create /data/local/mnt/etc/hosts: directory nonexistent
Ubuntu is configured with SSH and VNC servers that can be accessed from the IP:
eth0: No such device
chroot: can't execute '/bin/bash': No such file or directory
Shutting down BackTrack ARM
failed.
failed.
failed.
failed.
losetup: /dev/loop7: No such device or address
#
I have this error when i try
Sent from my A953 using Tapatalk
Click to expand...
Click to collapse
Same error here, Verizon Fascinate.
Motodoido, tripacer99: have you remembered to do the "sh installbusybox" command first?
I download the new package, and this what i got:
[[email protected] tools]$ ./adb shell
# id
uid=0(root) gid=0(root)
# cd sdcard/bt5
# ls
bt busybox installbusybox unionfs
bt5.img fsrw mountonly
# sh installbusybox
Beginning BusyBox installation...
/sdcard/busybox: No such file or directory
--install: applet not found
If there were no error messages given above then installation was successful!
# sh bt
mkdir: can't create directory '/data/local/mnt': File exists
Loop device exists
losetup: /dev/block/loop7: No such file or directory
mount: mounting /dev/block/loop7 on /data/local/mnt failed: Device or resource busy
mount: mounting devpts on /data/local/mnt/dev/pts failed: No such file or directory
mount: mounting proc on /data/local/mnt/proc failed: No such file or directory
mount: mounting sysfs on /data/local/mnt/sys failed: No such file or directory
net.ipv4.ip_forward = 1
bt: cannot create /data/local/mnt/etc/resolv.conf: directory nonexistent
bt: cannot create /data/local/mnt/etc/resolv.conf: directory nonexistent
bt: cannot create /data/local/mnt/etc/hosts: directory nonexistent
Ubuntu is configured with SSH and VNC servers that can be accessed from the IP:
eth0: ip 192.168.2.13 mask 255.255.255.0 flags [up broadcast running multicast]
chroot: can't execute '/bin/bash': No such file or directory
Shutting down BackTrack ARM
umount: can't umount /data/local/mnt/dev/pts: No such file or directory
umount: can't umount /data/local/mnt/proc: No such file or directory
umount: can't umount /data/local/mnt/sys: No such file or directory
umount: can't umount /data/local/mnt: Invalid argument
losetup: /dev/loop7: Device or resource busy
#
Click to expand...
Click to collapse
Hrm yet another small error in one of the scripts. So sorry :S (this script is from the BT5 team though, so I take no fault in it not working, lol).
Open "installbusybox" in a text editor and replace the text "cat /sdcard/busybox" with "cat /sdcard/bt5/busybox" it should work. I'll fix it and put it up online once I'm home from work today.
msullivan said:
Hrm yet another small error in one of the scripts. So sorry :S (this script is from the BT5 team though, so I take no fault in it not working, lol).
Open "installbusybox" in a text editor and replace the text "cat /sdcard/busybox" with "cat /sdcard/bt5/busybox" it should work. I'll fix it and put it up online once I'm home from work today.
Click to expand...
Click to collapse
thanks for your time and for your help
now i got:
# sh installbusybox
Beginning BusyBox installation...
[1] Illegal instruction ./busybox cp /da...
--install: applet not found
If there were no error messages given above then installation was successful!
#
# cat installbusybox
perm=$(id|cut -b 5)
if [ "$perm" != "0" ];then echo "This script requires root! Type: su"; exit; fi
echo "Beginning BusyBox installation..."
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
cat /sdcard/bt5/busybox > /data/local/busybox
chmod 755 /data/local/busybox
#/data/local/busybox mkdir /system/xbin
cd /data/local
./busybox cp /data/local/busybox /system/xbin
cd /system/xbin
chmod 755 busybox
./busybox --install -s /system/xbin
rm /data/local/busybox
echo "If there were no error messages given above then installation was successful!"
# ls /data/local/busybox
ls: /data/local/busybox: No such file or directory
#
Click to expand...
Click to collapse
Dr_Death said:
thanks for your time and for your help
now i got:
Click to expand...
Click to collapse
I'll have to play when I get home... at the moment I don't have an answer :-/
Link is offline....

Debshell bash error on HTC Gratia with latest CM7

As it is my first message, I have permissions only to post messages here.
I want to run Backtrack 5 on my Gratia. I installed Debdroid as written at gitbrew's website[/url]
I use oririnal BT image from this website.
I renamed btandr35.img to debian.img to make no changes to .conf file.
After "mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system", "export ...", "su", "bash" I've got this error
localhost / # debshell bash
/system/bin/debshell: line 17: /data/local/debian/etc/hostname: No such file or directory
Opening debdroid chroot on loop255
chroot: can't execute 'bash' No such file or directory
Exiting debdroid chroot - System is still running
localhost / #
Anybody knows solution?
Syavick said:
As it is my first message, I have permissions only to post messages here.
I want to run Backtrack 5 on my Gratia. I installed Debdroid as written at gitbrew's website[/url]
I use oririnal BT image from this website.
I renamed btandr35.img to debian.img to make no changes to .conf file.
After "mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system", "export ...", "su", "bash" I've got this error
localhost / # debshell bash
/system/bin/debshell: line 17: /data/local/debian/etc/hostname: No such file or directory
Opening debdroid chroot on loop255
chroot: can't execute 'bash' No such file or directory
Exiting debdroid chroot - System is still running
localhost / #
Anybody knows solution?
Click to expand...
Click to collapse
I have the exact same problem as you, I am running the Droid 2 CM 7 Nightly build (latest). I have bash, etc. Bash exists in two places: /system/xbin and /etc/bash, but even using the command (after you are in bash) "chroot /data/local/debian /system/xbin/bash" (chroot command goes: "chroot directory [FILE ARGS]") and still got the same exact error: chroot: can't execute 'bash': No such file or directory.
I have used two different GB roms (leaked motorola stock and CM 7). I must have spent over a hundred hours this week looking for and testing out possible solutions, to no avail.
What are we missing?
/system/bin/debshell: line 17: /data/local/debian/etc/hostname: No such file or directory
I fixed this error by creating empty file "hostname" in "etc" directory. But I still have chroot error. I made some experiments with copying bash to different folders - no results.
Yeah that part of the problem was an easy fix, and even though I can use the bash command wherever I am in my filesystem as well as when I am using bash, it seems that chroot cannot find the bash command. Trouble is, I can't find chroot, and I would assume that chroot would be in the same directories as bash. Even using the command ls /*/chroot gives me nothing.
Nothing works as before!

Categories

Resources