I know similar questions were asked here a billion times, but different to those I got my system working. I just get the wrong error-message when I break it (and I want to debug another issue using these, so it's critical they work).
Starting with the working system:
$ tree . ├── bin │ └── bash ├── lib │ ├── libc.so.6 │ ├── libdl.so.2 │ └── libtinfo.so.6 └── lib64 └── ld-linux-x86-64.so.2 $ sudo chroot . /bin/bash bash-5.0# As we'd expect everything to run the bash is there and the bash runs.
Now when I remove anything inside the lib folder, I get an error telling me the library is missing:
$ rm -f lib/libdl.so.2 $ sudo chroot . /bin/bash /bin/bash: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory Also as expected. However, when I remove ld-linux-x86-64.so.2 inside the lib64 folder:
$ rm -f lib64/ld-linux-x86-64.so.2 $ sudo chroot . /bin/bash chroot: failed to run command ‘/bin/bash’: No such file or directory It's telling me /bin/bash is missing. The message is identical to when I actually delete it.
$ rm -f bin/bash $ sudo chroot . /bin/bash chroot: failed to run command ‘/bin/bash’: No such file or directory So for some reason it thinks the bash is missing when actually, what I assume is the dynamic linker, is missing. I assume this is because it's using this linker to load the elf in the first place, but that doesn't make the message more correct.
I even checked when I actually prevent bash it from finding ld-linux-x86-64.so.2 by running it in qemu on a different system I get the correct error message:
<some arm system>$ qemu-x86_64 -L /tmp/nowhere bin/bash /lib64/ld-linux-x86-64.so.2: No such file or directory Is this a bug? Is there some option to tell chroot to not behave like this and print the actually missing file? Is there some magic in this file? What is going on here?
TLDR: Why does chroot tell me the executable is missing when actually lib64/ld-linux-x86-64.so.2 is?