Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info how to fix failed chroot #194

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Docs/CrossBuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<arch> /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-<arch>-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/<arch> /usr/bin/qemu-<arch>-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-<arch>` 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 <<EOF
package qemu-user-static
type magic
offset 0
magic \x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00
mask \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
interpreter /usr/bin/qemu-riscv64-static
EOF
$ sudo update-binfmts --import /tmp/qemu-riscv64
```

Now chroot should work.

## Non-standard system paths

For systems with non-standard paths (like `/lib64/`) `-L<path>` option might not be enough to find libararies, since `-L` specifies search dirs only for explicitly specified libs (i.e. through `-l<libname>` in command line).
Expand Down
Loading