chroot: failed to run command ‘/bin/bash’: No such file or directory

ajnabi picture ajnabi · Nov 10, 2015 · Viewed 29.1k times · Source

In the process of trying to rescue an unbootable Debian Jessie system, I get the following error when trying to chroot:

chroot: failed to run command ‘/bin/bash’: No such file or directory

I have been googling around and it's supposedly related to a 64bit/32bit clash (chrooting from a 32bit into 64bit or vis a versa), yet I don't see how that could apply here since I am rescuing a 64bit system with a 64bit live-hybrid-Debian-USB-stick.

/bin/bash is in the chroot directory and so are the library depenencies, as per ldd.

Does anyone have an idea what is causing the error?

Below are my mount points, and an ls:

  # mount |grep mnt
/dev/mapper/centos_vh200-root on /mnt/vh2 type ext4 (rw,relatime,data=ordered)
/dev/sda1 on /mnt/vh2/boot type ext4 (rw,relatime,data=ordered)
none on /mnt/vh2/proc type proc (rw,relatime)
devtmpfs on /mnt/vh2/dev type devtmpfs (rw,nosuid,size=10240k,nr_inodes=414264,mode=755)
sys on /mnt/vh2/sys type sysfs (rw,relatime)


  # ls -l /mnt/vh2/bin/bash
-rwxr-xr-x 1 root root 1029624 Nov 12  2014 /mnt/vh2/bin/bash

This is ldd output for bash:

 # ldd /mnt/vh2/bin/bash
      linux-vdso.so.1 (0x00007ffd49bcc000)
      libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007fad99f1a000)
      libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fad99cf0000)
      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fad99aec000)
      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fad99743000)
      /lib64/ld-linux-x86-64.so.2 (0x00007fad9a13f000)

Terminal session:

  # mount /dev/centos_vh200/root /mnt/vh2
  # mount /dev/sda1 /mnt/vh2/boot/
  # mount -t proc none /mnt/vh2/proc/
  # mount -o bind /dev /mnt/vh2/dev/
  # mount -t sysfs sys /mnt/vh2/sys/
  # chroot /mnt/vh2/ /bin/bash
chroot: failed to run command ‘/bin/bash’: No such file or directory

Answer

Dariusz Bączkowski picture Dariusz Bączkowski · Nov 11, 2015

ldd /mnt/vh2/bin/bash is done outside chroot so it finds your live system libraries. Look for libraries in /mnt/vh2/ not in /.