[arch-general] Executing a command of a chroot outside of the chroot

Martin Panter vadmium+al at gmail.com
Thu Dec 6 22:12:58 EST 2012

On 6 December 2012 15:07, Δημήτρης Ζέρβας <01ttouch at gmail.com> wrote:
> I have a chroot environment on /data/workbench/mnt and I want to execute a
> binary which is inside the chroot environment (for example
> /data/workbench/mnt/bin/bash). I added the chroot library path to
> $LD_LIBRARY_PATH and I just did /data/workbench/mnt/bin/bash. I get a very
> strange error: No such file or directory. I am ABSOLUTELY sure that the
> file exists. When I chroot /data/workbench/mnt /bin/bash everything runs
> smoothly without errors. What's going on?
> BTW: I'm on armv7l

Just a guess but the file that doesn’t exist might be the ELF loader
aka interpreter. You can find out what it is by using the “ldd”, or
“readelf” commands:

$ readelf --segments /bin/bash
. . .
  INTERP         0x0000000000000238 0x0000000000400238 0x0000000000400238
                 0x000000000000001a 0x000000000000001a  R      1
      [Requesting program interpreter: /lib/ld-linux-x86-64.so.2]

It should vary depending on architecture and ABI. Then you might be
able to invoke it manually:

ROOT/lib/ld-linux-WHATEVER ROOT/bin/bash

Hope this helps, but it would probably only be practical for really
simple programs; you’ll probably have the same problem when Bash tries
to execute something.

More information about the arch-general mailing list