我开始使用 busybox 构建自己的发行版。我使用自编译的内核5.15。已经创建了一个 initramfs。这是 initramfs 的初始化脚本:
#!/bin/sh
/bin/sh
现在如果我使用 qemu 启动它:
qemu-system-x86_64 -kernel kernel_5.15 -initrd initrd.img
我遇到内核恐慌:
[ 1.765830] Run /init as init process
[ 1.767253] Failed to execute /init (error -2)
[ 1.767516] Run /sbin/init as init process
[ 1.768032] Run /etc/init as init process
[ 1.768338] Run /bin/init as init process
[ 1.768656] Run /bin/sh as init process
[ 1.769230] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[ 1.770061] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.15.145 #1
[ 1.770416] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[ 1.770914] Call Trace:
[ 1.771538] <TASK>
[ 1.771789] dump_stack_lvl+0x34/0x48
[ 1.772223] ? memcpy_orig+0x110/0x123
[ 1.772421] panic+0xfb/0x2b2
[ 1.772563] ? kernel_execve+0x14b/0x190
[ 1.772762] ? rest_init+0xb0/0xb0
[ 1.772933] kernel_init+0x10e/0x110
[ 1.773095] ret_from_fork+0x22/0x30
[ 1.773314] </TASK>
[ 1.773789] Kernel Offset: 0x37e00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[ 1.774506] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---
我还尝试传递 init 参数,例如 init=/init。但也会出现内核恐慌,如下所示:
[ 1.784834] Run /init as init process
[ 1.786264] Failed to execute /init (error -2)
[ 1.786513] Run /init as init process
[ 1.787051] Kernel panic - not syncing: Requested init /init failed (error -2).
[ 1.787507] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.15.145 #1
[ 1.787853] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[ 1.788318] Call Trace:
[ 1.788994] <TASK>
[ 1.789254] dump_stack_lvl+0x34/0x48
[ 1.789656] ? memcpy_orig+0x110/0x123
[ 1.789807] panic+0xfb/0x2b2
[ 1.789933] ? rest_init+0xb0/0xb0
[ 1.790071] kernel_init+0xba/0x110
[ 1.790214] ret_from_fork+0x22/0x30
[ 1.790396] </TASK>
[ 1.790862] Kernel Offset: 0x7600000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[ 1.791676] ---[ end Kernel panic - not syncing: Requested init /init failed (error -2). ]---
请帮忙。如果你需要我可以提供更接近的信息
尝试过:
- 将 init 作为参数传递
- 更改 initramfs 文件的权限
- 其他内核
- youtube 上有不同的教程