9

When I plug in a usbhub (7 sticks in) udev displays a lot of messages in console. Can I hide these messages or send them to /dev/null?

jsterr
  • 1,341

3 Answers3

10

On CentOS, I don't get udev messages when I plug in a simple USB thumbstick. Instead I get:

[sdb] Assuming drive cache: write through

a couple of times.

But this isn't udev, or syslog mentioning this to you on the console. You could know this for sure yourself, by killing syslogd or rsyslogd (Please make sure this isn't a production server, which I hope it is not what with inserting USB hubs and all that :) and re-inserting the USB device.

The messages still popup, so as Ulrich mentioned, this is coming from the kernel, or the USB module to be exact, which uses kernel.printk to show you these messages, not using any system services at all.

An excerpt from the linux documentation sysctl/kernel.txt:

The four values in printk denote: console_loglevel, default_message_loglevel, minimum_console_loglevel and default_console_loglevel respectively.

These values influence printk() behavior when printing or logging error messages. See 'man 2 syslog' for more info on the different loglevels.

  • console_loglevel: messages with a higher priority than this will be printed to the console
  • default_message_level: messages without an explicit priority will be printed with this priority
  • minimum_console_loglevel: minimum (highest) value to which console_loglevel can be set
  • default_console_loglevel: default value for console_loglevel
    #define KERN_EMERG    "<0>"  /* system is unusable               */
    #define KERN_ALERT    "<1>"  /* action must be taken immediately */
    #define KERN_CRIT     "<2>"  /* critical conditions              */
    #define KERN_ERR      "<3>"  /* error conditions                 */
    #define KERN_WARNING  "<4>"  /* warning conditions               */
    #define KERN_NOTICE   "<5>"  /* normal but significant condition */
    #define KERN_INFO     "<6>"  /* informational                    */
    #define KERN_DEBUG    "<7>"  /* debug-level messages             */

So using the above mentioned values for arguments to printk, you can get the kernel to shut up about informational messages or simple warnings on the console. For example,

echo "3 3 3 3" > /proc/sys/kernel/printk

made my insertions of the USB thumbstick go all quiet. Do you want to make it stick through a reboot, add a line to /etc/sysctl.conf:

kernel.printk = 3 3 3 3
reiche
  • 361
  • Since systemd v207 sysctl config files should be of the format /etc/sysctl.d/*.conf. –  Jul 18 '20 at 17:15
5

Yes, by changing to a different syslog channel, provided you understand how syslog works:

From udev manual:

   udev_log
          The logging priority which can be set to err ,info or the corre-
          sponding numerical syslog(3) value.  The default value is err.

So now you could edit /etc/udev/udev.conf and change this value.

daisy
  • 54,555
  • okay thanks for answering. How can I find out, which Syslog value I have to use that all usb-udev messages are hidden? – jsterr Aug 08 '12 at 08:19
  • Do I have to use the the values of "Facility Level" or of "Severity Level"? See http://en.wikipedia.org/wiki/Syslog#Facility_Levels – jsterr Aug 08 '12 at 12:36
0

you can simply try sudo setterm --msg off