Kernel module: how to get console output?

I am writing a kernel module and I want to be able to print something on the console output when booting with insmod module.ko.

I tried to use

printk(KERN_EMERG "test kernel emergency\n");

but nothing is displayed on my console. However, he appears in dmesg.

Additional Information:
I am using a 32-bit version of Intel x86 with linux-3.0.0

and cat /proc/sys/kernel/printkgives4 4 1 7

+5
source share
3 answers

1- make sure that you are in full terminal mode (press Alt + Ctrl + f1)

2- printk(KERN_EMERG "test kernel emergency\n"); try instead

printk(KERN_ALERT "test kernel alert\n");

+7
source

Jens

printk ​​ syslogd. dmesg , syslogd.

( insmod), Linux. ubuntu printk, ALERT EMERGENCY.

+3

You need to change your syslog to print emergency kernel messages to the console (or specific users or ttys).

There are many syslog daemons, if you do not control the one you are using and you are not root, you are out of luck. If you control the one you are using, syslog-ng is pretty good and has examples of how to do this manually in it.

0
source

All Articles