From 196f508af3968d2f6917cf733ebb850b41f0c227 Mon Sep 17 00:00:00 2001 From: Gleb Date: Sat, 13 Apr 2024 14:19:02 +0300 Subject: [PATCH] Add info how to fix failed chroot --- Docs/CrossBuild.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Docs/CrossBuild.md b/Docs/CrossBuild.md index 5e7d96a7..8862e5a6 100644 --- a/Docs/CrossBuild.md +++ b/Docs/CrossBuild.md @@ -104,6 +104,33 @@ Another way is to create rootfs with all required libs from scratch: https://wik # Troubleshooting +## `chroot failed: no such file or directory` + +Debootstrap might fail with smth like `chroot failed: no such file or directory` during rootfs generation when it needs to continue setup in rootfs. +Or same can happen during manual chroot `sudo chroot ./rootfs/ /bin/bash`, which also fails with same error as debootstrap even though `/bin/bash` is present in rootfs. + +To fix this first check that `qemu--static` is copied from `/usr/bin/` on host to `/usr/bin` in rootfs. If it's not copied, do that manually. + +If this doesn't solve the problem, this means that binfmt was misconfigured for some reason. To verify this try `sudo chroot ./rootfs/ /usr/bin/qemu--static /bin/bash`, and if it works, the problem is indeed with binfmt. + +1. First check that binfmt is enabled with `cat /proc/sys/fs/binfmt_misc/status`. +2. Then check that config for required arch is present with `cat /proc/sys/fs/binfmt_misc/qemu-` or `update-binfmts --display`, and that this arch is enabled. +3. Even if both are present and seem correct, there migt be misconfiguration (i.e. binfmt arch config is outdated). To update config follow next steps (example for RISC-V from https://wiki.debian.org/RISC-V#Manual_qemu-user_installation): + +```sh +$ cat >/tmp/qemu-riscv64 <` option might not be enough to find libararies, since `-L` specifies search dirs only for explicitly specified libs (i.e. through `-l` in command line).