Is there an application to mount remote filesystems? - G1 Android Development

Is there any applcation that can mount on sdcard a remote fs like nfs, cifs and smbfs?
I know that there is a way with some commands to mount cifs and it worked for me but I am looking for an esier way to do that.

Do you have debian installed?
Code:
modprobe fuse
chroot into debian or however you do it
Decide which one you want...I like sshfs
Code:
apt-get install sshfs
Be root or make sure your user is part of the fuse group
Code:
usermod -a -G fuse <username>
Mount the remote filesystem...can also do mount -t sshfs, etc
Code:
sshfs [email protected]:/path/to/dir /path/to/mountpoint
Unmount it when you're done
Code:
fusermount -u /path/to/mountpoint
As you can imagine, a lot can be done with this. I was lamenting the lack of a remote share option yesterday and was really surprised to see the fuse module already compiled for this kernel. JF1.41 by the way, just in case the standard kernel doesn't have it

Ooh...actually I just reread your post. No, probably not. You could make a bash script and then compile a simple application to run it for you, I guess.

thanks for you answer anyway its nice to know another way to that.
I think that I should write a bash script and find how to run it...

Related

[HOWTO] Running debian via chroot on OO

This tutorial is based on this one for G1: http://www.saurik.com/id/10
Hi,
I'll show you how to run debian in chroot on our optimus one. It wont affect android in any way, and they can run simultaneously, side by side. You are only running bash from debian, not its kernel or any other low-level part. But you can use debian's programs.
Requirements
* Linux on your pc or in virtual machine
You need debootstrap to make debian image, so you need debian distro (maybe in *buntu it is too, but I am not sure). You dont need GUI, bash is all you need.
* Busybox(-> rooted phone)
Most custom roms comes with busybox, I am not sure how about store ROM.
* Terminal emulator on phone and/or ADB
I suggest you to make sure you have adb, because you dont wanna write it all on small touch keyboard.
Some knowledge about linux systems
If you are following this tutorial only because you want to /flex on your friends and you dont know anything about linux, then you really _should_ stop reading this tutorial.
I also recommend you to have a2sd, so we can put debian image on its partition, when it is on sdcard main partition, it _may_ cause some problems with usb mass storage.
So, lets start.
1. Getting debian image
Boot into debian and get bootstrap tool:
Code:
apt-get install debootstrap
Now, create an empty disk image, I'd say minimum size is about 150mb, but I recommend you use more:
Code:
dd if=/dev/zero of=debian.img seek=*size_in_bytes* bs=1 count=1
You need to create ext filesystem in image with this tool(you can try it with "sudo" if you have problems):
Code:
mke2fs -F debian.img
Image is ready now, now lets mount it so we can install debian into it:
Code:
mkdir debian
mount -o loop debian.img debian
Debootstrap tool will do all the work for us. You can try to use squeeze instead of lenny or download it from your country's mirror. "--variant=minbase" argument will install just base system with apt-get and only few other packages. (This also may need sudo)
Code:
debootstrap --verbose --arch armel --foreign lenny debian http://ftp.cz.debian.org/debian
umount debian
2. Mount the image
Now, we will use ADB shell to mount the image and finish debian installation. Do not forget to write "su" before you start, we need root for this.
You need to decide where to put debian.img. I suggest you to put it on a2sd partition, which is system/sd, so :
Code:
cp /sdcard/debian.img /system/sd
export kit=/system/sd
Our mount point will be /data/local/mnt, so lets make some variable to make it easier:
Code:
export mnt=/data/local/mnt
busybox mkdir -p $mnt
We also need to set these enviroment variables, and we can also make alias for busybox so we dont have to write busybox all the time.
Code:
export PATH=/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
alias _=busybox
Now we need to create loop device for image:
Code:
_ mknod /dev/loop0 b 7 0
And if nothing went wrong, you should be able to mount image now ("mount: no /etc/mtab" is normal) :
Code:
_ mount -o loop,noatime $kit/debian.img $mnt
3. Finalizing installation of debian
With mounted image, we can proceed to second stage of debian bootstrap:
Code:
_ chroot $mnt /debootstrap/debootstrap --second-stage
If you want install some packages with apt-get, you also need to add repo to sources.list. Of course, if you downloaded squeeze instead of lenny, you need to change "lenny" to "squeeze"
Code:
echo 'deb http://ftp.cz.debian.org/debian lenny main' >$mnt/etc/apt/sources.list
Set correct DNS servers - debian can't take them from Android.
Code:
echo 'nameserver 4.2.2.2' >$mnt/etc/resolv.conf
Done, installation over.
4. Running debian bash
To get to debian bash, use this command. You can try "cat /etc/issue.net" or "uname -a" so you can see its really debian.
Code:
_ chroot $mnt /bin/bash
But its not all yet, you need to mount some things for debian:
Code:
mount -t devpts devpts /dev/pts
mount -t proc proc /proc
mount -t sysfs sysfs /sys
Now link mtab to /proc/mounts. You need to do this only once.
Code:
rm -f /etc/mtab
ln -s /proc/mounts /etc/mtab
And if you want to use ssh server to log in into debian, you also should set root pass:
Code:
passwd root
5. Installing packages
First, you need to update packages list:
Code:
apt-get update
and now you can install whatever you want with "apt-get install"!
6. Finishing
I suggest you to write some .sh script so you can mount it all with one command, for example something like this: http://pastebin.com/VT6272d5
What packages have you tested?
sshd - works great, you can connect to phone via putty or ssh
mc - works, but phone screen is to small
gcc-avr - if you are programming for avr microcontrollers, you can compile it on your phone
netcat - telnet connection
git-core - works great
htop - you can see this on screnshot below
apache2 - works like a charm
xfce4, Xorg server and tightvncserver - working but slow, see screenshots
gnash - working but slow, see screenshots. This is the only option how to run flash content on optimus one xD
Iceweasel - if you are using vnc server, you can browse web pages
gcc, g++, autoreconf, cmake and whatever else is needed to build mangos - working
mysql-server - you have to set "user = root" in /etc/mysql/my.conf, but works
MaNGOS - http://getmangos.com/ takes long to build, but works! See this post and also this one.
..and maybe some more which I dont remember.
Hope this tutorial helped you
I'll try bootstrapping debian when I figure out what the hell is wrong with my system. I can't download files from ftp (but I can with wget and other progs. just not with pacman, debootstrap, and the like).
debian on optimus v
searched around to avoid multiple posts, and found this.
I've been running chroot debian on my V as well, squeeze then sid now going back to squeeze.
the main problem I've encountered was in the "debootstrap --second-stage", which generally froze at "I: configuring sysvinit". I thought that was from overloading the CPU, but turns out android init doesn't create /dev/initctl like debian does, so debootstrap hangs waiting for a response reading/writing /dev/initctl
I didn't have that issue using SL4A's shell instead of android terminal.
being a bit of a 'noid, I have used "mknod /dev/initctl p" in the chroot before running "debootstrap --second-stage" since reading of that solution. not sure if it's making much difference, because that didn't fix the issue before I found SL4A and was still using android terminal for shell functions.
I like xfce4 as a window manager in the VNC, it's small but still functional.
I did a bit of things different than saurik, but used his guide extensively, along with much googling for other deb->droid ports.
my chroot runs in the android root directory with bind-mounts since the custom kernel I like doesn't include unionfs. I also directly use an ext4 2nd partition on the SD rather than a loop-mounted filesystem image. (yes, ext4 journals will eventually frag my SD but the cost of another is worth the crash-resistance to me.)
my short-term goal is to mix inits between the two os's and run X through an android app frontend to avoid the framebuffer copy lag from the VNC. my 3 main reasons for debian on the phone are program development (works currently,) flash (actually gnash, and needs a working full-speed access to framebuffer, not working yet,) and emulators for J2ME and MAME (same boat as flash.)
so far trying to run X directly blanks my screen and forces a battery pull to get it back, so kinda giving up that route for the moment.
so installing Archlinux on O1 must be possible? how?
pymebrahimi said:
so installing Archlinux on O1 must be possible? how?
Click to expand...
Click to collapse
All must work, as long as they support running on ARM. AFAIK Arch doesn't have an (official) ARM port. You can try Arch Mobile though
This command fails me
Code:
_ mount -o loop,noatime $kit/debian.img $mnt
The error I get is no device or file exists.
Tried creating more number of loop devises too. Still it didn't work. I am using cyanogemmod 2.3.3 ROM.
onehomelist said:
This command fails me
Code:
_ mount -o loop,noatime $kit/debian.img $mnt
The error I get is no device or file exists.
Tried creating more number of loop devises too. Still it didn't work. I am using cyanogemmod 2.3.3 ROM.
Click to expand...
Click to collapse
What is the exact wording of the error?
The exact error that I get:
Code:
# busybox mknod /dev/loop0 b 7 0
# busybox mount -o loop,noatime $kit/debian.img $mnt
mount: can't setup loop device: No such file or directory
Instead of using $kit/debian.img, try manually pointing to the debian image.
For example, if you have it on the sdcard's debian folder:
Code:
/sdcard/debian/debian.img
That too didn't work.
make sure that debian image is where it should be. Also try to "ls /dev/" and look for loop0 - i had some problems with loop devices on mik's 2.3, but I did not really solved it, because I went back to froyo after while.
The loop0 device exists is /dev. As you have experienced same issue on the same ROM, I am convinced that its a ROM issue.
I just tried to install xorg, xfce4 & tightvncserver - everything work just fine, although its kinda slow
ext partition instead of loop filesystem
Tasssadar said:
I just tried to install xorg, xfce4 & tightvncserver - everything work just fine, although its kinda slow
Click to expand...
Click to collapse
I think it runs faster from a sdcard partition than a loop filesystem, if I remember right. I tested a loop-mounted preconstructed debian img from some tutorial for another device before debootstrapping my own.
partition your card with a second partition, ext2 if you're worried about journalling wearing out your sd, or ext4 if you're more worried about corrupting your precious debian filesystem in a crash or unclean umount. gparted in ubuntu seemed to work well for me.
resize your ntfs partition instead of deleting it or android may complain.
with your debian img mounted as a loop filesystem on a linux box at the same time as your new partition, you can copy everything from the img to the ext partition by:
Code:
cp -av /path/to/loopmountedimg/* /path/to/extpartition
if you replace the loop-mounting code in your boot script with a vold mount of your ext partition, android is supposed to umount the partition cleanly on powerdown or reboot.
on my optimus v, the mount looks like the following in my boot script (I'm posting the comments too for info)
# mount 2nd sdcard partition from vold, should prevent dirty unmount at reboot
# if your linux is on a different partition than 2, substitute that number for the 2 in .../vold/179:2 below
# first unmount it; if not already mounted, system will echo 'umount: can't forcibly umount /dev/block/vold/179:2: Invalid argument' but this isn't an error to worry about
Code:
umount -l /dev/block/vold/179:2
mount -o noatime,exec,suid /dev/block/vold/179:2 /$mnt
maybe someone here can use this info.
also, for anyone who wants to save some hours and bandwidth, I have a basic squeeze debootstrap uploaded to 4shared.
it shouldn't be missing any of the readme's or licensing docs, so it should be GPL ok AFAIK.
resolv.conf and sources.list are already configured for 3g access and the main Debian repository, so it's pretty much plug-n-play.
no extra packages. you'll need to apt-get tightvncserver and a window manager unless you just want the bash shell.
the first time you chroot in, you should use passwd to set a root password, and adduser to get a non-root account on there.
the only glitch is that I accidentally tar'd it into a compressed folder; so you can't just untar it into the ext partition, it needs unpacked with an archive manager. sorry!
here is the filesystem image
uncompressed, 9645 items, totalling 264.3 MB
compressed, 116.3 MB (121929580 Bytes)
Tried to put it on ext2 partition without image, its a bit faster but still very slow.
But i took some screenshots this time. You can see flash (well, gnash) player on optimus one working on last screenshot
And I have one question: is debian using its own libc or android's bionic?
Tasssadar said:
Tried to put it on ext2 partition without image, its a bit faster but still very slow.
Click to expand...
Click to collapse
guess I'm biased, first linux I used was on a 100MHz pentium 1, so this handheld flies by comparison.
But i took some screenshots this time. You can see flash (well, gnash) player on optimus one working on last screenshot
Click to expand...
Click to collapse
I could only get gnash to play ads. boo. froze up iceweasel every time I tried to open a flash video. what browser are you using? oh, man, it's iceweasel, isn't it?? also, chromium just refused to start on my optimus.
And I have one question: is debian using its own libc or android's bionic?
Click to expand...
Click to collapse
pretty sure it's standard debian libc. you could integrate the android toolchain if you were so motivated, probably.
bigsupersquid said:
I could only get gnash to play ads. boo. froze up iceweasel every time I tried to open a flash video. what browser are you using? oh, man, it's iceweasel, isn't it?? also, chromium just refused to start on my optimus.
Click to expand...
Click to collapse
Chromium does not work for me, too.
Well, it froze for me too, but after while it at least got to show what you see on the screenshot
bigsupersquid said:
pretty sure it's standard debian libc. you could integrate the android toolchain if you were so motivated, probably.
Click to expand...
Click to collapse
I was just thinking if this is possible, then normal android aplication could have libc included, if its needed.
Do you know MaNGOS? It is open-source server for World of Warcraft (for more info go to http://getmangos.com/). I just compiled it and I run it on my optimus one. And guess what - without world db, its really fast! I am extracting UDB to database right now, I will post some screenshots and results with full-featured db soon.
And thats why I love linux and android
I got no words to describe my eyes when reading that at the moment.
So, what you might wanna know if you wanna try it too:
All packages needed for mangos to compile are working good, except for mysql server: you need to set "user = root" in my.cnf - it is located in /etc/mysql/ - because you cant put any root rights to any other user than root, so mysql user cant create tcp socket.
You will most likely need swap file - optimus has plenty of RAM, but yet not enough. All you need is to compile kernel with CONFIG_SWAP=y and follow this tutorial: http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/. 512mb swap is enough. Just for the record, swap is working on optimus one, I think nobody tried it here yet.
Now as for the compilation of mangos, it is mostly working as it is, only problems are intel tbb library and g3dlite library.
TBB is not available for arm yet, so you need to compile without it. Use -DUSE_STD_MALLOC=0 in cmake line.
As for the g3dlite, things are little bit more tricky - you need it, and there are some asm() instructions in it, which are different for arm. I only commented them, because I dont know assembler: https://github.com/Tasssadar/mangos-arm/commit/67c442fa0c10e82b282b83a8fe485588f8786e12
I have no idea how it can even work without all that code in g3dlite, but it just does.
You can use scriptdev2 from its git, theres no problem in it.
Thats all, after that just "make" and get something good to read, because it will take really long. At least 5 hours for compilation and nearly hour and a half for linking of scriptdev2 and mangosd binary.
Creating of databases is just like on normal pc, so I just skip it...same goes for dbc files, maps and vmaps.
Loading of mangos takes around 4 minutes with full-featured db. mangos then takes around 180mb of ram and cpu usage is...surprisingly low, considering the fact that our cpu does not have hw float operations. I tried to clear Azjol Nerub instance (well, solo with gm character) and maximal cpu usage was 60%, when fighting a boss with lots of spawns. I could imagine some 5-man dungeon run would be just fine
Also, you will get slight lag when moving into new location, when phone loads map files from sdcard.
Thats all, see screenshots

Experiments with GB Kernel

I'm opening this thread to share information about experiments with the new GB kernel with other devs/contributors of M2 community.
Based on the idea of dual-booting I managed today to get my phone running using system directly from an image on /data.
The base system installed is boot/devtree/recovery from signed GB Leak with Mostly Blurless ROM. I created an image from this same system with dd if=/dev/block/system of=/data/blurless.img.
I then edited bootmenu 2nd-int init.rc to:
- comment lines that mount /data and /system
- added the following lines:
Code:
mount ext3 [email protected] /data nosuid nodev noatime nodiratime barrier=0
mount ext3 [email protected]/data/blurless.img /system noatime nodiratime barrier=1
In init.mapphone_umts.rc:
- commented lines that remounts /system
- added following line:
Code:
mount ext3 [email protected]/data/blurless-system.img /system ro noatime nodiratime remount
In /system/bootmenu/scripts/2nd-init.sh:
Code:
#!/sbin/sh
######## BootMenu Script v0.8.6
######## Execute [2nd-init] Menu
export PATH=/sbin:/system/xbin:/system/bin
######## Main Script
rm /*.rc
cp -r -f /system/bootmenu/2nd-init/* /
cp -fp /system/bootmenu/binary/2nd-init /sbin/
chmod 755 /*.rc
#chmod 755 /system/bootmenu/binary/2nd-init
chmod 755 /sbin/2nd-init
umount /acct
umount /mnt/asec
umount /dev/cpuctl
umount /dev/pts
umount /mnt/obb
## sbin cleanup
## move post_bootmenu.sh
#/system/bootmenu/binary/2nd-init
umount -l /system
/sbin/2nd-init
exit
Works fine and system is really mounted on loopback device after boot. Now I want to mount on init.rc /data as a bind fs. Does anyone know how to do that as a init.rc script command?
As a test I tried
mount ext3 [email protected]/data/system /mnt/data
but it didn't work
Ok. I found a way to do that mounting data first as /mnt/data then mounting loopback system. with system ready I can mount bind /data with the following command:
exec /system/xbin/busybox mount -obind /mnt/data/rom/blurless-data /data
I'd like better to mount this with a native init command if anybody knows how to, but for the moment this will do.
It doesn't work because bind is not supported by the original mount command ?
Anyway, may be you can do symlink with the data directory .
But good job allowing us to test img system without breaking existing one !
Trying now to boot MIUI on a second system image I get the following error:
08-26 21:06:40.773 2971 2979 E FramebufferNativeWindow: couldn't open framebuffer HAL (No such device)
I'm not sure if this error was caused by kernel incompatibility or by some special file libsurfaceflinger could not find. Doing strings | grep on libsurfaceflinger.so from miui I could find this references:
/dev/tty0
/sys/android_power/wait_for_fb_sleep
/sys/android_power/wait_for_fb_wake
/sys/class/graphics/fbcon
/sys/power/wait_for_fb_sleep
/sys/power/wait_for_fb_wake
Maybe we can map old devices to new devices (ln -s) at run time and make it work but I don't know exactly how to map them.
Edit: I am unable to create anything in /sys, even mounting it as RW. Does n1 know what I should do?
Yeah! You rule!
r2beta0 said:
Trying now to boot MIUI on a second system image I get the following error:
08-26 21:06:40.773 2971 2979 E FramebufferNativeWindow: couldn't open framebuffer HAL (No such device)
I'm not sure if this error was caused by kernel incompatibility or by some special file libsurfaceflinger could not find. Doing strings | grep on libsurfaceflinger.so from miui I could find this references:
/dev/tty0
/sys/android_power/wait_for_fb_sleep
/sys/android_power/wait_for_fb_wake
/sys/class/graphics/fbcon
/sys/power/wait_for_fb_sleep
/sys/power/wait_for_fb_wake
Maybe we can map old devices to new devices (ln -s) at run time and make it work but I don't know exactly how to map them.
Edit: I am unable to create anything in /sys, even mounting it as RW. Does n1 know what I should do?
Click to expand...
Click to collapse
Ok. for your system find all it needs, you have to "bind" (by anyway i think) /proc and /sys . Like a normal linux when you do a chroot. I don't know the exact order of execution of your script, but before anything else, you must have proper /proc , /sys ,/dev . For example, here it what we need in to do in linux,
#!/bin/bash
mount --bind /dev /répertoire-vers-votre-chroot/dev
mount --bind /dev/pts /répertoire-vers-votre-chroot/dev/pts
mount --bind /dev/shm /répertoire-vers-votre-chroot/dev/shm
mount -t proc none /répertoire-vers-votre-chroot/proc
mount -t sysfs none /répertoire-vers-votre-chroot/sys
As you can't bind them with mount, try the symlink , it might work (i dont see why not) . These directories are created by the kernel , maybe there are other in android , i don't know.
Try that and let me know , it should do the trick !
Edit: i read too fast! It couldnt be that, as you dont change / .
r2beta0 said:
Trying now to boot MIUI on a second system image I get the following error:
08-26 21:06:40.773 2971 2979 E FramebufferNativeWindow: couldn't open framebuffer HAL (No such device)
I'm not sure if this error was caused by kernel incompatibility or by some special file libsurfaceflinger could not find. Doing strings | grep on libsurfaceflinger.so from miui I could find this references:
/dev/tty0
/sys/android_power/wait_for_fb_sleep
/sys/android_power/wait_for_fb_wake
/sys/class/graphics/fbcon
/sys/power/wait_for_fb_sleep
/sys/power/wait_for_fb_wake
Maybe we can map old devices to new devices (ln -s) at run time and make it work but I don't know exactly how to map them.
Edit: I am unable to create anything in /sys, even mounting it as RW. Does n1 know what I should do?
Click to expand...
Click to collapse
Isn't MIUI and CM7 running on top of froyo kernel/dev tree?
I remember I got the same HAL issue when I tried to run unsigned GB on froyo kernel. I assume trying to run froyo based rom's on 2.3.4 kernel will show the same issues.
n3ptun3 said:
Isn't MIUI and CM7 running on top of froyo kernel/dev tree?
I remember I got the same HAL issue when I tried to run unsigned GB on froyo kernel. I assume trying to run froyo based rom's on 2.3.4 kernel will show the same issues.
Click to expand...
Click to collapse
Hm... maybe you're right. The new nightly CM from Defy should work with GB kernel I think.
Sent from my Milestone 2 XDA App
dangpzanco said:
Hm... maybe you're right. The new nightly CM from Defy should work with GB kernel I think.
Sent from my Milestone 2 XDA App
Click to expand...
Click to collapse
I wouldn't bet on it. 2nd-init might be GB ready, but Defy's CM7 is still built over a froyo base. If I have time this weekend I'll experiment on D2G CM7 with GB base.
Just let GB kernel boot CM7. ch-2.2 kernel suck in touch screen.
n3ptun3 said:
I wouldn't bet on it. 2nd-init might be GB ready, but Defy's CM7 is still built over a froyo base. If I have time this weekend I'll experiment on D2G CM7 with GB base.
Click to expand...
Click to collapse
I can't boot CM7 0826 nightly bulid with both ch-2.2.2/GB kernels. Anyone know why? The author has changed the 2nd-init?
Edit: I think I know why. The author delete 2nd-init in /binary. So we need to change the boot method to 2nd-boot. GB kernel isn't suported yet.
Endless7 said:
Edit: I think I know why. The author delete 2nd-init in /binary. So we need to change the boot method to 2nd-boot. GB kernel isn't suported yet.
Click to expand...
Click to collapse
That seems to be a mistake and was fixed in 3e3c820adecf812e3dfea872a184f5f428fd4fbc (Allow 2nd-init support with bootmenu, which is stored in system image). It was caused by heavy restructuring of the motorola common boot-code in the CM7 repository. Just copy my 2nd-init into the binary directory, and you should be fine.
pat972 said:
Ok. for your system find all it needs, you have to "bind" (by anyway i think) /proc and /sys . Like a normal linux when you do a chroot. I don't know the exact order of execution of your script, but before anything else, you must have proper /proc , /sys ,/dev . For example, here it what we need in to do in linux,
#!/bin/bash
mount --bind /dev /répertoire-vers-votre-chroot/dev
mount --bind /dev/pts /répertoire-vers-votre-chroot/dev/pts
mount --bind /dev/shm /répertoire-vers-votre-chroot/dev/shm
mount -t proc none /répertoire-vers-votre-chroot/proc
mount -t sysfs none /répertoire-vers-votre-chroot/sys
As you can't bind them with mount, try the symlink , it might work (i dont see why not) . These directories are created by the kernel , maybe there are other in android , i don't know.
Try that and let me know , it should do the trick !
Edit: i read too fast! It couldnt be that, as you dont change / .
Click to expand...
Click to collapse
It's a good idea, as I can bind filesystems using busybox mount. It needs just some engineering into 2nd-init script like copying busybox to /sbin and forcing umount of /dev /proc and /sys, but it can be done.
How do I clone /sys to some other folder like /data/sys? I tried with 'cp -a' but it doesn't work fine. As I see I have to clone /sys and make some symlinks on this clone. Then I bind it with original /sys on init.rc. Is that right?
r2beta0 said:
It's a good idea, as I can bind filesystems using busybox mount. It needs just some engineering into 2nd-init script like copying busybox to /sbin and forcing umount of /dev /proc and /sys, but it can be done.
How do I clone /sys to some other folder like /data/sys? I tried with 'cp -a' but it doesn't work fine. As I see I have to clone /sys and make some symlinks on this clone. Then I bind it with original /sys on init.rc. Is that right?
Click to expand...
Click to collapse
I would not unmount /dev /proc and /sys, they are closely related to kernel init, in linux desktop it the first thing rc.sysinit does.
I was thinking more to something like "ln -s /sys/ /data/sys" , and one other solution i've just tested, is to do a "mount -n -t sysfs sys /data/sys -o nosuid,noexec,nodev" ! The difference for me is that with the mount command you'll not be able to umount /data/sys until reboot ! With the symlink you can just rm it when you finish.
The bind option is usefull cause when you do a chroot, you don't have access the other part of the system , so i'm not sure the symlink method work in that case. i'll ask and tell you.
Edit : I confirm It's that well about bind and chroot. and it seems to me , you can't create file in /sys , the kernel create them and you can read/change values. If you create one, it will not be taken in account by the kernel.
Also can you light up my lantern, which script in /system is called after the 2nd-init to launch the MIUI ?
pat972 said:
I would not unmount /dev /proc and /sys, they are closely related to kernel init, in linux desktop it the first thing rc.sysinit does.
I was thinking more to something like "ln -s /sys/ /data/sys" , and one other solution i've just tested, is to do a "mount -n -t sysfs sys /data/sys -o nosuid,noexec,nodev" ! The difference for me is that with the mount command you'll not be able to umount /data/sys until reboot ! With the symlink you can just rm it when you finish.
The bind option is usefull cause when you do a chroot, you don't have access the other part of the system , so i'm not sure the symlink method work in that case. i'll ask and tell you.
Edit : I confirm It's that well about bind and chroot. and it seems to me , you can't create file in /sys , the kernel create them and you can read/change values. If you create one, it will not be taken in account by the kernel.
Also can you light up my lantern, which script in /system is called after the 2nd-init to launch the MIUI ?
Click to expand...
Click to collapse
When you use bootmenu to start 2nd-init it will run a script called /system/bootmenu/script/2nd-init.sh. The last line of this script is 2nd-init binary itself. When you call 2nd-init binary it forks init on top of itself causing something like a hot restart. So, what 2nd-init script does is remount / as RW and copy new init.rc, init.mpaphone_umts.rc and init binary to /. Then it calls 2nd-init binary in order to use your custom files instead of stock ones. You can do anything you like on init.rc, as I did to boot MIUI from a loopback device. Unfortunately MIUI was compiled for froyo kernel and can't find some devices it needs to work. Thats why I need to create symlinks inside /sys and I think I already found a way to do that. Will test and explain that later.
Ok thanks !
Even with the new symlinks the system is unable to boot. As I suspected it is far more complicated then just adding links to /sys, too bad. I think the only way we have to boot multi-systems with multi-kernels (like miui on froyo and stock on gb) will be using kexec hack. n1 know if some group already found a way to run kexec on milestone or milestone2?
You can't rebuilt miui over a generic 2.6.32 kernel ? Well i'm a total newb in rom dev, i assume the officiel ginger from google won't work, you must have some specific hardware stuff ! For kexec it seems they have some driver problem, but since you want to boot the moto kernel may be it'll be easier !
pat972 said:
You can't rebuilt miui over a generic 2.6.32 kernel ? Well i'm a total newb in rom dev, i assume the officiel ginger from google won't work, you must have some specific hardware stuff ! For kexec it seems they have some driver problem, but since you want to boot the moto kernel may be it'll be easier !
Click to expand...
Click to collapse
MIUI is closed source, so only team members are able to rebuilt it
Do you know how can I use kexec to boot moto kernel?
r2beta0 said:
MIUI is closed source, so only team members are able to rebuilt it
Click to expand...
Click to collapse
This is illegal - violation of GPL license. If they modified Linux kernel they should give users source code to those modifications.

Debian on droid 2 / droid 2 global

First off, This is probably in the wrong space, simply because I haven't reached my proper post count. (Too much of a lurker, sorry) but I think I've found something that will make fellow D2 / D2G smile, and I couldn't help but share this.
Here is where I got the idea from:
http://forum.xda-developers.com/showthread.php?t=962974
Unfortunately, the debian-img.zip link is no longer functional (at least it was the last time I checked). No big deal, you can get it from here: Debian-img.zip.
Download that, and make sure you have your Android sdk tools installed. You will need root and busybox. Connect phone to computer, memory card mode, create folder called debian, and unpack the debian-img.zip file into the debian folder on the sdcard. When complete, switch it to charge only mode and now for the fun to begin.
Open the command prompt, navigate to sdk\tools folder, and type adb devices. If you don't see your phone listed as a device (will be a bunch of letters and numbers) switch it to pc mode, run adb devices again.
Once it shows up, type the following:
adb shell
su
mount -o remount,rw -t yaffs2 /dev/block/mmcblk1p21 /system
export bin=/system/bin
export img=/sdcard/debian/debian.img
export mnt=/data/local/debian
mkdir /data/local/debian
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
busybox mount -t ext3 -o loop,noatime,nodiratime $img $mnt
busybox mount -t devpts devpts $mnt/dev/pts
busybox mount -t proc proc $mnt/proc
busybox mount -t sysfs sysfs $mnt/sys
busybox sysctl -w net.ipv4.ip_forward=1
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost" > $mnt/etc/hosts
busybox mount --bind /sdcard $mnt/sdcard
busybox chroot $mnt /bin/bash
if ps -Al | grep vnc > /dev/null
then
echo "vnc detected"
else
export USER=root
rm -r /tmp
mkdir /tmp
vncserver -geometry 854x480
fi
exit
mount -o remount,ro -t yaffs2 /dev/block/mmcblk1p21 /system
You can't just copy/paste that whole block of code due to the busybox commands. Copy and paste one at a time. I also found that you can't make a script with that code either (please prove me wrong!) and have it work on the droid2 or d2g without errors.
Once you put in the last command, hit ctrl+c, and then open AndroidVNC, using the following data (similar to the debondroid thread):
nickname: debian
Password: password
Address: localhost
Port: 5901
Then connect!
Issues:
I have found that not only can't I use a script, I also cannot use a terminal emulator or even connectbot to put in the commands line by line. I am unsure why, but this only seems to work when I use the adb shell through a computer/usb connection.
You may have issues using USB SDCARD mode after you have run this code. This is fixed by rebooting the phone (as this causes debian to stop being run, and the img is being run off the sdcard, which is mounted with busybox into the system). Otherwise, all other phone functions work perfectly.
A neat little bonus: I found that I am able to access the internet through a browser in debian using nothing more than my 3g data connection.
Feel free to comment! Especially if someone out there can get these commands to work as a script. Enjoy!
im dieing to get this running, i have D2G running miui ics, first i cant download debian-img.zip, it wont complete download. after searching and downloading debian arm iso and renaming img i try your instructions and get hung up at
busybox mount -t ext3 -o loop,noatime,nodiratime $img $mnt
any help would be apperciated thank you
It's possible the latest ICS leak could be the problem (I had only tried this on an old Fission build, stock (both) and CM7). However, sometimes when I would reset the phone and run the commands again, it would throw me an error in the same spot you're having. It was wierd (as it JUST worked). I flashed to a different ROM to see what was up and it was happy again--but only through one power cycle. There might be a spot in this code I'm missing, but the error it throws acts as if I were trying to mount the img in the wrong loop block. This could be to the loop block already having the residual data (from the forced shutdown of the phone not allowing a tru closure of Debian), and if that's the case It would make sense if we could wipe that loop block (del and recreate it) through ADB. I haven't had time, but I'll look into it tonight.
As for the img, I'll also look into that tonight (on my phone currently).
I really apperciate the speedy reply, I'm not showing ext2 or ext3 on miui ics, do you know of a working GB rom that debian works with. I really apperciate your work in getting this going, I'm surprised its not developed by more people as the idea of having a desktop computer in your pocket is appealing. Thanks again
That's the beauty of this workaround: D2/D2G doesn't have ext3 support. That's why I had to use this method and frankly could be one of the reasons that there are those out of the blue errors that don't make sense. I need time so I can get screenshots up (to prove I'm not lying), but this will work with the img file linked.
For a good GB build, you can try the latest CM7 build at rootzwiki, or the stock GB update.
I tried again and almost everything went smoothly until i punched in "fi" and it gave me an "Unknown hz value! <80> Assume 100." i finished the instructions and tried to fire up androidvnc and tried to connect and i get " VNC connection failed! localhost" so im going to try and attach a bmp of my cmd window. i am looking into the unkown hz value but so far am stumped. "change ext of file to bmp or png"
also im assuming the debian img which i was able to successfully download is a arm distro?
omg it worked!!!! i redid the steps like i had done i was still getting vnc connection error, then i changed the address in vnc from "localhost" to "127.0.0.1" and it works!!! thanks man
jlhaehl said:
I tried again and almost everything went smoothly until i punched in "fi" and it gave me an "Unknown hz value! <80> Assume 100." i finished the instructions and tried to fire up androidvnc and tried to connect and i get " VNC connection failed! localhost" so im going to try and attach a bmp of my cmd window. i am looking into the unkown hz value but so far am stumped. "change ext of file to bmp or png"
also im assuming the debian img which i was able to successfully download is a arm distro?
Click to expand...
Click to collapse
Debian img is indeed for ARM. And I haven't seen that error at all before, so I don't know what to tell you. Was working on school projects all night and just ran out of time, so didn't get to fire it up for screenshots, but it looks like you got it to work.
The next thing I'm gonna try is to put it in script form, and I think the solution is to put the busybox parts into a seperate script (android seems to like parsing the scripts all at once, so this borks the busybox commands).
I noticed that its busybox killing the script as well, good luck on compiling one that is compatable i will do wht i can on my end though i dont expect it to be much, thank you for putting this up, one more notch android has over the big apple

Using Debian binaries instead of busybox (Yes you can!)

Yes, it is possible to use Debian (or any other ARM based distribution) binaries instead of busybox. These devices have plenty of horsepower, and a fair amount of space on them. There should be enough room to get proper versions of command line apps baked in
NOTE: This is a PROOF OF CONCEPT. Do not attempt unless you are familiar with linux, chroot, and are fine with potentially screwing up your phone!
Frankly, I got tired of the limited feature set and compatibility issues that come with busybox. So, I decided to see if I could come up with something better... all it took was a free app from the market, 4 GB carved out of my SD card, and a little bit of time.
I've played a bit with chroot (mostly using the "Linux Installer" app):
https://market.android.com/details?id=com.galoula.LinuxInstall&hl=en
My SD card has a 4GB SD-EXT partition on it, formatted as EXT4, and then a FAT32 partition. I have my phone set up to never unmount the SD-EXT partition. And, since I'm using ICS, it's not using that partition for anything yet anyways.
In any case, to save a whole lot of trouble and deal with potential corruption issues, I set up the linux chroot to use a folder instead of an image. This turned out to be handy, because I can access files and play around with bind mounts much more easily than I can with an image file.
Right now I've got Debian Stable installed using chroot to my SD-EXT partition. After getting to a Debian prompt, I updated apt:
apt-get update
apt-get install build-essential
Now we have a fully working GCC environment to use. However, the environment that Linux Installer provides comes with most tools already at your disposal.
Now what? I don't want to have to chroot to use these utilities. That's a waste of my time
Here, we have two options... one is somewhat easy, and one is really easy.
These are not statically compiled applications, so we do need a few libraries. To replicate the functionality of busybox (and so much more), you really only need about 15 of them.
---------------------- THE REALLY EASY WAY ----------------------
The really easy way to do this is to bind mount the following folders from the "chroot" (in my case it's /sd-ext/linux) to the root of the android device:
/bin
/lib
/usr
/sbin
I'm writing this from memory, but I believe (off the top of my head) the proper command is:
busybox mount -o bind,rw /sd-ext/linux/bin /bin
busybox mount -o bind,rw /sd-ext/linux/lib /lib
busybox mount -o bind,rw /sd-ext/linux/usr /usr
busybox mount -o bind,rw /sd-ext/linux/sbin /sbin
Please correct me if I'm wrong (and this is assuming that your chroot environment is in /sd-ext/linux
On some devices, /bin and /sbin already exist. Deal with that however you want.
Now, all you have to do is:
EXPORT PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/sbin
If you've done it properly, you can shut down your chroot environment, go to /bin, and run ./ping 8.8.8.8
If it doesn't work, you screwed up somewhere (or I did!).
---------------------- THE SOMEWHAT EASY WAY ----------------------
On the android side, make the following folder structure:
/bin
/lib
/sbin
/usr
/usr/bin
/usr/lib
/usr/local/bin
Also, set your path so you can actually use the programs:
EXPORT PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/sbin
Now, let's say we want to have Debian's version of 'ping' without having to chroot. Do the following:
Pop into your chroot environment, head into the /bin folder, and run the following command:
ldd /bin/ping
This will tell you what shared libraries ping uses. In my case, it uses:
/lib/libgcc_s.so.1
/lib/libc.so.6
/lib/ld-linux.so.3
Pop back over to the android side, and run the following commands (assuming that /sd-ext/linux is your chroot environment, and adjusting as necessary for the libraries that are actually used by the program you are attempting to make work)
cp /sd-ext/linux/bin/ping /bin
cp /sd-ext/linux/lib/libgcc_s.so.1 /lib
cp /sd-ext/linux/lib/libc.so.6 /lib
cp /sd-ext/linux/lib/ld-linux.so.3 /lib
Now type:
/bin/ping
You will get either get an error message about a shared library, command not found, or (if you're lucky) the Debian version of ping.
If you're not so lucky, i'd suggest copying over /usr/bin/ldd from the debian side and using it to figure out (on the android side) which libraries you're missing.
***HUGE NOTE***: Remember that folder structure we're using? It will disappear when you reboot your phone, so back it up! I would actually recommend using bind mounts and a shell script to have a more "persistent" folder structure, but that's just me...
Like I said, there's really only about 15 shared libraries or so that are needed to give us a plethora of applications at our disposal. I'll give up a bit of my phone's system space to be able to drop to a proper bash command line and pull up nano, use the full and complete version of tar, gzip, or whatever utility I want.
As I'm still playing with this, I don't have a test package or anything to put up. This is more of a proof of concept idea (that I've already partially implemented on my phone).
Also, GCC can get you a long way Since we're compiling on-device, there is no cross-compiler necessary. Inside of the chroot, I compiled patchELF
http://nixos.org/patchelf.html
I thought that utility might come in handy. Compiles slowly (this is a phone we're compiling on), but it works great.
The next step is to see if I can bake it in...

[Q] Send files to a mounted windows share using adb

Kind of a one-off question... I'm working on a project that will automatically dd image an android phone to an off-phone location (the host computers d: drive for example) using a script executed through adb. It has to be automatic and the resulting dd image absolutely cannot be written to the phones memory.
Maybe something like:
Code:
$ su
# mount -o rw,remount -t vfat /dev/block/mmcblk0p4 /dd
# dd if=/dev/block/mmcblk0p1 of=/dd/system.dd
I've tried the cifs route but sadly, it appears the cifs.ko and slow-work.ko modules haven't been done for my handset (or I may be so stupid I can't even follow directions. It's a real possibility).
I thought I'd use the time-tested netcat method but again, I can't locate the nc binary for netcat that will run on my handset.
Any alternatives? Anyone know where the G2X specific kernel modules can be had? Someone maybe have an android nc binary?

Categories

Resources