I have a filesystem build with buildroot, to compile code for a device using a old kernel and uClibc.

Now I want to chroot into the fs. The problem is, I don't have /bin/bash, just /bin/busybox.
How do I say chroot to use busybox ash instead?

I already tried to create a link to busybox ash, but chroot still says failed to run command /bin/bash. no such file or directory.

chroot /path/to/fs /bin/ash

See the chroot man page for details.

| improve this answer | |
  • this doesn't work, i just have busybox in my /bin/ directory. – Pingu Dec 13 '12 at 15:13
  • 1
    You said that you had a link ash -> busybox. Anyway, just run chroot /path/to/fs /bin/busybox ash then. – Stéphane Chazelas Dec 13 '12 at 15:17

Busybox does not include a ldd script. Instead you can run it like this.

            libresolv.so.2 => /lib/libresolv.so.2 (0xb6ece000)
            libc.so.6 => /lib/libc.so.6 (0xb6d8c000)
            /lib/ld-linux-armhf.so.3 (0xb6ef2000)

As you can see busybox depends on a couple of libraries in this case. So I created a directory structure like below and was able to run ls command.

# pwd

# ls -R
bin   lib   sbin

busybox  login    ls       sh

ld-linux-armhf.so.3  libc.so.6            libresolv.so.2

# chroot /home/<jail>/ ls
bin   lib   sbin
| improve this answer | |

You need to 'ldd busybox' and copy over the shared libs to which it links into the chroot. Use 'cp -L src dst' on the libs because they are usually simlinked.

| improve this answer | |
  • Busybox is usually statically linked to avoid this. – suprjami Nov 14 '19 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.