我正在努力学习如何为Linux构建一个最小的initramfs。我设置了CONFIG_INITRAMFS_SOURCE="asd"
,创建了asd
目录,里面有一个使用gcc -fpic -static main.c -o init
编译的init
文件。在内核日志中,我得到了以下错误:
Run /init as init process
Failed to execute /init (error -8)
这是输入源代码:
int main() {
printf("Hello, world!n");
for(;;);
}
我做错了什么?
它与defconfig内核和CONFIG_INITRAMFS_SOURCE
集一起工作。在目录中,我必须使节点dev/console
。
mkdir dev
sudo mknod --mode=0600 dev/console c 5 1
在qemu中运行-kernel linux*/arch/x86_64/boot/bzImage
之后,调用init之后显示Hello, world!
。