我正在尝试在升级到 libc 和许多其他工具后启动专有的内核构建和操作系统。我使用 3.2.0 内核中的 initramfs 和一些实用程序(例如 busybox)进行引导。然而,由于 udev 172 和 systemd 43 的更新,systemd
结构似乎发生了重大变化。我曾经使用 启动init=/bin/systemd
,现在似乎是/usr/lib/systemd/systemd
,但是仅仅更改该init
值不起作用,因为我收到此错误和内核恐慌:
# exec /bin/busybox switch_root /mnt/rootfs /usr/lib/systemd/systemd ro rootwait
BusyBox v1.20.2 (2014-05-28 13:23:51 IST) multi-call binary.
Usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT [ARGS]
Unmounting /proc
Executing switch_root and spawning init
switch_root: can't execute '/usr/lib/systemd/systemd': Too many levels of symbolic links
[49290.074730] Kernel panic - not syncing: Attempted to kill init!
[49290.093029] Backtrace:
[49290.100574] Function entered at [<c0017160>] from [<c0410744>]
[49290.118584] r6:4024473c r5:cf01bc00 r4:c0cdbb08 r3:60000013
[49290.136081] Function entered at [<c041072c>] from [<c04109c0>]
[49290.154074] Function entered at [<c0410950>] from [<c003e240>]
[49290.172069] r3:c0cac4a4 r2:0000001c r1:00000001 r0:c0457748
[49290.189560] r7:000000f8
[49290.197366] Function entered at [<c003dbdc>] from [<c003e348>]
[49290.215360] r7:000000f8
[49290.223152] Function entered at [<c003e2f4>] from [<c003e3b8>]
[49290.241147] r4:00000001 r3:00000001
[49290.252176] Function entered at [<c003e3a0>] from [<c0013a80>]
有谁知道符号链接错误是来自 busybox 的 switch_root 还是启动/usr/lib/systemd/systemd
进程?
我假设 switch_root 在解释某些内容时存在问题,但可能是我没有正确配置的 systemd。
我只是想不出如何调试这个的想法。
这是ls -ld
输出(对于下面混乱的评论感到抱歉):
# ls -ld /mnt/rootfs/usr/lib/systemd/
drwxrwxr-x 7 0 0 4096 Jan 8 01:21 /mnt/rootfs/usr/lib/systemd/
#
# ls -ld /mnt/rootfs/usr/lib/systemd/systemd
-rwxr-xr-x 1 0 0 674468 Apr 12 2016 /mnt/rootfs/usr/lib/systemd/systemd
这是strace
输出:
# exec strace -f /bin/busybox switch_root /mnt/rootfs /usr/lib/systemd/systemd r
o rootwait
execve("/bin/busybox", ["/bin/busybox", "switch_root", "/mnt/rootfs", "/usr/lib/systemd/systemd", "ro", "rootwait"], [/* 6 vars */]) = 0
brk(0) = 0x1a45000
uname({sys="Linux", node="(none)", ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400ac000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib/tls/v7l/neon/vfp/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/v7l/neon/vfp", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/tls/v7l/neon/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/v7l/neon", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/tls/v7l/vfp/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/v7l/vfp", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/tls/v7l/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/v7l", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/tls/neon/vfp/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/neon/vfp", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/tls/neon/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/neon", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/tls/vfp/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/vfp", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/tls", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/v7l/neon/vfp/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/v7l/neon/vfp", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/v7l/neon/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/v7l/neon", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/v7l/vfp/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/v7l/vfp", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/v7l/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/v7l", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/neon/vfp/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/neon/vfp", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/neon/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/neon", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/vfp/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/lib/vfp", 0xbe9d3540) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\250g\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1242860, ...}) = 0
mmap2(NULL, 1312160, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x400d3000
mprotect(0x401fe000, 65536, PROT_NONE) = 0
mmap2(0x4020e000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12b) = 0x4020e000
mmap2(0x40211000, 9632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40211000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40214000
set_tls(0x402144c0, 0x40214ba8, 0x4004b000, 0x402144c0, 0x4004b000) = 0
mprotect(0x4020e000, 8192, PROT_READ) = 0
mprotect(0x4004a000, 4096, PROT_READ) = 0
getuid32() = 0
chdir("/mnt/rootfs") = 0
stat64("/", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
stat64(".", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
getpid() = 771
mmap2(NULL, 45056, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x402ba000
mmap2(NULL, 401408, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40307000
brk(0) = 0x1a45000
brk(0x1a67000) = 0x1a67000
munmap(0x40307000, 401408) = 0
munmap(0x402ba000, 45056) = 0
write(2, "BusyBox v1.20.2 (2016-04-12 15:5"..., 41BusyBox v1.20.2 (2016-04-12 15:51:37 IST)) = 41
write(2, " multi-call binary.\n", 20 multi-call binary.
) = 20
write(2, "\nUsage: ", 8
Usage: ) = 8
write(2, "switch_root", 11switch_root) = 11
write(2, " ", 1 ) = 1
write(2, "[-c /dev/console] NEW_ROOT NEW_I"..., 42[-c /dev/console] NEW_ROOT NEW_INIT [ARGS]) = 42
write(2, "\n\n", 2
) = 2
exit_group(1) = ?
+++ exited with 1 +++
Unmounting /proc
Executing switch_root and spawning init
switch_root: can't execute '/usr/lib/systemd/systemd': Too many levels of symbolic links
[ 52.064978] Kernel panic - not syncing: Attempted to kill init!
[ 52.083278] Backtrace:
[ 52.090828] Function entered at [<c0017160>] from [<c0410764>]
[ 52.108828] r6:40259730 r5:cf01bc00 r4:c09c1b08 r3:600b0013
[ 52.126328] Function entered at [<c041074c>] from [<c04109e0>]
[ 52.144324] Function entered at [<c0410970>] from [<c003e240>]
[ 52.162319] r3:c09924a4 r2:00000020 r1:00000001 r0:c0457750
[ 52.179817] r7:000000f8
[ 52.187621] Function entered at [<c003dbdc>] from [<c003e348>]
[ 52.205616] r7:000000f8
[ 52.213410] Function entered at [<c003e2f4>] from [<c003e3b8>]
[ 52.231416] r4:000a0138 r3:ffffffff
[ 52.242451] Function entered at [<c003e3a0>] from [<c0013a80>]
不幸的是,我在其中找不到任何有用的信息。查看 busybox 代码,它会执行一个操作chroot
,清理旧的安装目录并execv
使用我的init
命令运行一个操作。