0

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)
ABeginner
  • 5
  • 2
  • @GeraldSchneider Successfully, thank you very much for your answer. – ABeginner Aug 22 '23 at 05:53
  • Your live environment is running from the computer memory. The files loaded are a kernel and an intramfs respectively. The initramfs gets unpacked to /run. All your attempts to create a new folder are indeed altering the unpacked initramfs which is transient and not persistent. The /run mentioned in the previous line is also from the unpacked initramfs. Creating /mnt/boot and doing a chroot to /mnt/root is creating a loop – RAMUMSRK Aug 22 '23 at 05:34

1 Answers1

1

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
  • 23,274
  • 8
  • 57
  • 89
  • Because the debian12 live environment does not have grub install and update grub commands, I have now switched the environment to the ubuntu 19.04 live environment. The same operation, why is there still a problem with ubuntu 19.04 chroot? – ABeginner Aug 22 '23 at 06:46