0

I am playing with linux booting for educationl purposes. Here is my micromalistic init program:

#include <stdio.h>

int main () {
        printf ("hello\n");
        while (1) { }
        return 0;
}

Compiled with gcc -static init.c -o initrd/init

ramdisk:

cd initrd
find .|cpio --quiet -H newc -o | gzip -9 -n > ../myinitrd.gz

As you can see /init is the only file in ram disc.

qemu-system-x86_64 -m 2G -accel kvm -kernel bzImage -append "init=/init" -initrd myinitrd.gz

Last lines I see in VM output:

[    0.803476] Run /init as init process
[    0.804003] init (70) used greatest stack depth: 14696 bytes left

It seems init loaded, but printf() message does not het through. Why?

exebook
  • 32,014
  • 33
  • 141
  • 226
  • 2
    "*but printf() message does not het through. Why?*" -- The questions you should be asking instead are "what device is used for stdout of the init process?" and "what device is designated the "console", i.e **/dev/console**?" *Hint*: the second question answers the first question. – sawdust Jan 06 '23 at 23:49

0 Answers0