0

For some reason, every time I plug in a USB device, a whole bunch of messages get dumped onto the terminal. (Saying something about device IDs, buffering modes, etc.)

How to I prevent this from happening?


Update:

Several people have asked me things, so let me summarise the potentially-relevant information I have collected so far:

  • The stray text appears on whichever virtual terminal I'm currently looking at. Each line is prefixed with what looks like the system uptime.

  • The quiet parameter is already on the kernel command line.

  • The current setting for printk is 6 4 1 7.

  • As best as I can tell, the syslog package isn't even installed. (Nor rsyslog.) Certainly there are no configuration files for it in /etc.

  • Init is definitely systemd.

  • /etc/sysctl.d is empty. /etc/sysctl.conf contains only comments.

  • 1
    One idea would be to check your syslog configuration to see if it's configured to dump any of the messages /dev/console – Bratchley Apr 14 '14 at 16:57
  • with udev rules – mikeserv Apr 14 '14 at 16:57
  • 1
    Which terminal? Is this specific to tty1 or do you get it on other ttys and/or in terminal emulators too? If it is just tty, it could be an issue with your boot configuration. – Graeme Apr 14 '14 at 17:42

4 Answers4

3

Boot with:

quiet loglevel=3

For info:

quiet       [KNL] Disable most log messages

loglevel=   All Kernel Messages with a loglevel smaller than the
        console loglevel will be printed to the console. It can
        also be changed with klogd or other programs. The
        loglevels are defined as follows:

        0 (KERN_EMERG)      system is unusable
        1 (KERN_ALERT)      action must be taken immediately
        2 (KERN_CRIT)       critical conditions
        3 (KERN_ERR)        error conditions
        4 (KERN_WARNING)    warning conditions
        5 (KERN_NOTICE)     normal but significant condition
        6 (KERN_INFO)       informational
        7 (KERN_DEBUG)      debug-level messages

After boot check (you want to see 3 as a first number reported):

$ sysctl kernel.printk
kernel.printk = 3       4       1       4

For more info on kernel.printk see Description of kernel.printk values.

printk might be overridden later in boot process by sysctl, usually once processing /etc/sysctl.conf or /etc/sysctl.d/* (depending on your distribution and boot process).

Then depending on your log daemon you might need further adjustments. For systemd you might look in /etc/systemd/journald.conf.

  • All good suggestions. But sadly no help. Setting the loglevel did nothing. The sysctl stuff is all blank, and so is the various systemd configuration files. Although, I did see some commented-out lines that might help... – MathematicalOrchid Apr 15 '14 at 10:33
1

If the messages have numbers before them, these are messages produced by the Linux Kernel. (The number means the number of seconds since the system was booted up.) To stop these messages, add the quiet parameter to your kernel command line. You may do this by editing a file in the /boot partition or using a configuration tool provided by your bootloader, e.g. GRUB. This will also stop the messages as your system starts.

user60684
  • 1,753
  • Nice suggestion, but I just checked, and that particular parameter is already there. (BTW, yes, the messages are prefixed with a number that looks like seconds of uptime.) – MathematicalOrchid Apr 14 '14 at 18:56
1

If Miroslav Koskar's suggestion regarding kernel loglevel did not help (you might as well use 2 or 1 there instead of 3, IMO), have a look in your /etc/syslog.conf (or rsyslog.conf) for a line containing /dev/console. This indicates the level of messages that are passed to the console by the system logger, which maybe the case if the kernel isn't doing it directly.

If the line looks like this:

*.warn       /dev/console

Change *.warn to *.crit or *.emerg, or just plain comment it out. For more information see your syslog documentation.


Since loglevel did not work and you apparently have no syslogd (bad idea, BTW), the problem is presumably that your printk settings are 6 4 1 7. The first one is the console log level, and that's what you need to change. You can do this as root one of two ways:

sysctl kernel.printk="2 4 1 7"
   - or -
echo "2 4 1 7" > /proc/sys/kernel/printk

You can then check them with sysctl kernel.printk or cat /proc/sys/kernel/printk. The USB messages are very unlikely to be CRITICAL (log level 2), and if they are submitted with no priority from whatever module, they use the default, which is the second of the four printk values (in this case, 4).

If this works for you, you should add a file to /etc/sysctl.d/ with one line:

kernel.printk = 2 4 1 7

I don't think you need quotes there. If that directory does not exist, add a line to /etc/sysctl.conf, creating it if necessary. For more information, see man sysctl.conf.

goldilocks
  • 87,661
  • 30
  • 204
  • 262
0

I was eventually able to solve this by adding the following command to one of my startup scripts:

klogconsole -l 3

This seems to make the system shut up. (At least, after the point where the command is executed.)