Chroot:没有这样的文件或目录

Chroot:没有这样的文件或目录

我知道以前有人问过这个问题,但他们没有解决我的问题。

我已经绑定了/dev/proc,复制了qemu-arm-static/usr/bin。但 chroot 无法执行任何命令。

前一天还在工作。所以我现在不知道什么坏了。

strace dump 如果它指向任何东西

execve("/usr/sbin/chroot", ["chroot", "target-rootfs", "bash"], [/* 27 vars */]) = 0
brk(NULL)                               = 0x2513000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=127309, ...}) = 0
mmap(NULL, 127309, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4c601e3000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4c601e2000
mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4c5fc14000
mprotect(0x7f4c5fdd4000, 2097152, PROT_NONE) = 0
mmap(0x7f4c5ffd4000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f4c5ffd4000
mmap(0x7f4c5ffda000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4c5ffda000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4c601e1000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4c601e0000
arch_prctl(ARCH_SET_FS, 0x7f4c601e1700) = 0
mprotect(0x7f4c5ffd4000, 16384, PROT_READ) = 0
mprotect(0x608000, 4096, PROT_READ)     = 0
mprotect(0x7f4c60203000, 4096, PROT_READ) = 0
munmap(0x7f4c601e3000, 127309)          = 0
brk(NULL)                               = 0x2513000
brk(0x2534000)                          = 0x2534000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2981280, ...}) = 0
mmap(NULL, 2981280, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4c5f93c000
close(3)                                = 0
getcwd("/home/YashB/mini_deb", 4096)    = 21
lstat("/home/YashB/mini_deb/target-rootfs", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
chroot("target-rootfs")                 = 0
chdir("/")                              = 0
execve("/usr/local/sbin/bash", ["bash"], [/* 27 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/local/bin/bash", ["bash"], [/* 27 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/sbin/bash", ["bash"], [/* 27 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/bin/bash", ["bash"], [/* 27 vars */]) = -1 ENOENT (No such file or directory)
execve("/sbin/bash", ["bash"], [/* 27 vars */]) = -1 ENOENT (No such file or directory)
execve("/bin/bash", ["bash"], [/* 27 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/games/bash", ["bash"], [/* 27 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/local/games/bash", ["bash"], [/* 27 vars */]) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2492, ...}) = 0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2492
read(3, "", 4096)                       = 0
close(3)                                = 0
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "chroot: ", 8chroot: )                 = 8
write(2, "failed to run command \342\200\230bash\342\200\231", 32failed to run command ‘bash’) = 32
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": No such file or directory", 27: No such file or directory) = 27
write(2, "\n", 1
)                       = 1
close(1)                                = 0
close(2)                                = 0
exit_group(127)                         = ?
+++ exited with 127 +++

答案1

我已经让它工作了。我犯了一个非常愚蠢的错误。

我使用的qemu-arm-static是而不是qemu-aarch64-static我应该使用的,所以这就是一团糟。

答案2

您的跟踪输出会显示哪些文件丢失。

因此,只需安装跟踪标识的所有丢失文件并再次检查...重复此操作,直到完成。

您只需要在chroot()创建ENOENT.

相关内容