1

I am using the Debian 12 live environment and have created a folder:

mkdir /mnt/boot

When I execute sudo chroot/mnt/boot, the following error is reported:

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

I have found this problem(https://serverfault.com/questions/162362/chroot-fails-cannot-run-command-bin-bash-no-such-file-or-directory), which looks very similar to my problem, but I followed the above steps and my problem has not been resolved. I don't know where the problem is with me?

1# mounting sda1 to /mnt/boot:

user@debian:sudo mount /dev/sda1 /mnt/boot

2# /bin/bash exists:

user@debian:/mnt/boot$whereis /bin/bash
bash: /usr/bin/bash /user/share/man/man1/bash.1.gz
user@debian:/mnt/boot$ls /bin/bash
/bin/bash

3# cp .so from lib and lib64:

user@debian:/mnt/boot$ls lib
ld-linux-86-64.so.2 libc.so.6 libdl.so.2 libtnfo.so.6 

4# make /mnt/boot/lib64 a symbolic to /mnt/boot/lib:

user@debian:/mnt/boot$sudo mkdir lib64
user@debian:/mnt/boot$sudo ln -s /mnt/boot/lib /mnt/boot/lib64

5# ldd:

user@debian:/mnt/boot$ldd /bin/bash
  linux-vdso.so.1 (0x00007ffdb8d1000)
  libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6(0x00007f3cda309000)
  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6(0x00007f3cda128000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f3cda493000)

1 Answers1

2

You are not checking a bash binary inside your chroot, you are checking one outside of the chroot. Ensure that the binary and all relevant libraries exist inside the chroot directory.

Gerald Schneider
  • 26,582
  • 8
  • 65
  • 97