[Toybox] chroot command

Isaac idunham at lavabit.com
Fri Aug 2 19:08:17 PDT 2013


On Sat, Aug 03, 2013 at 01:12:28AM +0200, Dave wrote:
> Hi guys,
> 
> Many thanks for the terrific work on toybox.  I just saw the video
> by Mr. Landley on the toybox home page, and I was blown away by the
> vision of the future of the phone, and the trenchant analysis of the
> state of the GPL ecosystem.
> 
> Usually when I have a software problem I will write a pointed email
> to a list like this detailing exactly what went wrong and asking for
> help.  This is a bit more broad and you might decide it doesn't
> belong in your forum.

Doesn't look like it, except for the criticism of trying to get a 
self-hosted phone OS.

> I decided the other day to install Debian on my Motorola Milestone 2
> phone.  The typical way to do this is with a loopback mounted file
> that contains  a prepackaged distribution that is almost always
> Ubuntu.  
<snip a lot of filler about how>
> Now I have a Debian install,
> so I put it back on the phone and fired it up.  Or tried to.  Chroot
> didn't work. It says:
> 
> bash-4.1# chroot .
> chroot .
> Segmentation fault
> 
> Not terribly informative.  It struck me that it was looking for
> /bin/sh.  I ran strings on busybox and it looks like it is hardcoded
> in there.  So I setup a symlink in /bin ( this will be erased on
> reboot by the way). No dice. 

Usage: chroot NEWROOT [COMMAND [ARG]...]
If you specify a command with path, it's interpreted after changing root.
/bin/sh is the default command.

So if you have the root FS mounted at:
/sdcard2/ubuntu/

And the root FS contains bin/pdksh, which you want to run, use this command:
chroot /sdcard2/ubuntu /bin/pdksh

But really, you generally need to run this first:
for dir in proc sys dev dev/pts; do mount --bind /${dir} ./${dir}; done
That won't fix segfaults though.
ulimit -c unlimited will enable core dumps if the kernel supports them.


> Normally my next move would be to run
> strace on chroot to find the issue, but it looks like I don't have

Download a static strace binary for arm:
http://landley.net/aboriginal/downloads/binaries/extras/strace-armv5l

> strace.  Not having any diagnostic tools to work with, I tried
> replacing busybox with toybox. Still no dice.

> So, long story short, Debian is not working on my phone.
> 
> In the course of doing all this I got to thinking about what problem
> I was setting out to solve in the first place.  Putting Debian on
> your phone has some cool factor, but isn't the phone running Linux
> already?  What do I hope to get out of it?  More to the point, the
> inconvenience  of running in a chroot takes away from some of the
> enjoyment of running desktop apps on my phone. What applications
> exactly did I hope to run on the phone? 

> The entire thing with
> the phone is that it benefits from a symbiotic relationship with
> servers.  The client server paradigm was practically invented for
> the phone.  I have had the phone for several years and I have been
> happy with just using the ssh client and using a web browser,
> because every single thing that I want to see or use is available
> from one or the other.  I don't even get my mail on the phone.  The
> web-mail works fine.  Denninger wrote a piece the other day about
> cell phones as desktop replacements :
> http://market-ticker.org/akcs-www?post=222877
> It looks OK as far as it goes, but I think it ignores the reality of
> ubiquitous computing. Cell phones, or tablets ( or even laptops)
> don't need to be self hosting if they are always connected to the
> network and there are servers available. 

If you didn't notice, toybox is aiming at this same usecase.

And here's my own take on it:
I have 2 laptops, a smartphone, and an old desktop. My brother has a desktop,
a laptop, 2 tablets (one android-based), and 3 smartphones.
Any of the smartphones is more powerful than the computer I was using 5 years
ago, and has a battery life longer than all three laptops together.
So when I go on a trip for the weekend and want to customize the phone,
why do I have to bring a giant brick to do it? Why not use the phone?
Why should I shuffle my work around to avoid using a device that can 
do it longer?
<snip a lot>
> blackberry hard. I'm inclined to agree in principle.  The only
> reason I don't change is that I don't like the blackberry keyboard.
> Think about it, you are throwing over the C library, the guts of the
> /etc directory, the entire user-land, why cling to the kernel?  What
> is it you like about it? Is it the license? You just made a powerful

It works. 
Ever had a Hiptop/Sidekick? It's Andy Rubin's previous project:
a NetBSD-based phone. 

Linux runs on more processor architectures than any other kernel,
costs nothing for the OEM, doesn't play favorites with hardware vendors,
has drivers for hardware ranging from "it isn't available on the market yet"
to "The company that made those folded 20 years ago", runs in any amount
of ram you can through at it (4 MB to multiple TB), on anywhere from
sub-100 MHz to 5.5 GHz CPUs, still can run programs that were compiled 
when it was still new, is commonly used for experients and research,
can be customized by whoever wants to, doesn't care what userland 
you stick on top, and provides an API that a great deal of software uses.

It's also run by a man who doesn't care what you call it or how you use it.

> case that the license was dead.  Why are you helping the same people
> that would be perfectly happy to waterboard Snowden for the rest of
> his natural?

Not sure where this comes from. But since you mention Snowden...
Communication with servers is good. But the moment you rely on them, you
rely on someone who probably doesn't care about you.
If there's anything he did teach, it's that servers are not to be trusted.

Isaac Dunham


 1375495697.0


More information about the Toybox mailing list