[g1-hackers] Debian on root progress, new update.zip, some tasks

Jay Freeman (saurik) saurik at saurik.com
Wed Nov 19 05:20:58 UTC 2008

So, I figured I'd give a status report on what I've been doing with improvements to the Debian installation for the G1, and it has turned into this e-mail.

What I really want (and what I think many of us want) to be able to do is to have / be Debian and have the Android folders just live comingled into the process. Using unionfs, as documented on my website, mostly satisfies this need but fails to totally solve the problem as we've been noticing issues with a few system services (things like being unable to turn off wifi). It also makes it difficult to install some packages as they might need to create folders or files at /, which is on the rootfs (stored in RAM).

In order to accomplish this, I have been working on making massive improvements to init. Specifically:

1) added "chdir" and "chroot"
2) setup "move" flag for mount
3) added "include" for init.rc files
4) finished implementing "trigger"
5) "mknod" that can wait for a device

I then modified the base init.rc file to include /system/init.rc and /data/init.rc as these partitions are brought online and trigger system and userdata, respectively. This way you can tack more initialization sequences in simple ways (the update image can store stuff in /system/init.rc and the end user can store stuff in /data/init.rc).

BEGIN diversion

While working on this, I also made some other improvements (including to the kernel), and have released a replacement update.zip that I'm using as a base to work on all of this. Some other enhancements I have included are:

1) included Android's /system/xbin folder for a real su (rather than just a setuid sh), among other useful tools
2) compiled crypto_core and other small features into the kernel that allow more types of loadable modules to work
3) applied the complete unionfs patch (rather than hacking the unionfs module to not require it)
4) included a small set of kernel modules (including ext2 and unionfs) in /system/modules with a modules.dep
5) upgraded busybox to 1.12.1, fixed its losetup to use /dev/block/loop* and its modprobe to use /system/modules
6) at Jesus Freke's suggestion, setup /system/xbin (and later /system/modules) to mount from a compressed image
7) added a loop at filename feature to init (check out /system/init.rc for an example) to make #6 possible
8) removed the annoying "E:Can't open /cache/recovery/command" error message from the recovery image
9) turned off Android's "paranoid sockets" feature to make using the network as non-root work as expected on Unix
10) applied the compcache kernel patch (currently unused) in the hope of later being able to obtain a compressed swap
11) setup the busybox shell in the recovery image so you can "adb shell" while in recovery mode (as root, of course)
12) a (mostly useless) usleep command for init (really only to help when debugging race conditions during boot)
13) switched to using a more modern tcp flow control algorithm (I think, it might be that it was the default anyway)
14) compiled in some minor kernel features, specifically /dev/{k,}mem and kernel module versioning
15) probably a really small change or two that I'm forgetting as it was almost certainly not important ;P

This file can be downloaded from here:

It can be installed to a G1 using the standard method: place on the root of your SD card as "update.zip", boot into recovery (hold Home while booting), hit Alt-L followed by Alt-S, and then wait while the phone reboots itself a few times.

END diversion

I then wrote a /data/init.rc that used the new commands to mount the second partition of the SD card to /mnt and pivot it to /. This has not yet worked correctly: none of the devices seem to be working correctly when I do this, although I believe I will be able to defeat this in the near future (as I bet it is just some sockets that are failing to be created in the right place). Specifically, you can't use the keyboard, the touchscreen, you have no signal and it doesn't know the remaining battery life ;P. Other than that, you know... it works /great/! (It does, in fact, boot up, start running things, even render the display correctly.)

There is a second issue, which is that the /sdcard folder does not mount correctly while the second partition is mounted :(. This should be fixable, but I currently do not know where in the pipeline the problem actually lies. More information can be found starting in the middle of the following thread on the android-porting Google group:


If there's anyone else out there that wants to play with this, you should:

0) somehow repartition your SD card and get that all setup (I have things like a static build of parted that helps with this, but right now this should only be done by people who know how to do this type of thing ;P)

1) install the above signed-kila-srk-116143.1.zip update
2) add the following source to /etc/apt/sources.list.d:
    deb http://apt.saurik.com/ lenny main
3) apt-get install android-base (gives you the right mount targets)
4) put the (attached) file (my current best attempt) as /data/init.rc

END status

So, things that still need to be done:

** Debian on /:
1) the hardware obviously needs to work, but hopefully this will be easy
2) /sdcard needs to work when the second partition is mounted (can be put off)

** Debian at All:
1) we need a libnss_android (so that glibc can do things like resolve uid/gid's and do DNS correctly)
2) something needs to be done to connect the init systems together, so that Debian's daemons start

I don't know if anyone is willing to, for example, help with libnns_android: its a rather decomposable task that mostly requires C knowledge, but there is definitely some room here for people who want to get involved in this process. ;P

Jay Freeman (saurik)
saurik at saurik.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.telesphoreo.org/pipermail/g1-hackers/attachments/20081118/98c3f0a2/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: init.rc
Type: application/octet-stream
Size: 547 bytes
Desc: not available
Url : http://www.telesphoreo.org/pipermail/g1-hackers/attachments/20081118/98c3f0a2/attachment.obj 

More information about the G1-Hackers mailing list