Is it possible to prevent kernel messages from appearing in dmesg output?

E.g. I am running software that terminates PPPoE tunnels. One of the features it provides is the ability to set custom interface names.

However this results in messages in dmesg such as:

[Mon May 28 09:50:06 2018] ifname.3: renamed from pppoe3 
[Mon May 28 11:07:40 2018] ifname.4: renamed from pppoe4 
[Mon May 28 11:11:37 2018] ifname.5: renamed from pppoe5 
[Mon May 28 11:18:26 2018] ifname.6: renamed from pppoe6 
[Mon May 28 11:40:46 2018] ifname.7: renamed from pppoe7

I tracked the function responsible for it to be netdev_info: https://github.com/torvalds/linux/blob/v4.16/net/core/dev.c#L1204

The problem with these messages it is that they fill the buffer and override any other important messages (driver crashes, iptable warnings, etc.).

Is it possible to supress this specific message from appearing in dmesg output?

I tried setting sysctl kernel.printk but it seems to have no effect, and messages appear in dmesg output regardless of the settings.

Thank you.

  • What did you try setting your kernel.printk value to? – Zoredache Jun 4 '18 at 22:17
  • One of the great things about open source is being able to make this kind of simple change even if there's no option to do so. You can just remove the code from your version of the kernel. (Or at least, I can do that in the distribution I use) – user253751 Jun 5 '18 at 2:23
  • @immibis compiling custom kernel would be an option as I had done it before and is relatively easy under debian and the change would be just one line, but this would be done as a last resort by me (it takes long to compile and I'd need to keep track of important security updates, so I'd lose the ability of a hassle free apt-get update && apt-get upgrade from time to time) – krdx Jun 5 '18 at 8:05

Well that function is netdev_info is printing kernel messages via printk at the INFO level. I believe you can adjust your kernel.printk to control the level of messages that actually get logged. So you could adjust downwards from a level of INFO to the less noisy WARN or ERR levels.

I generally like to go with this 3 4 1 3 as a default

# /etc/sysctl.d/printk.conf
# Uncomment the following to stop low-level messages on console
kernel.printk = 3 4 1 3

See these links for more details about kernel.printk

This will suppress more then just that specific message. If you have other information being logged at the INFO level that you actually want or need to see, this may not be a good solution.

If you only care about what is getting logged into you syslog managed logs, then you should be able to apply filters depending on what syslog daemon you are running.

  • Thanks. I was following this post before: superuser.com/questions/351387/… My default kernel.printk values were: "4 4 1 7" dmesg -l info prints the interface renames (this confirms they are INFO level) However, even completely erasing kernel.printk=" 0 0 0 0" seems to have no effect on dmesg as the messages still appear in the output. I filtered these messages from rsyslog via 'if $syslogfacility-text=='kern' and $syslogseverity >= 5 then stop' so at least they dont fill actual files on the system. – krdx Jun 5 '18 at 8:15
  • But unfortunately they can still override useful messages in dmesg such as (iptables conntrack overflows, NIC driver hangs/crashes, etc). – krdx Jun 5 '18 at 8:18

dmesg reads from the kernel ring buffer and, as far I can tell, you can not prevent it from being "polluted" from unwanted messages.

Anyway, depending on your distribution, older kernel logs can be found in /var/log/messages or /var/log/syslog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.